UNPKG

vibe-guard

Version:

🛡️ Vibe-Guard Security Scanner - 25 essential security rules to catch vulnerabilities before they catch you! Zero dependencies, instant setup, works everywhere, optimized performance. Detects SQL injection, XSS, exposed secrets, CSRF, CORS issues, and mo

154 lines 6.23 kB
#!/usr/bin/env node "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const commander_1 = require("commander"); const chalk_1 = __importDefault(require("chalk")); const index_1 = __importDefault(require("../index")); const version_1 = require("../types/version"); const program = new commander_1.Command(); program .name('vibe-guard') .description('🛡️ Vibe-Guard Security Scanner - Catch security issues before they catch you!') .version(version_1.VERSION); const fs = __importStar(require("fs")); async function handleScan(target, options) { try { console.log(chalk_1.default.blue.bold('🛡️ Starting Vibe-Guard Security Scan...\n')); const scanOptions = { target, format: options.format, verbose: options.verbose, exclude: options.exclude, include: options.include }; const vibeGuard = new index_1.default(); const output = await vibeGuard.scanAndFormat(scanOptions); if (options.outputFile) { fs.writeFileSync(options.outputFile, output); console.log(chalk_1.default.green(`✅ Results written to: ${options.outputFile}`)); } else { console.log(output); } const result = await vibeGuard.scan(scanOptions); if (result.issuesFound > 0) { process.exit(1); } } catch (error) { console.error(chalk_1.default.red.bold('❌ Error:'), error instanceof Error ? error.message : 'Unknown error'); process.exit(1); } } program .command('scan') .description('Scan files or directories for security issues') .argument('<target>', 'File or directory to scan') .option('-f, --format <format>', 'Output format (table, json, sarif, html)') .option('-o, --output-file <file>', 'Write output to file') .option('-v, --verbose', 'Verbose output', false) .option('--exclude <patterns...>', 'Exclude patterns') .option('--include <patterns...>', 'Include patterns') .action(handleScan); program .argument('[target]', 'File or directory to scan') .option('-f, --format <format>', 'Output format (table, json, sarif, html)') .option('-o, --output-file <file>', 'Write output to file') .option('-v, --verbose', 'Verbose output', false) .option('--exclude <patterns...>', 'Exclude patterns') .option('--include <patterns...>', 'Include patterns') .action((target, options) => { if (target) { handleScan(target, options); } else { program.help(); } }); program .command('rules') .description('List all available security rules') .action(() => { const vibeGuard = new index_1.default(); const rules = vibeGuard.getRules(); console.log(chalk_1.default.blue.bold('🛡️ Available Security Rules:\n')); rules.forEach(rule => { const severityColor = rule.severity === 'critical' ? chalk_1.default.red.bold : rule.severity === 'high' ? chalk_1.default.red : rule.severity === 'medium' ? chalk_1.default.yellow : chalk_1.default.blue; console.log(`${chalk_1.default.bold(rule.name)} ${severityColor(`[${rule.severity.toUpperCase()}]`)}`); console.log(` ${chalk_1.default.gray(rule.description)}\n`); }); }); program .command('version') .description('Show version information') .action(() => { console.log(chalk_1.default.blue.bold('🛡️ Vibe-Guard Security Scanner')); const vibeGuard = new index_1.default(); console.log(`Version: ${vibeGuard.getVersion()}`); console.log('Built for developers who code fast and need security that keeps up! 🚀'); console.log(chalk_1.default.gray('TypeScript-powered, zero-dependency security scanning')); }); program .command('init') .description('Create a default vibe-guard.json configuration file') .action(() => { const vibeGuard = new index_1.default(); vibeGuard.createConfigFile(); }); program .command('config') .description('Show sample configuration') .action(() => { const vibeGuard = new index_1.default(); console.log(chalk_1.default.blue.bold('📝 Sample vibe-guard.json Configuration:\n')); console.log(vibeGuard.generateConfig()); }); process.on('unhandledRejection', (reason, promise) => { console.error(chalk_1.default.red.bold('❌ Unhandled Rejection at:'), promise, chalk_1.default.red('reason:'), reason); process.exit(1); }); process.on('uncaughtException', (error) => { console.error(chalk_1.default.red.bold('❌ Uncaught Exception:'), error); process.exit(1); }); program.parse(); //# sourceMappingURL=vibe-guard.js.map