@maverick006/vibeguard 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +72 -0
- package/package.json +26 -0
- package/src/index.ts +81 -0
- package/tsconfig.json +12 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
require("dotenv/config");
|
|
8
|
+
const commander_1 = require("commander");
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
const ora_1 = __importDefault(require("ora"));
|
|
11
|
+
const ai_engine_1 = require("@maverick006/ai-engine");
|
|
12
|
+
const types_1 = require("@maverick006/types");
|
|
13
|
+
const fs_1 = require("fs");
|
|
14
|
+
const path_1 = require("path");
|
|
15
|
+
const program = new commander_1.Command();
|
|
16
|
+
program
|
|
17
|
+
.name('vibeguard')
|
|
18
|
+
.description('VibeGuard Deterministic DevSecOps CLI')
|
|
19
|
+
.version('1.0.0');
|
|
20
|
+
program
|
|
21
|
+
.command('scan')
|
|
22
|
+
.description('Run a security scan on the current directory')
|
|
23
|
+
.option('-d, --dir <path>', 'Directory to scan', process.cwd())
|
|
24
|
+
.option('--fix', 'Automatically generate AI remediation fixes')
|
|
25
|
+
.action(async (options) => {
|
|
26
|
+
console.log(chalk_1.default.bold.magenta('\n🛡️ VibeGuard Orchestrator Initiated\n'));
|
|
27
|
+
const spinner = (0, ora_1.default)('Scanning repository for vulnerabilities...').start();
|
|
28
|
+
// Simulate orchestration of underlying tools since this is the demo CLI
|
|
29
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
30
|
+
spinner.succeed('Scans completed via deterministic engines');
|
|
31
|
+
// Generate mock findings that would come from the scanners
|
|
32
|
+
const findings = [
|
|
33
|
+
{
|
|
34
|
+
id: 'vg-001',
|
|
35
|
+
title: 'SQL Injection Vulnerability',
|
|
36
|
+
description: 'User input is directly concatenated into a SQL query, allowing for injection attacks.',
|
|
37
|
+
severity: types_1.Severity.HIGH,
|
|
38
|
+
scanner: 'Semgrep',
|
|
39
|
+
file: 'src/api/users.ts',
|
|
40
|
+
line: 42
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
console.log(chalk_1.default.bold(`\nFound ${findings.length} vulnerabilities.`));
|
|
44
|
+
for (const finding of findings) {
|
|
45
|
+
console.log(chalk_1.default.red(`\n[${finding.severity}] ${finding.title}`));
|
|
46
|
+
console.log(chalk_1.default.gray(`File: ${finding.file}:${finding.line}`));
|
|
47
|
+
console.log(`${finding.description}`);
|
|
48
|
+
if (options.fix) {
|
|
49
|
+
console.log(chalk_1.default.blue('\nGenerating AI Remediation...'));
|
|
50
|
+
try {
|
|
51
|
+
const explainer = new ai_engine_1.ContextualExplainer();
|
|
52
|
+
// Mock file context
|
|
53
|
+
let snippet = 'const query = "SELECT * FROM users WHERE name = " + req.query.name;';
|
|
54
|
+
if ((0, fs_1.existsSync)((0, path_1.join)(options.dir, finding.file))) {
|
|
55
|
+
const content = (0, fs_1.readFileSync)((0, path_1.join)(options.dir, finding.file), 'utf-8');
|
|
56
|
+
snippet = content.split('\n').slice(Math.max(0, finding.line - 5), finding.line + 5).join('\n');
|
|
57
|
+
}
|
|
58
|
+
const explanation = await explainer.explainFinding(finding, { codeContext: snippet });
|
|
59
|
+
console.log(chalk_1.default.green('\n✅ AI Remediation Plan:'));
|
|
60
|
+
console.log(chalk_1.default.white(explanation.summary));
|
|
61
|
+
console.log(chalk_1.default.white(explanation.details));
|
|
62
|
+
console.log(chalk_1.default.green('\nSuggested Fix:'));
|
|
63
|
+
console.log(chalk_1.default.white(explanation.codeFix || explanation.remediation));
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
console.log(chalk_1.default.yellow(`AI Fix generation failed: ${e.message}`));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
console.log(chalk_1.default.magenta('\nScan complete.\n'));
|
|
71
|
+
});
|
|
72
|
+
program.parse(process.argv);
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@maverick006/vibeguard",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "VibeGuard CLI",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"vibeguard": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"dev": "ts-node src/index.ts",
|
|
12
|
+
"start": "node dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@maverick006/ai-engine": "*",
|
|
16
|
+
"@maverick006/types": "*",
|
|
17
|
+
"chalk": "^4.1.2",
|
|
18
|
+
"commander": "^11.1.0",
|
|
19
|
+
"dotenv": "^17.4.2",
|
|
20
|
+
"ora": "^5.4.1"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/node": "^20.0.0",
|
|
24
|
+
"typescript": "^5.0.0"
|
|
25
|
+
}
|
|
26
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import 'dotenv/config';
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import ora from 'ora';
|
|
6
|
+
import { ContextualExplainer } from '@maverick006/ai-engine';
|
|
7
|
+
import { NormalizedFinding, Severity } from '@maverick006/types';
|
|
8
|
+
import { readFileSync, existsSync } from 'fs';
|
|
9
|
+
import { join } from 'path';
|
|
10
|
+
|
|
11
|
+
const program = new Command();
|
|
12
|
+
|
|
13
|
+
program
|
|
14
|
+
.name('vibeguard')
|
|
15
|
+
.description('VibeGuard Deterministic DevSecOps CLI')
|
|
16
|
+
.version('1.0.0');
|
|
17
|
+
|
|
18
|
+
program
|
|
19
|
+
.command('scan')
|
|
20
|
+
.description('Run a security scan on the current directory')
|
|
21
|
+
.option('-d, --dir <path>', 'Directory to scan', process.cwd())
|
|
22
|
+
.option('--fix', 'Automatically generate AI remediation fixes')
|
|
23
|
+
.action(async (options) => {
|
|
24
|
+
console.log(chalk.bold.magenta('\n🛡️ VibeGuard Orchestrator Initiated\n'));
|
|
25
|
+
|
|
26
|
+
const spinner = ora('Scanning repository for vulnerabilities...').start();
|
|
27
|
+
|
|
28
|
+
// Simulate orchestration of underlying tools since this is the demo CLI
|
|
29
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
30
|
+
|
|
31
|
+
spinner.succeed('Scans completed via deterministic engines');
|
|
32
|
+
|
|
33
|
+
// Generate mock findings that would come from the scanners
|
|
34
|
+
const findings: NormalizedFinding[] = [
|
|
35
|
+
{
|
|
36
|
+
id: 'vg-001',
|
|
37
|
+
title: 'SQL Injection Vulnerability',
|
|
38
|
+
description: 'User input is directly concatenated into a SQL query, allowing for injection attacks.',
|
|
39
|
+
severity: Severity.HIGH,
|
|
40
|
+
scanner: 'Semgrep',
|
|
41
|
+
file: 'src/api/users.ts',
|
|
42
|
+
line: 42
|
|
43
|
+
}
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
console.log(chalk.bold(`\nFound ${findings.length} vulnerabilities.`));
|
|
47
|
+
|
|
48
|
+
for (const finding of findings) {
|
|
49
|
+
console.log(chalk.red(`\n[${finding.severity}] ${finding.title}`));
|
|
50
|
+
console.log(chalk.gray(`File: ${finding.file}:${finding.line}`));
|
|
51
|
+
console.log(`${finding.description}`);
|
|
52
|
+
|
|
53
|
+
if (options.fix) {
|
|
54
|
+
console.log(chalk.blue('\nGenerating AI Remediation...'));
|
|
55
|
+
try {
|
|
56
|
+
const explainer = new ContextualExplainer();
|
|
57
|
+
// Mock file context
|
|
58
|
+
let snippet = 'const query = "SELECT * FROM users WHERE name = " + req.query.name;';
|
|
59
|
+
if (existsSync(join(options.dir, finding.file as string))) {
|
|
60
|
+
const content = readFileSync(join(options.dir, finding.file as string), 'utf-8');
|
|
61
|
+
snippet = content.split('\n').slice(Math.max(0, (finding.line as number) - 5), (finding.line as number) + 5).join('\n');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const explanation = await explainer.explainFinding(finding, { codeContext: snippet });
|
|
65
|
+
|
|
66
|
+
console.log(chalk.green('\n✅ AI Remediation Plan:'));
|
|
67
|
+
console.log(chalk.white(explanation.summary));
|
|
68
|
+
console.log(chalk.white(explanation.details));
|
|
69
|
+
|
|
70
|
+
console.log(chalk.green('\nSuggested Fix:'));
|
|
71
|
+
console.log(chalk.white(explanation.codeFix || explanation.remediation));
|
|
72
|
+
} catch (e: any) {
|
|
73
|
+
console.log(chalk.yellow(`AI Fix generation failed: ${e.message}`));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
console.log(chalk.magenta('\nScan complete.\n'));
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
program.parse(process.argv);
|