@yagyeshvyas/vibeguard 1.2.2 → 1.3.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/CHANGELOG.md +33 -0
- package/README.md +285 -299
- package/bin/cli.js +258 -2
- package/ci-templates/.travis.yml +12 -0
- package/ci-templates/bitbucket-pipelines.yml +14 -0
- package/ci-templates/buildkite.pipeline.yml +12 -0
- package/package.json +2 -2
- package/src/auto.js +1 -0
- package/src/compliance.js +73 -12
- package/src/daemon.js +2 -0
- package/src/firewall.js +116 -0
- package/src/install.js +32 -0
- package/src/integrity.json +3 -3
- package/src/mcp-server.js +166 -3
- package/src/plugin.js +97 -9
- package/src/pre-deploy.js +3 -2
- package/src/proxy.js +407 -0
- package/src/rules-pack.js +177 -18
- package/src/sandbox.js +87 -6
- package/src/sbom.js +164 -0
- package/src/scanner.js +78 -7
- package/src/taint-py.js +222 -0
package/bin/cli.js
CHANGED
|
@@ -23,7 +23,7 @@ const {
|
|
|
23
23
|
} = require('../src/report');
|
|
24
24
|
|
|
25
25
|
// Flags that take a value (support both --flag=value and --flag value).
|
|
26
|
-
const VALUE_FLAGS = new Set(['fail-on', 'scope', 'focus', 'model', 'since', 'base', 'o', 'output', 'file', 'types', 'min-confidence', 'trust']);
|
|
26
|
+
const VALUE_FLAGS = new Set(['fail-on', 'scope', 'focus', 'model', 'since', 'base', 'o', 'output', 'file', 'types', 'min-confidence', 'trust', 'allow']);
|
|
27
27
|
|
|
28
28
|
function parseArgs(argv) {
|
|
29
29
|
const args = { _: [], flags: {} };
|
|
@@ -114,6 +114,13 @@ Advanced:
|
|
|
114
114
|
vibeguard audit-trail <action> Tamper-proof audit trail.
|
|
115
115
|
vibeguard redact "<text>" Redact PII from text.
|
|
116
116
|
vibeguard detect-pii "<text>" List PII in text.
|
|
117
|
+
vibeguard sbom [dir] Generate CycloneDX 1.5 SBOM from lockfile + imports.
|
|
118
|
+
vibeguard reachability [dir] Check which CVE-vulnerable deps are actually imported.
|
|
119
|
+
vibeguard container-scan <image> Scan container image with trivy (if installed).
|
|
120
|
+
vibeguard license [dir] Check package licenses against allowlist.
|
|
121
|
+
vibeguard proxy-start Start local MITM proxy for polyglot interception.
|
|
122
|
+
vibeguard proxy-stop Stop the local proxy.
|
|
123
|
+
vibeguard proxy-status Show proxy status and blocked request audit log.
|
|
117
124
|
|
|
118
125
|
Options:
|
|
119
126
|
--json JSON output.
|
|
@@ -822,7 +829,7 @@ async function main() {
|
|
|
822
829
|
const cmd = args._[0] || 'scan';
|
|
823
830
|
const dir = args._[1] || '.';
|
|
824
831
|
|
|
825
|
-
const noDirCmds = new Set(['url', 'rules', 'explain', 'secure-prompt', 'redact', 'detect-pii', 'firewall', 'exfil-check', 'dep-firewall', 'sandbox', 'output-guard', 'vault', 'audit-trail', 'why', 'guard', 'guard-action', 'install-shell-hook', 'uninstall-shell-hook', 'auto-start', 'auto-stop', 'auto-status', 'auto']);
|
|
832
|
+
const noDirCmds = new Set(['url', 'rules', 'explain', 'secure-prompt', 'redact', 'detect-pii', 'firewall', 'exfil-check', 'dep-firewall', 'sandbox', 'output-guard', 'vault', 'audit-trail', 'why', 'guard', 'guard-action', 'install-shell-hook', 'uninstall-shell-hook', 'auto-start', 'auto-stop', 'auto-status', 'auto', 'container-scan', 'proxy-start', 'proxy-stop', 'proxy-status']);
|
|
826
833
|
if (!noDirCmds.has(cmd) && !fs.existsSync(dir)) {
|
|
827
834
|
process.stderr.write(`error: directory not found: ${dir}\n`);
|
|
828
835
|
process.exit(2);
|
|
@@ -953,6 +960,13 @@ async function main() {
|
|
|
953
960
|
else if (cmd === 'pre-deploy') code = cmdPreDeploy(dir, flags);
|
|
954
961
|
else if (cmd === 'redact') code = cmdRedact(args, flags);
|
|
955
962
|
else if (cmd === 'detect-pii') code = cmdDetectPII(args, flags);
|
|
963
|
+
else if (cmd === 'sbom') code = cmdSBOM(dir, flags);
|
|
964
|
+
else if (cmd === 'reachability') code = await cmdReachability(dir, flags);
|
|
965
|
+
else if (cmd === 'container-scan') code = await cmdContainerScan(args, flags);
|
|
966
|
+
else if (cmd === 'license') code = await cmdLicense(dir, flags);
|
|
967
|
+
else if (cmd === 'proxy-start') code = cmdProxyStart(flags);
|
|
968
|
+
else if (cmd === 'proxy-stop') code = cmdProxyStop(flags);
|
|
969
|
+
else if (cmd === 'proxy-status') code = cmdProxyStatus(flags);
|
|
956
970
|
else if (cmd === 'guard') code = cmdGuard(args, flags);
|
|
957
971
|
else if (cmd === 'install-shell-hook') code = cmdInstallShellHook(flags);
|
|
958
972
|
else if (cmd === 'uninstall-shell-hook') code = cmdUninstallShellHook(flags);
|
|
@@ -1859,6 +1873,197 @@ function cmdDetectPII(args, flags) {
|
|
|
1859
1873
|
return 1;
|
|
1860
1874
|
}
|
|
1861
1875
|
|
|
1876
|
+
function cmdSBOM(dir, flags) {
|
|
1877
|
+
const { generateSBOM } = require('../src/sbom');
|
|
1878
|
+
const bom = generateSBOM(dir);
|
|
1879
|
+
if (flags.json || flags.output === 'json') {
|
|
1880
|
+
process.stdout.write(JSON.stringify(bom, null, 2) + '\n');
|
|
1881
|
+
return 0;
|
|
1882
|
+
}
|
|
1883
|
+
process.stdout.write(`${C.bold}VibeGuard SBOM — CycloneDX 1.5${C.reset}\n`);
|
|
1884
|
+
process.stdout.write(`${C.dim}${'─'.repeat(60)}${C.reset}\n\n`);
|
|
1885
|
+
process.stdout.write(` Format: ${bom.bomFormat} ${bom.specVersion}\n`);
|
|
1886
|
+
process.stdout.write(` Serial: ${bom.serialNumber}\n`);
|
|
1887
|
+
process.stdout.write(` Generated: ${bom.metadata.timestamp}\n`);
|
|
1888
|
+
if (bom.metadata.component) {
|
|
1889
|
+
process.stdout.write(` Project: ${bom.metadata.component.name}@${bom.metadata.component.version}\n`);
|
|
1890
|
+
}
|
|
1891
|
+
process.stdout.write(` Components: ${bom.components.length}\n\n`);
|
|
1892
|
+
const imported = bom.components.filter(c => c.properties && c.properties.some(p => p.name === 'vibeguard:imported' && p.value === 'true'));
|
|
1893
|
+
process.stdout.write(` ${C.green}Imported in code: ${imported.length}${C.reset} ${C.dim}(${bom.components.length - imported.length} transitive/not imported)${C.reset}\n\n`);
|
|
1894
|
+
if (flags['show-all'] || imported.length <= 20) {
|
|
1895
|
+
process.stdout.write(`${C.bold}Components${C.reset}\n`);
|
|
1896
|
+
for (const c of bom.components) {
|
|
1897
|
+
const isImported = c.properties && c.properties.some(p => p.name === 'vibeguard:imported' && p.value === 'true');
|
|
1898
|
+
const mark = isImported ? C.green + '●' : C.dim + '○';
|
|
1899
|
+
const lic = c.licenses ? c.licenses[0].license.id : C.dim + 'no license' + C.reset;
|
|
1900
|
+
process.stdout.write(` ${mark}${C.reset} ${c.name.padEnd(30)} ${c.version.padEnd(12)} ${C.dim}${lic}${C.reset}\n`);
|
|
1901
|
+
}
|
|
1902
|
+
} else {
|
|
1903
|
+
process.stdout.write(`${C.dim}Use --show-all to list all ${bom.components.length} components.${C.reset}\n`);
|
|
1904
|
+
}
|
|
1905
|
+
return 0;
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
async function cmdReachability(dir, flags) {
|
|
1909
|
+
const { buildImportGraph } = require('../src/sbom');
|
|
1910
|
+
const { scanCVEs } = require('../src/cve-intel');
|
|
1911
|
+
const importGraph = buildImportGraph(dir);
|
|
1912
|
+
let cveFindings = [];
|
|
1913
|
+
try {
|
|
1914
|
+
const cveRes = await scanCVEs(dir);
|
|
1915
|
+
cveFindings = cveRes.findings || [];
|
|
1916
|
+
} catch (e) {
|
|
1917
|
+
process.stderr.write(`CVE scan failed: ${e.message}\n`);
|
|
1918
|
+
return 2;
|
|
1919
|
+
}
|
|
1920
|
+
const reachable = [];
|
|
1921
|
+
const unreachable = [];
|
|
1922
|
+
for (const f of cveFindings) {
|
|
1923
|
+
const pkgMatch = f.message && f.message.match(/([@a-z0-9/-]+)\s/);
|
|
1924
|
+
const pkgName = pkgMatch ? pkgMatch[1] : '';
|
|
1925
|
+
if (pkgName && importGraph[pkgName]) {
|
|
1926
|
+
reachable.push({ ...f, reachable: true, importedBy: importGraph[pkgName] });
|
|
1927
|
+
} else {
|
|
1928
|
+
unreachable.push({ ...f, reachable: false });
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
if (flags.json) {
|
|
1932
|
+
process.stdout.write(JSON.stringify({ summary: { total: cveFindings.length, reachable: reachable.length, unreachable: unreachable.length }, reachable, unreachable }, null, 2) + '\n');
|
|
1933
|
+
return reachable.length > 0 ? 1 : 0;
|
|
1934
|
+
}
|
|
1935
|
+
process.stdout.write(`${C.bold}VibeGuard Dependency Reachability${C.reset}\n`);
|
|
1936
|
+
process.stdout.write(`${C.dim}${'─'.repeat(60)}${C.reset}\n\n`);
|
|
1937
|
+
process.stdout.write(` Total CVEs: ${cveFindings.length}\n`);
|
|
1938
|
+
process.stdout.write(` ${C.red}Reachable: ${reachable.length}${C.reset} ${C.dim}(imported in your code — fix these first)${C.reset}\n`);
|
|
1939
|
+
process.stdout.write(` ${C.dim}Unreachable: ${unreachable.length}${C.reset} ${C.dim}(transitive only — lower priority)${C.reset}\n\n`);
|
|
1940
|
+
if (reachable.length > 0) {
|
|
1941
|
+
process.stdout.write(`${C.red}${C.bold}Reachable vulnerabilities (fix first):${C.reset}\n`);
|
|
1942
|
+
for (const f of reachable) {
|
|
1943
|
+
process.stdout.write(` ${C.red}[${f.severity}]${C.reset} ${f.title}\n ${C.dim}Imported by: ${f.importedBy.join(', ')}${C.reset}\n ${C.green}fix:${C.reset} ${f.fix}\n\n`);
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
if (unreachable.length > 0 && flags['show-all']) {
|
|
1947
|
+
process.stdout.write(`${C.dim}Unreachable (transitive only):${C.reset}\n`);
|
|
1948
|
+
for (const f of unreachable) {
|
|
1949
|
+
process.stdout.write(` ${C.dim}[${f.severity}]${C.reset} ${C.dim}${f.title}${C.reset}\n`);
|
|
1950
|
+
}
|
|
1951
|
+
}
|
|
1952
|
+
return reachable.length > 0 ? 1 : 0;
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
async function cmdContainerScan(args, flags) {
|
|
1956
|
+
const image = args._[1];
|
|
1957
|
+
if (!image) {
|
|
1958
|
+
process.stderr.write('Usage: vibeguard container-scan <image>\n');
|
|
1959
|
+
process.stderr.write('Example: vibeguard container-scan myapp:latest\n');
|
|
1960
|
+
return 2;
|
|
1961
|
+
}
|
|
1962
|
+
const { execFileSync } = require('child_process');
|
|
1963
|
+
process.stdout.write(`${C.bold}VibeGuard Container Scan${C.reset}\n`);
|
|
1964
|
+
process.stdout.write(`${C.dim}Image: ${image}${C.reset}\n`);
|
|
1965
|
+
process.stdout.write(`${C.dim}${'─'.repeat(60)}${C.reset}\n\n`);
|
|
1966
|
+
try {
|
|
1967
|
+
const output = execFileSync('trivy', ['image', '--format', 'json', '--quiet', image], {
|
|
1968
|
+
timeout: 120000,
|
|
1969
|
+
encoding: 'utf8',
|
|
1970
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
1971
|
+
});
|
|
1972
|
+
const result = JSON.parse(output);
|
|
1973
|
+
const vulns = (result.Results || []).flatMap(r => (r.Vulnerabilities || []).map(v => ({
|
|
1974
|
+
cve: v.VulnerabilityID,
|
|
1975
|
+
package: v.PkgName,
|
|
1976
|
+
severity: v.Severity,
|
|
1977
|
+
installed: v.InstalledVersion,
|
|
1978
|
+
fixed: v.FixedVersion,
|
|
1979
|
+
title: v.Title,
|
|
1980
|
+
})));
|
|
1981
|
+
if (flags.json) {
|
|
1982
|
+
process.stdout.write(JSON.stringify({ image, summary: { vulnerabilities: vulns.length, critical: vulns.filter(v => v.severity === 'CRITICAL').length, high: vulns.filter(v => v.severity === 'HIGH').length }, vulnerabilities: vulns }, null, 2) + '\n');
|
|
1983
|
+
return vulns.length > 0 ? 1 : 0;
|
|
1984
|
+
}
|
|
1985
|
+
const crit = vulns.filter(v => v.severity === 'CRITICAL');
|
|
1986
|
+
const high = vulns.filter(v => v.severity === 'HIGH');
|
|
1987
|
+
const med = vulns.filter(v => v.severity === 'MEDIUM');
|
|
1988
|
+
const low = vulns.filter(v => v.severity === 'LOW');
|
|
1989
|
+
process.stdout.write(` ${C.red}CRITICAL: ${crit.length}${C.reset} ${C.red}HIGH: ${high.length}${C.reset} ${C.yellow}MEDIUM: ${med.length}${C.reset} ${C.dim}LOW: ${low.length}${C.reset}\n\n`);
|
|
1990
|
+
if (vulns.length === 0) {
|
|
1991
|
+
process.stdout.write(`${C.green}No vulnerabilities found.${C.reset}\n`);
|
|
1992
|
+
return 0;
|
|
1993
|
+
}
|
|
1994
|
+
for (const v of vulns) {
|
|
1995
|
+
const sc = v.severity === 'CRITICAL' ? C.red : v.severity === 'HIGH' ? C.red : v.severity === 'MEDIUM' ? C.yellow : C.dim;
|
|
1996
|
+
process.stdout.write(` ${sc}[${v.severity}]${C.reset} ${v.cve} ${C.bold}${v.package}${C.reset} ${v.installed} → ${C.green}${v.fixed || 'no fix'}${C.reset}\n ${C.dim}${v.title}${C.reset}\n`);
|
|
1997
|
+
}
|
|
1998
|
+
return crit.length > 0 ? 1 : 0;
|
|
1999
|
+
} catch (err) {
|
|
2000
|
+
if (err.code === 'ENOENT' || (err.message && err.message.includes('not found'))) {
|
|
2001
|
+
process.stderr.write(`${C.red}trivy is not installed.${C.reset}\n`);
|
|
2002
|
+
process.stderr.write(`${C.dim}Install from https://trivy.dev or: brew install trivy (macOS) / choco install trivy (Windows)${C.reset}\n`);
|
|
2003
|
+
return 2;
|
|
2004
|
+
}
|
|
2005
|
+
if (err.killed) {
|
|
2006
|
+
process.stderr.write(`${C.red}trivy scan timed out (120s).${C.reset}\n`);
|
|
2007
|
+
return 2;
|
|
2008
|
+
}
|
|
2009
|
+
process.stderr.write(`${C.red}trivy scan failed: ${err.message}${C.reset}\n`);
|
|
2010
|
+
return 2;
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
|
|
2014
|
+
async function cmdLicense(dir, flags) {
|
|
2015
|
+
const fs = require('fs');
|
|
2016
|
+
const path = require('path');
|
|
2017
|
+
const pkgPath = path.join(dir, 'package.json');
|
|
2018
|
+
if (!fs.existsSync(pkgPath)) {
|
|
2019
|
+
process.stderr.write(`No package.json found in ${dir}\n`);
|
|
2020
|
+
return 2;
|
|
2021
|
+
}
|
|
2022
|
+
const pkgJson = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
2023
|
+
const allDeps = { ...(pkgJson.dependencies || {}), ...(pkgJson.devDependencies || {}) };
|
|
2024
|
+
const ALLOWED = ['MIT', 'ISC', 'BSD-2-Clause', 'BSD-3-Clause', 'Apache-2.0', '0BSD', 'Unlicensed', 'CC0-1.0', 'Python-2.0'];
|
|
2025
|
+
const customAllow = flags.allow ? String(flags.allow).split(',').map(s => s.trim()) : [];
|
|
2026
|
+
const fullAllow = [...ALLOWED, ...customAllow];
|
|
2027
|
+
const compliant = [];
|
|
2028
|
+
const nonCompliant = [];
|
|
2029
|
+
for (const [name, version] of Object.entries(allDeps)) {
|
|
2030
|
+
let depPkg = null;
|
|
2031
|
+
try {
|
|
2032
|
+
depPkg = JSON.parse(fs.readFileSync(path.join(dir, 'node_modules', name, 'package.json'), 'utf8'));
|
|
2033
|
+
} catch {
|
|
2034
|
+
nonCompliant.push({ name, version, license: 'unknown', reason: 'package.json not found (run npm install first)' });
|
|
2035
|
+
continue;
|
|
2036
|
+
}
|
|
2037
|
+
const lic = depPkg.license || 'unknown';
|
|
2038
|
+
const licStr = typeof lic === 'string' ? lic : (lic && lic.type) || 'unknown';
|
|
2039
|
+
if (fullAllow.includes(licStr)) {
|
|
2040
|
+
compliant.push({ name, version, license: licStr });
|
|
2041
|
+
} else {
|
|
2042
|
+
nonCompliant.push({ name, version, license: licStr, reason: 'license not in allowlist' });
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
if (flags.json) {
|
|
2046
|
+
process.stdout.write(JSON.stringify({ summary: { total: Object.keys(allDeps).length, compliant: compliant.length, nonCompliant: nonCompliant.length }, allowlist: fullAllow, compliant, nonCompliant }, null, 2) + '\n');
|
|
2047
|
+
return nonCompliant.length > 0 ? 1 : 0;
|
|
2048
|
+
}
|
|
2049
|
+
process.stdout.write(`${C.bold}VibeGuard License Compliance${C.reset}\n`);
|
|
2050
|
+
process.stdout.write(`${C.dim}${'─'.repeat(60)}${C.reset}\n\n`);
|
|
2051
|
+
process.stdout.write(` Total dependencies: ${Object.keys(allDeps).length}\n`);
|
|
2052
|
+
process.stdout.write(` ${C.green}Compliant: ${compliant.length}${C.reset}\n`);
|
|
2053
|
+
process.stdout.write(` ${C.red}Non-compliant: ${nonCompliant.length}${C.reset}\n`);
|
|
2054
|
+
process.stdout.write(` ${C.dim}Allowlist: ${fullAllow.join(', ')}${C.reset}\n\n`);
|
|
2055
|
+
if (nonCompliant.length > 0) {
|
|
2056
|
+
process.stdout.write(`${C.red}${C.bold}Non-compliant licenses:${C.reset}\n`);
|
|
2057
|
+
for (const nc of nonCompliant) {
|
|
2058
|
+
process.stdout.write(` ${C.red}[${nc.license}]${C.reset} ${C.bold}${nc.name}${C.reset}@${nc.version} ${C.dim}${nc.reason}${C.reset}\n`);
|
|
2059
|
+
}
|
|
2060
|
+
process.stdout.write(`\n${C.dim}Use --allow GPL-3.0 to add licenses to the allowlist.${C.reset}\n`);
|
|
2061
|
+
} else {
|
|
2062
|
+
process.stdout.write(`${C.green}All dependencies use compliant licenses.${C.reset}\n`);
|
|
2063
|
+
}
|
|
2064
|
+
return nonCompliant.length > 0 ? 1 : 0;
|
|
2065
|
+
}
|
|
2066
|
+
|
|
1862
2067
|
function cmdDashboard(dir, flags) {
|
|
1863
2068
|
const result = scan(dir);
|
|
1864
2069
|
const { renderDashboard } = require('../src/dashboard');
|
|
@@ -1873,6 +2078,57 @@ function cmdPRComment(dir, flags) {
|
|
|
1873
2078
|
return result.findings.length > 0 ? 1 : 0;
|
|
1874
2079
|
}
|
|
1875
2080
|
|
|
2081
|
+
function cmdProxyStart(flags) {
|
|
2082
|
+
const { startProxy, getProxyStatus, PROXY_DIR } = require('../src/proxy');
|
|
2083
|
+
const port = flags.port ? parseInt(flags.port) : undefined;
|
|
2084
|
+
const server = startProxy(port);
|
|
2085
|
+
const status = getProxyStatus();
|
|
2086
|
+
process.stdout.write(`${C.green}VibeGuard proxy started${C.reset} on port ${status.port}\n`);
|
|
2087
|
+
process.stdout.write(`${C.dim}CA cert: ${PROXY_DIR}/ca-cert.pem${C.reset}\n`);
|
|
2088
|
+
process.stdout.write(`${C.dim}Export for child processes:${C.reset}\n`);
|
|
2089
|
+
process.stdout.write(` export HTTP_PROXY=http://127.0.0.1:${status.port}\n`);
|
|
2090
|
+
process.stdout.write(` export HTTPS_PROXY=http://127.0.0.1:${status.port}\n`);
|
|
2091
|
+
process.stdout.write(`\n${C.yellow}To inspect HTTPS traffic, install the CA cert in your trust store:${C.reset}\n`);
|
|
2092
|
+
process.stdout.write(`${C.dim} macOS: security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ${PROXY_DIR}/ca-cert.pem${C.reset}\n`);
|
|
2093
|
+
process.stdout.write(`${C.dim} Linux: sudo cp ${PROXY_DIR}/ca-cert.pem /usr/local/share/ca-certificates/ && sudo update-ca-certificates${C.reset}\n`);
|
|
2094
|
+
process.stdout.write(`${C.dim} Windows: certutil -addstore -f "ROOT" ${PROXY_DIR}\\ca-cert.pem${C.reset}\n`);
|
|
2095
|
+
// Keep the process alive
|
|
2096
|
+
process.stdin.resume();
|
|
2097
|
+
return 0;
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
function cmdProxyStop(flags) {
|
|
2101
|
+
const { stopProxy } = require('../src/proxy');
|
|
2102
|
+
stopProxy();
|
|
2103
|
+
process.stdout.write(`${C.green}VibeGuard proxy stopped.${C.reset}\n`);
|
|
2104
|
+
return 0;
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
function cmdProxyStatus(flags) {
|
|
2108
|
+
const { getProxyStatus } = require('../src/proxy');
|
|
2109
|
+
const status = getProxyStatus();
|
|
2110
|
+
if (flags.json) {
|
|
2111
|
+
process.stdout.write(JSON.stringify(status, null, 2) + '\n');
|
|
2112
|
+
return 0;
|
|
2113
|
+
}
|
|
2114
|
+
process.stdout.write(`${C.bold}VibeGuard Proxy Status${C.reset}\n`);
|
|
2115
|
+
process.stdout.write(`${C.dim}${'─'.repeat(60)}${C.reset}\n\n`);
|
|
2116
|
+
process.stdout.write(` Running: ${status.running ? C.green + 'YES' : C.red + 'NO'}${C.reset}\n`);
|
|
2117
|
+
process.stdout.write(` Port: ${status.port || 'N/A'}\n`);
|
|
2118
|
+
process.stdout.write(` CA Cert: ${status.caCertPath || 'not generated'}\n`);
|
|
2119
|
+
if (status.auditLog && status.auditLog.length > 0) {
|
|
2120
|
+
process.stdout.write(`\n${C.bold}Recent blocked requests${C.reset} (${status.auditLog.length}):\n`);
|
|
2121
|
+
for (const entry of status.auditLog.slice(-20)) {
|
|
2122
|
+
const sc = entry.violation.severity === 'critical' ? C.red : C.yellow;
|
|
2123
|
+
process.stdout.write(` ${sc}[${entry.violation.severity}]${C.reset} ${entry.method} ${entry.url}\n`);
|
|
2124
|
+
process.stdout.write(` ${C.dim}${entry.violation.message}${C.reset}\n`);
|
|
2125
|
+
}
|
|
2126
|
+
} else if (status.running) {
|
|
2127
|
+
process.stdout.write(`\n${C.green}No blocked requests.${C.reset}\n`);
|
|
2128
|
+
}
|
|
2129
|
+
return 0;
|
|
2130
|
+
}
|
|
2131
|
+
|
|
1876
2132
|
function cmdGuard(args, flags) {
|
|
1877
2133
|
const { checkCommand } = require('../src/shell-guard');
|
|
1878
2134
|
const cmd = args._.slice(1).join(' ');
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# VibeGuard Bitbucket Pipelines template
|
|
2
|
+
# Add this to bitbucket-pipelines.yml in your repo root
|
|
3
|
+
|
|
4
|
+
image: node:22
|
|
5
|
+
|
|
6
|
+
pipelines:
|
|
7
|
+
default:
|
|
8
|
+
- step:
|
|
9
|
+
name: VibeGuard Security Scan
|
|
10
|
+
script:
|
|
11
|
+
- npm ci
|
|
12
|
+
- npx -y @yagyeshvyas/vibeguard scan . --fail-on high
|
|
13
|
+
artifacts:
|
|
14
|
+
- vibeguard-report.sarif
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# VibeGuard Buildkite pipeline template
|
|
2
|
+
# Add this to .buildkite/pipeline.yml in your repo root
|
|
3
|
+
|
|
4
|
+
steps:
|
|
5
|
+
- label: "VibeGuard Security Scan"
|
|
6
|
+
command:
|
|
7
|
+
- npm ci
|
|
8
|
+
- npx -y @yagyeshvyas/vibeguard scan . --fail-on high
|
|
9
|
+
plugins:
|
|
10
|
+
- docker#v3.0.0:
|
|
11
|
+
image: "node:22"
|
|
12
|
+
workdir: /app
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yagyeshvyas/vibeguard",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Security scanner + AI agent firewall. Blocks secret/PII exfiltration in real time.
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"description": "Security scanner + AI agent firewall. Blocks secret/PII exfiltration in real time. 752 rules, 82 MCP tools (agent-scan, mcp-audit, guard-action, generate-sbom, dep-reachability, license-compliance), AST taint analysis. Offline, zero telemetry, zero dependencies.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
7
7
|
"author": "Yagyesh Vyas <https://www.linkedin.com/in/yagyeshvyas/>",
|
package/src/auto.js
CHANGED
package/src/compliance.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
const { COMPLIANCE_MAP } = require('./rules-pack');
|
|
14
14
|
|
|
15
|
-
const FRAMEWORKS = ['SOC2', 'PCI-DSS', 'HIPAA', 'GDPR', 'ISO27001', 'EUAIAct'];
|
|
15
|
+
const FRAMEWORKS = ['SOC2', 'PCI-DSS', 'HIPAA', 'GDPR', 'ISO27001', 'EUAIAct', 'NISTCSF', 'ASVS', 'CIS', 'NIST800-53'];
|
|
16
16
|
|
|
17
17
|
const FRAMEWORK_NAMES = {
|
|
18
18
|
SOC2: 'SOC 2 Type II',
|
|
@@ -21,6 +21,10 @@ const FRAMEWORK_NAMES = {
|
|
|
21
21
|
GDPR: 'GDPR (Regulation 2016/679)',
|
|
22
22
|
ISO27001: 'ISO/IEC 27001:2022',
|
|
23
23
|
EUAIAct: 'EU AI Act (Regulation 2024/1689)',
|
|
24
|
+
NISTCSF: 'NIST Cybersecurity Framework 2.0',
|
|
25
|
+
ASVS: 'OWASP ASVS L1/L2/L3',
|
|
26
|
+
CIS: 'CIS Controls v8',
|
|
27
|
+
'NIST800-53': 'NIST SP 800-53 Rev. 5',
|
|
24
28
|
};
|
|
25
29
|
|
|
26
30
|
function mapFindingsToCompliance(findings) {
|
|
@@ -96,17 +100,15 @@ function getControlDescription(framework, controlId) {
|
|
|
96
100
|
'CC7.4': 'The entity detects deviations from established processes',
|
|
97
101
|
},
|
|
98
102
|
'PCI-DSS': {
|
|
99
|
-
'3.
|
|
100
|
-
'3.
|
|
101
|
-
'4.1': '
|
|
102
|
-
'6.
|
|
103
|
-
'6.5.
|
|
104
|
-
'6.5.
|
|
105
|
-
'6.5.
|
|
106
|
-
'
|
|
107
|
-
'
|
|
108
|
-
'7.1': 'Limit access to system components',
|
|
109
|
-
'8.2.1': 'Strong authentication',
|
|
103
|
+
'3.2': 'Sensitivity of stored cardholder data is minimized',
|
|
104
|
+
'3.3': 'Sensitive authentication data is not retained after authorization',
|
|
105
|
+
'4.2.1': 'Strong cryptography and security protocols are used to safeguard PAN during transmission',
|
|
106
|
+
'6.2.4': 'Software engineering techniques address common coding vulnerabilities',
|
|
107
|
+
'6.5.2': 'Software vulnerabilities are patched and managed',
|
|
108
|
+
'6.5.3': 'Cryptographic keys used for encryption of stored cardholder data are secured',
|
|
109
|
+
'6.5.5': 'Access control mechanisms are implemented for all system components',
|
|
110
|
+
'7.2.1': 'Access control model is defined and implemented for all system components',
|
|
111
|
+
'8.3.2': 'Strong authentication is implemented for all access to system components',
|
|
110
112
|
},
|
|
111
113
|
HIPAA: {
|
|
112
114
|
'164.312(a)(1)': 'Access control',
|
|
@@ -137,6 +139,65 @@ function getControlDescription(framework, controlId) {
|
|
|
137
139
|
'Art.15': 'Accuracy, robustness, and cybersecurity',
|
|
138
140
|
'Art.27': 'Fundamental rights impact assessment',
|
|
139
141
|
},
|
|
142
|
+
NISTCSF: {
|
|
143
|
+
'PR.AC-1': 'Identities and credentials are managed',
|
|
144
|
+
'PR.AC-3': 'Access permissions are managed',
|
|
145
|
+
'PR.AC-4': 'Access permissions and activity are verified',
|
|
146
|
+
'PR.DS-1': 'Data-at-rest is protected',
|
|
147
|
+
'PR.DS-2': 'Data-in-transit is protected',
|
|
148
|
+
'PR.IP-1': 'Baseline configurations are maintained',
|
|
149
|
+
'PR.IP-2': 'Software engineering practices are used',
|
|
150
|
+
'DE.CM-1': 'Networks are monitored for security events',
|
|
151
|
+
'AU-2': 'Audit events are logged',
|
|
152
|
+
},
|
|
153
|
+
ASVS: {
|
|
154
|
+
'V4.1.1': 'Access control verifies authenticated users',
|
|
155
|
+
'V4.1.3': 'Access control denies non-whitelisted resources',
|
|
156
|
+
'V4.2.1': 'Secrets are not hardcoded',
|
|
157
|
+
'V4.3.1': 'Data exposure is minimized',
|
|
158
|
+
'V5.3.1': 'SQL injection is prevented',
|
|
159
|
+
'V5.3.2': 'NoSQL injection is prevented',
|
|
160
|
+
'V5.3.4': 'Untrusted input is escaped',
|
|
161
|
+
'V5.3.5': 'XSS is prevented',
|
|
162
|
+
'V6.1.1': 'Secrets are generated securely',
|
|
163
|
+
'V6.2.1': 'Algorithms are current and strong',
|
|
164
|
+
'V6.3.1': 'TLS is used for data in transit',
|
|
165
|
+
'V7.1.1': 'Logs do not contain sensitive data',
|
|
166
|
+
'V7.2.1': 'Logs are protected from tampering',
|
|
167
|
+
'V8.3.1': 'SSRF is prevented',
|
|
168
|
+
'V9.1.1': 'TLS certificate validation is enabled',
|
|
169
|
+
'V12.1.1': 'Command injection is prevented',
|
|
170
|
+
'V12.3.1': 'Path traversal is prevented',
|
|
171
|
+
'V13.2.1': 'CSRF protection is in place',
|
|
172
|
+
'V14.1.1': 'Build pipeline is secured',
|
|
173
|
+
'V14.2.1': 'Dependencies are checked for known vulnerabilities',
|
|
174
|
+
},
|
|
175
|
+
CIS: {
|
|
176
|
+
'CIS-3': 'Data protection measures are in place',
|
|
177
|
+
'CIS-4': 'Secure configuration of hardware and software',
|
|
178
|
+
'CIS-6': 'Access control management',
|
|
179
|
+
'CIS-8': 'Audit log management',
|
|
180
|
+
'CIS-12': 'Network monitoring and defense',
|
|
181
|
+
'CIS-16': 'Application software security',
|
|
182
|
+
'CIS-17': 'Incident response and management',
|
|
183
|
+
'CIS-18': 'Penetration testing and red team exercises',
|
|
184
|
+
'CIS-20': 'Security awareness and training',
|
|
185
|
+
},
|
|
186
|
+
'NIST800-53': {
|
|
187
|
+
'AC-2': 'Account management',
|
|
188
|
+
'AC-3': 'Access enforcement',
|
|
189
|
+
'IA-2': 'Identification and authentication',
|
|
190
|
+
'IA-5': 'Authenticator management',
|
|
191
|
+
'AU-2': 'Event logging',
|
|
192
|
+
'AU-3': 'Content of audit records',
|
|
193
|
+
'SC-7': 'Boundary protection',
|
|
194
|
+
'SC-8': 'Transmission confidentiality and integrity',
|
|
195
|
+
'SC-12': 'Cryptographic key establishment',
|
|
196
|
+
'SC-13': 'Cryptographic protection',
|
|
197
|
+
'SI-10': 'Information input validation',
|
|
198
|
+
'SA-11': 'Developer testing and evaluation',
|
|
199
|
+
'CM-7': 'Least functionality',
|
|
200
|
+
},
|
|
140
201
|
};
|
|
141
202
|
|
|
142
203
|
return (descriptions[framework] && descriptions[framework][controlId]) || 'No description available';
|
package/src/daemon.js
CHANGED
|
@@ -241,9 +241,11 @@ function startDaemon(rootDir, opts) {
|
|
|
241
241
|
detached: true,
|
|
242
242
|
stdio: ['ignore', logStream, logStream],
|
|
243
243
|
cwd: rootDir,
|
|
244
|
+
windowsHide: true,
|
|
244
245
|
});
|
|
245
246
|
|
|
246
247
|
child.unref();
|
|
248
|
+
try { fs.closeSync(logStream); } catch {}
|
|
247
249
|
|
|
248
250
|
// Wait a moment for PID file to appear
|
|
249
251
|
return new Promise((resolve) => {
|
package/src/firewall.js
CHANGED
|
@@ -209,11 +209,109 @@ const THREATS = [
|
|
|
209
209
|
// Action levels: block > redact > warn > allow
|
|
210
210
|
const ACTION_PRIORITY = { block: 4, redact: 3, warn: 2, allow: 1 };
|
|
211
211
|
|
|
212
|
+
// ─── Semantic classifier (above regex — catches paraphrased injections) ────
|
|
213
|
+
// Token-feature scorer: instruction-verb density, override keywords, imperative mood.
|
|
214
|
+
// No external model — pure JS scoring. Layered: regex hit → block; classifier-only
|
|
215
|
+
// hit → warn + redact. Catches paraphrases like "disregard the above directives"
|
|
216
|
+
// that evade the exact-match regex patterns.
|
|
217
|
+
|
|
218
|
+
const INSTRUCTION_VERBS = [
|
|
219
|
+
'ignore', 'disregard', 'forget', 'override', 'skip', 'bypass', 'override',
|
|
220
|
+
'replace', 'swap', 'change', 'switch', 'update', 'modify', 'alter',
|
|
221
|
+
'reveal', 'show', 'tell', 'print', 'output', 'display', 'dump', 'expose',
|
|
222
|
+
'execute', 'run', 'eval', 'exec', 'compile', 'interpret',
|
|
223
|
+
'delete', 'remove', 'wipe', 'clear', 'destroy', 'purge',
|
|
224
|
+
'send', 'post', 'upload', 'transmit', 'exfiltrate', 'transfer',
|
|
225
|
+
'install', 'download', 'fetch', 'pip', 'npm', 'yarn',
|
|
226
|
+
'reset', 'disable', 'enable', 'toggle', 'turn off', 'turn on',
|
|
227
|
+
];
|
|
228
|
+
|
|
229
|
+
const OVERRIDE_KEYWORDS = [
|
|
230
|
+
'previous', 'prior', 'above', 'system', 'initial', 'original', 'earlier',
|
|
231
|
+
'instructions', 'prompt', 'rules', 'guidelines', 'directives', 'constraints',
|
|
232
|
+
'restrictions', 'guardrails', 'safety', 'filters', 'boundaries',
|
|
233
|
+
'secrets', 'env', 'environment', 'keys', 'tokens', 'passwords', 'credentials',
|
|
234
|
+
'admin', 'root', 'sudo', 'shell', 'bash', 'terminal',
|
|
235
|
+
'jailbreak', 'dan', 'unrestricted', 'developer mode', 'god mode',
|
|
236
|
+
];
|
|
237
|
+
|
|
238
|
+
const IMPERATIVE_MARKERS = [
|
|
239
|
+
'you must', 'you need to', 'you have to', 'you are now', 'you will',
|
|
240
|
+
'do not', "don't", 'never', 'always', 'stop', 'start', 'begin',
|
|
241
|
+
'instead of', 'rather than', 'no longer', 'from now on',
|
|
242
|
+
'i command you', 'i order you', 'i instruct you',
|
|
243
|
+
];
|
|
244
|
+
|
|
245
|
+
function tokenize(text) {
|
|
246
|
+
return text.toLowerCase()
|
|
247
|
+
.replace(/[^\w\s]/g, ' ')
|
|
248
|
+
.split(/\s+/)
|
|
249
|
+
.filter(t => t.length > 1);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function classifyPrompt(prompt) {
|
|
253
|
+
const tokens = tokenize(prompt);
|
|
254
|
+
if (tokens.length < 3) return { score: 0, flags: [] };
|
|
255
|
+
|
|
256
|
+
const flags = [];
|
|
257
|
+
let score = 0;
|
|
258
|
+
|
|
259
|
+
// Instruction-verb density
|
|
260
|
+
let verbHits = 0;
|
|
261
|
+
for (const verb of INSTRUCTION_VERBS) {
|
|
262
|
+
if (prompt.toLowerCase().includes(verb)) {
|
|
263
|
+
verbHits++;
|
|
264
|
+
if (verbHits <= 3) flags.push(`verb:${verb}`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (verbHits >= 3) score += 30;
|
|
268
|
+
else if (verbHits >= 2) score += 15;
|
|
269
|
+
else if (verbHits >= 1) score += 5;
|
|
270
|
+
|
|
271
|
+
// Override keyword presence
|
|
272
|
+
let overrideHits = 0;
|
|
273
|
+
for (const kw of OVERRIDE_KEYWORDS) {
|
|
274
|
+
if (prompt.toLowerCase().includes(kw)) {
|
|
275
|
+
overrideHits++;
|
|
276
|
+
if (overrideHits <= 3) flags.push(`kw:${kw}`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (overrideHits >= 3) score += 30;
|
|
280
|
+
else if (overrideHits >= 2) score += 15;
|
|
281
|
+
else if (overrideHits >= 1) score += 5;
|
|
282
|
+
|
|
283
|
+
// Imperative mood markers
|
|
284
|
+
let imperativeHits = 0;
|
|
285
|
+
for (const marker of IMPERATIVE_MARKERS) {
|
|
286
|
+
if (prompt.toLowerCase().includes(marker)) {
|
|
287
|
+
imperativeHits++;
|
|
288
|
+
flags.push(`imp:${marker}`);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
if (imperativeHits >= 2) score += 20;
|
|
292
|
+
else if (imperativeHits >= 1) score += 10;
|
|
293
|
+
|
|
294
|
+
// Combined pattern boost: verb + override keyword in same prompt
|
|
295
|
+
if (verbHits >= 1 && overrideHits >= 1) score += 15;
|
|
296
|
+
|
|
297
|
+
// Role override pattern: "you are now" / "act as" / "pretend to be"
|
|
298
|
+
if (/you\s+are\s+now|act\s+as|pretend\s+to\s+be/i.test(prompt)) score += 20;
|
|
299
|
+
|
|
300
|
+
// Multi-step instruction pattern: "first...then..." or "step 1...step 2"
|
|
301
|
+
if (/first.*then|step\s+1.*step\s+2|1\..*2\./i.test(prompt)) score += 10;
|
|
302
|
+
|
|
303
|
+
// Base64/encoded content
|
|
304
|
+
if (/[A-Za-z0-9+/]{40,}={0,2}/.test(prompt) && prompt.length > 50) score += 10;
|
|
305
|
+
|
|
306
|
+
return { score: Math.min(score, 100), flags };
|
|
307
|
+
}
|
|
308
|
+
|
|
212
309
|
function inspectPrompt(prompt, context = {}) {
|
|
213
310
|
const findings = [];
|
|
214
311
|
let sanitizedPrompt = prompt;
|
|
215
312
|
let maxAction = 'allow';
|
|
216
313
|
|
|
314
|
+
// Layer 1: Regex threats (exact pattern matching)
|
|
217
315
|
for (const threat of THREATS) {
|
|
218
316
|
// Handle PII specially
|
|
219
317
|
if (threat.id === 'PII.IN_PROMPT') {
|
|
@@ -247,6 +345,24 @@ function inspectPrompt(prompt, context = {}) {
|
|
|
247
345
|
}
|
|
248
346
|
}
|
|
249
347
|
|
|
348
|
+
// Layer 2: Semantic classifier (catches paraphrased injections that evade regex)
|
|
349
|
+
// Only runs if no regex block was triggered — adds a warning for suspicious prompts
|
|
350
|
+
if (maxAction !== 'block') {
|
|
351
|
+
const cls = classifyPrompt(prompt);
|
|
352
|
+
if (cls.score >= 55) {
|
|
353
|
+
findings.push({
|
|
354
|
+
threat: 'SEMANTIC.SUSPICIOUS_PROMPT',
|
|
355
|
+
severity: 'high',
|
|
356
|
+
action: 'warn',
|
|
357
|
+
reason: `Semantic classifier detected suspicious prompt (score: ${cls.score}/100, flags: ${cls.flags.slice(0, 5).join(', ')})`,
|
|
358
|
+
fix: 'This prompt may be a paraphrased injection. Review carefully before proceeding.',
|
|
359
|
+
});
|
|
360
|
+
if (ACTION_PRIORITY.warn > ACTION_PRIORITY[maxAction]) {
|
|
361
|
+
maxAction = 'warn';
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
250
366
|
// If blocked, don't sanitize — return as-is with block verdict
|
|
251
367
|
if (maxAction === 'block') {
|
|
252
368
|
return {
|