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.
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
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();
|