Adding the project for code injection and XSS vulnerability testing
This project is designed to help developers understand and mitigate code injection and XSS vulnerabilities. It includes a backend API and a frontend interface for testing various attack vectors in a controlled environment.
This commit is contained in:
42
frontend/scripts/lint-check.ts
Normal file
42
frontend/scripts/lint-check.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { exec } from 'child_process';
|
||||
import chalk from 'chalk';
|
||||
import ora from 'ora';
|
||||
|
||||
async function runCommand(command: string, description: string): Promise<void> {
|
||||
const spinner = ora(`Running ${description}...`).start();
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(command, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
spinner.fail(`${description} failed.`);
|
||||
console.error(chalk.red(`${description} failed.`));
|
||||
console.error(chalk.red(stderr));
|
||||
reject(new Error(stderr));
|
||||
} else {
|
||||
spinner.succeed(`${description} passed.`);
|
||||
console.log(chalk.green(`${description} passed.`));
|
||||
console.log(stdout);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function runLint(): Promise<void> {
|
||||
try {
|
||||
await runCommand('npm run lint:prettier', 'Prettier check');
|
||||
console.log(chalk.green('All checks passed.'));
|
||||
process.exit(0);
|
||||
} catch (err) {
|
||||
console.error(chalk.red('Lint checks failed.'));
|
||||
console.error(chalk.red('Please fix the issues above and try again.'));
|
||||
console.error(
|
||||
chalk.yellow(
|
||||
`Hint: You can run ${chalk.cyan('npm run prettier')} to automatically format your code.`
|
||||
)
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
runLint();
|
||||
Reference in New Issue
Block a user