@yagyeshvyas/vibeguard 1.12.0 → 1.13.1
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 +26 -0
- package/README.md +34 -17
- package/bin/cli.js +2753 -2753
- package/bin/cmd-mcp-firewall.js +1 -0
- package/bin/cmd-platform.js +3 -0
- package/ci/vibeguard.yml +42 -42
- package/package.json +2 -2
- package/scripts/counts.js +93 -93
- package/scripts/postinstall.js +26 -26
- package/src/auto.js +427 -427
- package/src/daemon.js +343 -343
- package/src/dashboard.js +278 -278
- package/src/engine.js +297 -297
- package/src/hook.js +151 -151
- package/src/install.js +298 -298
- package/src/integrity.js +1 -0
- package/src/integrity.json +9 -6
- package/src/mcp-firewall.js +11 -0
- package/src/platform/approval-service.js +124 -0
- package/src/platform/approval.js +16 -0
- package/src/platform/oauth-server.js +89 -0
- package/src/platform/os-sandbox.js +52 -1
- package/src/platform/runtime-monitor.js +69 -0
- package/src/platform/sandbox-manager.js +5 -0
- package/src/plugin.js +182 -182
- package/src/privacy-audit.js +272 -272
- package/src/repl.js +150 -150
- package/src/report.js +331 -331
- package/src/rules-pack.js +3068 -3068
- package/src/rules.js +1822 -1822
- package/src/sbom.js +193 -193
- package/src/scanner.js +1032 -1032
- package/src/shell-guard.js +302 -302
- package/src/slopsquat.js +144 -144
- package/src/trace.js +220 -220
- package/src/.vibeguard/cache/file-hashes.json +0 -60
- package/src/.vibeguard/latest-snapshot.json +0 -36
- package/src/.vibeguard/mcp-pins.json +0 -1
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/auto.js +0 -428
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/daemon.js +0 -344
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/dashboard.js +0 -279
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/engine.js +0 -297
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/hook.js +0 -151
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/install.js +0 -299
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/manifest.json +0 -65
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/mcp-server.js +0 -2051
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/plugin.js +0 -168
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/pre-deploy.js +0 -362
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/repl.js +0 -150
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/rules.js +0 -1611
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/sbom.js +0 -164
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/shell-guard.js +0 -292
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/slopsquat.js +0 -144
- package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/trace.js +0 -220
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/auto.js +0 -428
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/daemon.js +0 -344
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/engine.js +0 -297
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/install.js +0 -299
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/manifest.json +0 -37
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/mcp-server.js +0 -2055
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/plugin.js +0 -168
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/pre-deploy.js +0 -362
- package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/trace.js +0 -220
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/auto.js +0 -428
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/daemon.js +0 -344
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/dashboard.js +0 -279
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/engine.js +0 -297
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/hook.js +0 -151
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/install.js +0 -299
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/manifest.json +0 -65
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/mcp-server.js +0 -2055
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/plugin.js +0 -168
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/pre-deploy.js +0 -362
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/repl.js +0 -150
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/rules.js +0 -1611
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/sbom.js +0 -164
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/shell-guard.js +0 -292
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/slopsquat.js +0 -144
- package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/trace.js +0 -220
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/auto.js +0 -428
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/daemon.js +0 -344
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/dashboard.js +0 -279
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/engine.js +0 -297
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/hook.js +0 -151
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/install.js +0 -299
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/manifest.json +0 -65
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/mcp-server.js +0 -2054
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/plugin.js +0 -168
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/pre-deploy.js +0 -362
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/repl.js +0 -150
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/rules.js +0 -1611
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/sbom.js +0 -164
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/shell-guard.js +0 -292
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/slopsquat.js +0 -144
- package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/trace.js +0 -220
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/auto.js +0 -428
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/daemon.js +0 -344
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/engine.js +0 -297
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/install.js +0 -299
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/manifest.json +0 -37
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/mcp-server.js +0 -2055
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/plugin.js +0 -168
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/pre-deploy.js +0 -362
- package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/trace.js +0 -220
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/auto.js +0 -428
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/daemon.js +0 -344
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/engine.js +0 -297
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/manifest.json +0 -33
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/mcp-server.js +0 -2055
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/rules.js +0 -1611
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/shell-guard.js +0 -292
- package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/trace.js +0 -220
- package/src/.vibeguard-baseline.json +0 -5226
package/bin/cmd-mcp-firewall.js
CHANGED
|
@@ -178,6 +178,7 @@ function cmdMcpFirewall(args, flags) {
|
|
|
178
178
|
approvalTenant: flags['approval-tenant'],
|
|
179
179
|
approvalKeyId: flags['approval-key-id'],
|
|
180
180
|
maxBlocks: flags['max-blocks'] ? Number(flags['max-blocks']) : 0,
|
|
181
|
+
maxRssMb: flags['max-rss'] ? Number(flags['max-rss']) : 0,
|
|
181
182
|
});
|
|
182
183
|
|
|
183
184
|
proxy.child.once('spawn', () => {
|
package/bin/cmd-platform.js
CHANGED
|
@@ -96,6 +96,9 @@ async function cmdSandbox(args, flags) {
|
|
|
96
96
|
if (process.platform === 'win32') {
|
|
97
97
|
const { WindowsJobSandbox } = require('../src/platform/windows-sandbox');
|
|
98
98
|
backend = new WindowsJobSandbox();
|
|
99
|
+
} else if (process.platform === 'darwin') {
|
|
100
|
+
const { MacSandboxExecSandbox } = require('../src/platform/os-sandbox');
|
|
101
|
+
backend = new MacSandboxExecSandbox();
|
|
99
102
|
} else {
|
|
100
103
|
const { getLinuxBackend } = require('../src/platform/os-sandbox');
|
|
101
104
|
backend = getLinuxBackend();
|
package/ci/vibeguard.yml
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
name: VibeGuard
|
|
2
|
-
|
|
3
|
-
# Runs VibeGuard on every push and pull request. Fails the job when a CRITICAL
|
|
4
|
-
# issue is found, and uploads a SARIF report to GitHub code scanning so findings
|
|
5
|
-
# show up inline on the PR.
|
|
6
|
-
#
|
|
7
|
-
# Scope reminder: VibeGuard catches high-frequency, well-defined issues (secrets,
|
|
8
|
-
# injection, misconfig). It is not a full security review.
|
|
9
|
-
|
|
10
|
-
on:
|
|
11
|
-
push:
|
|
12
|
-
branches: [main, master]
|
|
13
|
-
pull_request:
|
|
14
|
-
|
|
15
|
-
permissions:
|
|
16
|
-
contents: read
|
|
17
|
-
security-events: write # required to upload SARIF
|
|
18
|
-
|
|
19
|
-
jobs:
|
|
20
|
-
vibeguard:
|
|
21
|
-
runs-on: ubuntu-latest
|
|
22
|
-
steps:
|
|
23
|
-
- uses: actions/checkout@v4
|
|
24
|
-
|
|
25
|
-
- uses: actions/setup-node@v4
|
|
26
|
-
with:
|
|
27
|
-
node-version: 20
|
|
28
|
-
|
|
29
|
-
# Produce a SARIF report for GitHub code scanning (does not fail the job).
|
|
30
|
-
- name: VibeGuard scan (SARIF)
|
|
31
|
-
run: npx -y vibeguard scan . --sarif --no-deps > vibeguard.sarif || true
|
|
32
|
-
|
|
33
|
-
- name: Upload SARIF
|
|
34
|
-
if: always()
|
|
35
|
-
uses: github/codeql-action/upload-sarif@v3
|
|
36
|
-
with:
|
|
37
|
-
sarif_file: vibeguard.sarif
|
|
38
|
-
|
|
39
|
-
# Gate the build: fail on CRITICAL findings, and on a degraded scan
|
|
40
|
-
# (--strict) so an incomplete/parse-failed scan can't pass as clean.
|
|
41
|
-
- name: VibeGuard gate (block on CRITICAL)
|
|
42
|
-
run: npx -y vibeguard scan . --precommit --strict
|
|
1
|
+
name: VibeGuard
|
|
2
|
+
|
|
3
|
+
# Runs VibeGuard on every push and pull request. Fails the job when a CRITICAL
|
|
4
|
+
# issue is found, and uploads a SARIF report to GitHub code scanning so findings
|
|
5
|
+
# show up inline on the PR.
|
|
6
|
+
#
|
|
7
|
+
# Scope reminder: VibeGuard catches high-frequency, well-defined issues (secrets,
|
|
8
|
+
# injection, misconfig). It is not a full security review.
|
|
9
|
+
|
|
10
|
+
on:
|
|
11
|
+
push:
|
|
12
|
+
branches: [main, master]
|
|
13
|
+
pull_request:
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
contents: read
|
|
17
|
+
security-events: write # required to upload SARIF
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
vibeguard:
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
|
|
25
|
+
- uses: actions/setup-node@v4
|
|
26
|
+
with:
|
|
27
|
+
node-version: 20
|
|
28
|
+
|
|
29
|
+
# Produce a SARIF report for GitHub code scanning (does not fail the job).
|
|
30
|
+
- name: VibeGuard scan (SARIF)
|
|
31
|
+
run: npx -y vibeguard scan . --sarif --no-deps > vibeguard.sarif || true
|
|
32
|
+
|
|
33
|
+
- name: Upload SARIF
|
|
34
|
+
if: always()
|
|
35
|
+
uses: github/codeql-action/upload-sarif@v3
|
|
36
|
+
with:
|
|
37
|
+
sarif_file: vibeguard.sarif
|
|
38
|
+
|
|
39
|
+
# Gate the build: fail on CRITICAL findings, and on a degraded scan
|
|
40
|
+
# (--strict) so an incomplete/parse-failed scan can't pass as clean.
|
|
41
|
+
- name: VibeGuard gate (block on CRITICAL)
|
|
42
|
+
run: npx -y vibeguard scan . --precommit --strict
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yagyeshvyas/vibeguard",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Offline-by-default security scanner and runtime firewall for AI-coded apps and MCP agents. 861 rules, 93 MCP tools, signed default-deny policy, tool-poisoning/prompt-injection/secret-exfiltration detection, signed audit
|
|
3
|
+
"version": "1.13.1",
|
|
4
|
+
"description": "Offline-by-default security scanner and runtime firewall for AI-coded apps and MCP agents. 861 rules, 93 MCP tools, signed default-deny policy, tool-poisoning/prompt-injection/secret-exfiltration detection, signed audit + external anchor, hosted approvals with signed proofs, HTTP/SSE MCP bridge with OAuth/TLS, Linux bubblewrap isolation, Windows Job containment and macOS sandbox-exec. Zero telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
7
7
|
"author": "Yagyesh Vyas <https://www.linkedin.com/in/yagyeshvyas/>",
|
package/scripts/counts.js
CHANGED
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* scripts/counts.js — generates live counts of rules, MCP tools, and defense
|
|
5
|
-
* layers from the source. Used to keep README.md and package.json numbers
|
|
6
|
-
* from drifting. Run: `npm run counts`.
|
|
7
|
-
*
|
|
8
|
-
* Output: JSON to stdout: { rules, mcpTools, layers }
|
|
9
|
-
* Also writes a README block between <!-- COUNTS:START --> and <!-- COUNTS:END -->
|
|
10
|
-
* markers if --update-readme is passed.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
const fs = require('fs');
|
|
14
|
-
const path = require('path');
|
|
15
|
-
|
|
16
|
-
const ROOT = path.resolve(__dirname, '..');
|
|
17
|
-
|
|
18
|
-
// --- Rules ---
|
|
19
|
-
function countRules() {
|
|
20
|
-
const { allRules } = require(path.join(ROOT, 'src', 'rules'));
|
|
21
|
-
return allRules().length;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// --- MCP Tools ---
|
|
25
|
-
// Statically count tool registrations in mcp-server.js (can't require it
|
|
26
|
-
// directly — it starts an MCP server on load).
|
|
27
|
-
function countMcpTools() {
|
|
28
|
-
const code = fs.readFileSync(path.join(ROOT, 'src', 'mcp-server.js'), 'utf8');
|
|
29
|
-
const matches = [...code.matchAll(/name:\s*['"]([a-z_]+)['"]/g)].map((m) => m[1]);
|
|
30
|
-
const tools = matches.filter((n) => n !== 'vibeguard');
|
|
31
|
-
const unique = [...new Set(tools)];
|
|
32
|
-
return unique.length;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// --- Defense Layers ---
|
|
36
|
-
// Counted from the pre-deploy gates in src/pre-deploy.js (the canonical list).
|
|
37
|
-
function countLayers() {
|
|
38
|
-
// Count from pre-deploy.js GATES array — no git needed.
|
|
39
|
-
try {
|
|
40
|
-
const src = fs.readFileSync(path.join(ROOT, 'src', 'pre-deploy.js'), 'utf8');
|
|
41
|
-
const match = src.match(/const GATES\s*=\s*\[([\s\S]*?)\]/);
|
|
42
|
-
if (match) {
|
|
43
|
-
const ids = match[1].match(/id:\s*'[^']+'/g);
|
|
44
|
-
if (ids) return ids.length;
|
|
45
|
-
}
|
|
46
|
-
} catch {}
|
|
47
|
-
return 13;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function getCounts() {
|
|
51
|
-
return {
|
|
52
|
-
rules: countRules(),
|
|
53
|
-
mcpTools: countMcpTools(),
|
|
54
|
-
layers: countLayers(),
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// --- README update ---
|
|
59
|
-
function updateReadme(counts) {
|
|
60
|
-
const readmePath = path.join(ROOT, 'README.md');
|
|
61
|
-
let content = fs.readFileSync(readmePath, 'utf8');
|
|
62
|
-
const startMarker = '<!-- COUNTS:START -->';
|
|
63
|
-
const endMarker = '<!-- COUNTS:END -->';
|
|
64
|
-
|
|
65
|
-
const block = [
|
|
66
|
-
startMarker,
|
|
67
|
-
`<!-- Auto-generated by scripts/counts.js — do not edit manually -->`,
|
|
68
|
-
`<!-- Rules: ${counts.rules} | MCP Tools: ${counts.mcpTools} | Defense Layers: ${counts.layers} -->`,
|
|
69
|
-
endMarker,
|
|
70
|
-
].join('\n');
|
|
71
|
-
|
|
72
|
-
const startIdx = content.indexOf(startMarker);
|
|
73
|
-
const endIdx = content.indexOf(endMarker);
|
|
74
|
-
|
|
75
|
-
if (startIdx !== -1 && endIdx !== -1) {
|
|
76
|
-
content = content.slice(0, startIdx) + block + content.slice(endIdx + endMarker.length);
|
|
77
|
-
} else {
|
|
78
|
-
// No markers yet — append before the closing </div> at the end.
|
|
79
|
-
content = content.trimEnd() + '\n\n' + block + '\n';
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
fs.writeFileSync(readmePath, content);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// --- CLI ---
|
|
86
|
-
const args = process.argv.slice(2);
|
|
87
|
-
const counts = getCounts();
|
|
88
|
-
|
|
89
|
-
if (args.includes('--update-readme')) {
|
|
90
|
-
updateReadme(counts);
|
|
91
|
-
console.error('Updated README.md with counts block.');
|
|
92
|
-
}
|
|
93
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* scripts/counts.js — generates live counts of rules, MCP tools, and defense
|
|
5
|
+
* layers from the source. Used to keep README.md and package.json numbers
|
|
6
|
+
* from drifting. Run: `npm run counts`.
|
|
7
|
+
*
|
|
8
|
+
* Output: JSON to stdout: { rules, mcpTools, layers }
|
|
9
|
+
* Also writes a README block between <!-- COUNTS:START --> and <!-- COUNTS:END -->
|
|
10
|
+
* markers if --update-readme is passed.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const fs = require('fs');
|
|
14
|
+
const path = require('path');
|
|
15
|
+
|
|
16
|
+
const ROOT = path.resolve(__dirname, '..');
|
|
17
|
+
|
|
18
|
+
// --- Rules ---
|
|
19
|
+
function countRules() {
|
|
20
|
+
const { allRules } = require(path.join(ROOT, 'src', 'rules'));
|
|
21
|
+
return allRules().length;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// --- MCP Tools ---
|
|
25
|
+
// Statically count tool registrations in mcp-server.js (can't require it
|
|
26
|
+
// directly — it starts an MCP server on load).
|
|
27
|
+
function countMcpTools() {
|
|
28
|
+
const code = fs.readFileSync(path.join(ROOT, 'src', 'mcp-server.js'), 'utf8');
|
|
29
|
+
const matches = [...code.matchAll(/name:\s*['"]([a-z_]+)['"]/g)].map((m) => m[1]);
|
|
30
|
+
const tools = matches.filter((n) => n !== 'vibeguard');
|
|
31
|
+
const unique = [...new Set(tools)];
|
|
32
|
+
return unique.length;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// --- Defense Layers ---
|
|
36
|
+
// Counted from the pre-deploy gates in src/pre-deploy.js (the canonical list).
|
|
37
|
+
function countLayers() {
|
|
38
|
+
// Count from pre-deploy.js GATES array — no git needed.
|
|
39
|
+
try {
|
|
40
|
+
const src = fs.readFileSync(path.join(ROOT, 'src', 'pre-deploy.js'), 'utf8');
|
|
41
|
+
const match = src.match(/const GATES\s*=\s*\[([\s\S]*?)\]/);
|
|
42
|
+
if (match) {
|
|
43
|
+
const ids = match[1].match(/id:\s*'[^']+'/g);
|
|
44
|
+
if (ids) return ids.length;
|
|
45
|
+
}
|
|
46
|
+
} catch {}
|
|
47
|
+
return 13;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function getCounts() {
|
|
51
|
+
return {
|
|
52
|
+
rules: countRules(),
|
|
53
|
+
mcpTools: countMcpTools(),
|
|
54
|
+
layers: countLayers(),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// --- README update ---
|
|
59
|
+
function updateReadme(counts) {
|
|
60
|
+
const readmePath = path.join(ROOT, 'README.md');
|
|
61
|
+
let content = fs.readFileSync(readmePath, 'utf8');
|
|
62
|
+
const startMarker = '<!-- COUNTS:START -->';
|
|
63
|
+
const endMarker = '<!-- COUNTS:END -->';
|
|
64
|
+
|
|
65
|
+
const block = [
|
|
66
|
+
startMarker,
|
|
67
|
+
`<!-- Auto-generated by scripts/counts.js — do not edit manually -->`,
|
|
68
|
+
`<!-- Rules: ${counts.rules} | MCP Tools: ${counts.mcpTools} | Defense Layers: ${counts.layers} -->`,
|
|
69
|
+
endMarker,
|
|
70
|
+
].join('\n');
|
|
71
|
+
|
|
72
|
+
const startIdx = content.indexOf(startMarker);
|
|
73
|
+
const endIdx = content.indexOf(endMarker);
|
|
74
|
+
|
|
75
|
+
if (startIdx !== -1 && endIdx !== -1) {
|
|
76
|
+
content = content.slice(0, startIdx) + block + content.slice(endIdx + endMarker.length);
|
|
77
|
+
} else {
|
|
78
|
+
// No markers yet — append before the closing </div> at the end.
|
|
79
|
+
content = content.trimEnd() + '\n\n' + block + '\n';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
fs.writeFileSync(readmePath, content);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// --- CLI ---
|
|
86
|
+
const args = process.argv.slice(2);
|
|
87
|
+
const counts = getCounts();
|
|
88
|
+
|
|
89
|
+
if (args.includes('--update-readme')) {
|
|
90
|
+
updateReadme(counts);
|
|
91
|
+
console.error('Updated README.md with counts block.');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
94
|
console.log(JSON.stringify(counts, null, 2));
|
package/scripts/postinstall.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// scripts/postinstall.js — runs after npm install.
|
|
4
|
-
// Prints a one-line suggestion. NEVER modifies shell profiles or any file
|
|
5
|
-
// outside the installed package. A security tool that silently edits user
|
|
6
|
-
// files is doing the thing it warns about.
|
|
7
|
-
|
|
8
|
-
try {
|
|
9
|
-
// Opt-out + CI quiet: a security tool should not add install-time noise or
|
|
10
|
-
// surprise. VIBEGUARD_NO_POSTINSTALL=1 silences this entirely.
|
|
11
|
-
if (process.env.VIBEGUARD_NO_POSTINSTALL === '1' || process.env.CI) {
|
|
12
|
-
process.exit(0);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const path = require('path');
|
|
16
|
-
const fs = require('fs');
|
|
17
|
-
|
|
18
|
-
const cliPath = path.join(__dirname, '..', 'bin', 'cli.js');
|
|
19
|
-
if (!fs.existsSync(cliPath)) {
|
|
20
|
-
process.exit(0);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
process.stderr.write('\n VibeGuard installed. Run "vibeguard auto" to enable layered protection.\n\n');
|
|
24
|
-
process.exit(0);
|
|
25
|
-
} catch {
|
|
26
|
-
process.exit(0);
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// scripts/postinstall.js — runs after npm install.
|
|
4
|
+
// Prints a one-line suggestion. NEVER modifies shell profiles or any file
|
|
5
|
+
// outside the installed package. A security tool that silently edits user
|
|
6
|
+
// files is doing the thing it warns about.
|
|
7
|
+
|
|
8
|
+
try {
|
|
9
|
+
// Opt-out + CI quiet: a security tool should not add install-time noise or
|
|
10
|
+
// surprise. VIBEGUARD_NO_POSTINSTALL=1 silences this entirely.
|
|
11
|
+
if (process.env.VIBEGUARD_NO_POSTINSTALL === '1' || process.env.CI) {
|
|
12
|
+
process.exit(0);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const path = require('path');
|
|
16
|
+
const fs = require('fs');
|
|
17
|
+
|
|
18
|
+
const cliPath = path.join(__dirname, '..', 'bin', 'cli.js');
|
|
19
|
+
if (!fs.existsSync(cliPath)) {
|
|
20
|
+
process.exit(0);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
process.stderr.write('\n VibeGuard installed. Run "vibeguard auto" to enable layered protection.\n\n');
|
|
24
|
+
process.exit(0);
|
|
25
|
+
} catch {
|
|
26
|
+
process.exit(0);
|
|
27
27
|
}
|