ubon
Version:
Security scanner for AI-generated apps (Cursor, Lovable, Windsurf, v0). Catches hardcoded secrets, prompt injection, hallucinated imports, Server Actions / Edge runtime mistakes, and the vibe-coded vulnerabilities traditional linters miss.
40 lines • 1.89 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.renderPreCommitConfig = renderPreCommitConfig;
exports.installPreCommitHooks = installPreCommitHooks;
const fs_1 = require("fs");
const child_process_1 = require("child_process");
const path_1 = require("path");
function renderPreCommitConfig(options) {
const mode = options.mode || 'fast';
const failOn = options.failOn || 'error';
const entry = `ubon check --git-changed-since HEAD ${mode === 'fast' ? '--fast' : ''} --fail-on ${failOn}`.trim();
return `repos:\n - repo: local\n hooks:\n - id: ubon-security-check\n name: Ubon Security Scanner\n entry: ${entry}\n language: system\n files: \\\\.(js|jsx|ts|tsx|svelte|astro)$\n pass_filenames: false\n`;
}
function installPreCommitHooks(options) {
const directory = options.directory || process.cwd();
if (!(0, fs_1.existsSync)((0, path_1.join)(directory, '.git'))) {
throw new Error('Not a git repository (missing .git)');
}
const yaml = renderPreCommitConfig(options);
const target = (0, path_1.join)(directory, '.pre-commit-config.yaml');
if (options.dryRun) {
console.log(yaml);
return;
}
(0, fs_1.writeFileSync)(target, yaml);
console.log(`✅ Created ${target}`);
if (options.install === false)
return;
try {
(0, child_process_1.execFileSync)('pre-commit', ['--version'], { cwd: directory, stdio: 'ignore' });
}
catch {
console.log('⚠️ pre-commit not installed. Install with: pip install pre-commit');
console.log('Then run: pre-commit install');
return;
}
(0, child_process_1.execFileSync)('pre-commit', ['install'], { cwd: directory, stdio: 'inherit' });
console.log('✅ Ubon pre-commit hooks installed successfully');
}
//# sourceMappingURL=hooks.js.map