guardvibe 3.1.42 → 3.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 CHANGED
@@ -5,6 +5,28 @@ All notable changes to GuardVibe are documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [3.3.0] - 2026-06-07
9
+
10
+ ### Added — diff-aware scanning: block what you just wrote, not the backlog (438 rules / 37 tools)
11
+ - **`guardvibe diff [base]` is now diff-aware by default** — it reports only findings on lines the change actually **added**, instead of re-reporting pre-existing debt in every file you touched. This makes the gate actionable: it blocks the issues newly introduced vs the base, the ones an AI agent just wrote.
12
+ - **Transparent, never silent:** the report states the mode and how many pre-existing findings on unchanged lines were hidden (`preExistingHidden` in JSON; a note in markdown). `--all-lines` restores the whole-changed-file view.
13
+ - New module `src/tools/diff-aware.ts` — a pure, git-free unified-diff hunk parser (`addedLinesFromUnifiedDiff`) plus thin `git diff` wrappers (`getAddedLinesForDiff`, `getAddedLinesStaged`) and a `filterToAddedLines` helper. Unit-tested independent of git; works at any `--unified` context level; counts newly-added files as fully added; ignores deletions.
14
+ - No rule or tool changes (438 / 37).
15
+
16
+ Gate green (build / lint / test / self-audit PASS / A / 0).
17
+
18
+ ## [3.2.0] - 2026-06-07
19
+
20
+ ### Added — `secure_this`: close the loop from "warns" to "guarantees the fix landed" (438 rules / 37 tools)
21
+ - **New tool `secure_this`** (MCP + CLI `guardvibe secure-this <file>`). It scans a file, applies only the auto-fixes that **verifiably land**, and re-verifies — converting GuardVibe from a tool that *reports* findings into one that *guarantees the fix landed*.
22
+ - **Verify-and-rollback loop:** every candidate edit from `fix_code` is applied to a copy and re-scanned; the edit is kept only if it (1) strictly reduces the finding set and (2) introduces no new finding. Any edit that fails either check is rolled back. The loop repeats until no further verified fix is available.
23
+ - **Definition-of-done gate:** the result carries `definitionOfDone.passed` — the agent must pass it before claiming a task complete. `status` is `clean` / `secured` / `partial` / `no_autofix`; `applied[]` lists verified fixes, `remaining[]` lists findings that need a manual fix (with guidance).
24
+ - **Deterministic:** same code in → same code out (fixes applied in a fixed line/rule order; verified by the deterministic `analyzeFileSecurity`).
25
+ - **CLI:** `secure-this <file>` is dry-run by default (shows what would land + remaining manual work); `--write` applies only the verified fixes to disk; `--format json` for agents. Exit code gates a pre-commit hook / CI step (1 while real findings remain).
26
+ - Tool count 36 → 37. No rule changes (438).
27
+
28
+ Gate green (build / lint / test / self-audit PASS / A / 0).
29
+
8
30
  ## [3.1.42] - 2026-06-07
9
31
 
10
32
  ### Fixed — MCP registry description length (no rule-count change, 438 / 36)
package/README.md CHANGED
@@ -14,7 +14,7 @@
14
14
  - **🗺️ Sees the whole repo.** Cross-file taint + auth-coverage across every route — catches the unprotected endpoint your agent's narrow context missed.
15
15
  - **🔍 An independent second pair of eyes.** The thing that wrote the code can't review itself. GuardVibe is the outside checker on AI-written code — in the loop *while* your AI codes (real-time edit hook), not after.
16
16
 
17
- **The security MCP built for vibe coding.** 438 security rules, 36 tools covering the entire AI-generated code journey — from first line to production deployment.
17
+ **The security MCP built for vibe coding.** 438 security rules, 37 tools covering the entire AI-generated code journey — from first line to production deployment.
18
18
 
19
19
  Works with **Claude Code, Cursor, Gemini CLI, Codex, VS Code (Copilot), Windsurf**, and any MCP-compatible coding agent.
20
20
 
@@ -26,7 +26,7 @@ Works with **Claude Code, Cursor, Gemini CLI, Codex, VS Code (Copilot), Windsurf
26
26
 
27
27
  Most security tools are built for enterprise security teams. GuardVibe is built for **you** — the developer using AI to build and ship web apps fast.
28
28
 
29
- - **438 security rules, 36 tools** purpose-built for the stacks AI agents generate
29
+ - **438 security rules, 37 tools** purpose-built for the stacks AI agents generate
30
30
  - **Zero setup friction** — `npx guardvibe` and you're scanning
31
31
  - **No account required** — runs 100% locally, no API keys, no cloud
32
32
  - **Understands your stack** — not generic SAST, but rules that know Next.js, Supabase, Stripe, Clerk, and the tools you actually use
@@ -211,7 +211,7 @@ Maps security findings to SOC2, PCI-DSS, HIPAA, GDPR, ISO27001, and EU AI Act (E
211
211
  ### Supply Chain
212
212
  Malicious postinstall scripts, unpinned GitHub Actions, CI `npm` provenance / `--ignore-scripts` hardening (VG1070), typosquat detection, `node-ipc` protestware versions (VG1069), Miasma `@redhat-cloud-services` namespace compromise IOC (VG1074, RHSB-2026-006), Session messenger exfil endpoint IOC (VG1075, `filev2.getsession.org`), `@tanstack/*` Mini Shai-Hulud mass-malware versions (May 2026), `@wdio/browserstack-service` command injection via git branch names (CVE-2026-25244), lockfile poisoning patterns
213
213
 
214
- ## Tools (36 MCP tools)
214
+ ## Tools (37 MCP tools)
215
215
 
216
216
  | Tool | What it does |
217
217
  |------|-------------|
@@ -227,6 +227,7 @@ Malicious postinstall scripts, unpinned GitHub Actions, CI `npm` provenance / `-
227
227
  | `export_sarif` | SARIF v2.1.0 export for CI/CD integration |
228
228
  | `get_security_docs` | Security best practices and guides |
229
229
  | `fix_code` | **Auto-fix suggestions** with concrete patches for AI agents |
230
+ | `secure_this` | **Close the loop** — scan, apply only the fixes that verifiably land (each re-scanned, rolled back on regression), return the verified code + a definition-of-done gate |
230
231
  | `audit_config` | Audit project configuration files for cross-file security misconfigurations |
231
232
  | `generate_policy` | Detect project stack and generate tailored security policies (CSP, CORS, RLS) |
232
233
  | `review_pr` | Review PR diff for security issues with severity gating |
@@ -291,7 +292,13 @@ All scanning tools support `format: "json"` for machine-readable output.
291
292
  npx guardvibe scan [path] # Scan a directory for security issues
292
293
  npx guardvibe scan . --format json # JSON output for automation
293
294
  npx guardvibe check <file> # Scan a single file
294
- npx guardvibe diff [base] # Scan only changed files since git ref
295
+ npx guardvibe diff [base] # Scan changed files reports only newly-introduced issues
296
+ npx guardvibe diff [base] --all-lines # Include pre-existing findings in changed files too
297
+
298
+ # Close the loop — scan, apply verified fixes, re-verify
299
+ npx guardvibe secure-this <file> # Dry run: show the fixes that would land + remaining manual work
300
+ npx guardvibe secure-this <file> --write # Apply only the fixes that re-verify clean (rolled back on regression)
301
+ npx guardvibe secure-this <file> --format json
295
302
 
296
303
  # Full security audit
297
304
  npx guardvibe audit [path] # Full audit with PASS/FAIL verdict + hash
package/build/cli/scan.js CHANGED
@@ -78,9 +78,13 @@ export async function runDiffScan(base, flags) {
78
78
  const { execFileSync } = await import("child_process");
79
79
  const { analyzeFileSecurity } = await import("../tools/file-security.js");
80
80
  const { EXTENSION_MAP, CONFIG_FILE_MAP } = await import("../utils/constants.js");
81
+ const { getAddedLinesForDiff, filterToAddedLines } = await import("../tools/diff-aware.js");
81
82
  const format = validateFormat(flags);
82
83
  const outputFile = getOutputPath(flags);
83
84
  const root = resolve(".");
85
+ // Diff-aware by default: report only issues on newly-added lines. --all-lines
86
+ // restores the old whole-changed-file behavior (surfaces pre-existing debt too).
87
+ const allLines = flags["all-lines"] === true;
84
88
  let changedFiles;
85
89
  try {
86
90
  const output = execFileSync("git", ["diff", "--name-only", "--diff-filter=ACMR", base], { cwd: root, encoding: "utf-8" });
@@ -95,6 +99,7 @@ export async function runDiffScan(base, flags) {
95
99
  return;
96
100
  }
97
101
  const allFindings = [];
102
+ let preExistingHidden = 0;
98
103
  for (const relPath of changedFiles) {
99
104
  const fullPath = resolve(root, relPath);
100
105
  if (!existsSync(fullPath))
@@ -110,24 +115,34 @@ export async function runDiffScan(base, flags) {
110
115
  try {
111
116
  const content = readFileSync(fullPath, "utf-8");
112
117
  const findings = analyzeFileSecurity(content, language, undefined, fullPath, root);
113
- for (const f of findings) {
118
+ let kept = findings;
119
+ if (!allLines) {
120
+ const added = getAddedLinesForDiff(base, relPath, root);
121
+ kept = filterToAddedLines(findings, added);
122
+ preExistingHidden += findings.length - kept.length;
123
+ }
124
+ for (const f of kept) {
114
125
  allFindings.push({ file: relPath, severity: f.rule.severity, name: f.rule.name, id: f.rule.id, line: f.line, fix: f.rule.fix });
115
126
  }
116
127
  }
117
128
  catch { /* skip */ }
118
129
  }
130
+ const mode = allLines ? "all changed lines" : "newly-introduced lines only";
119
131
  let result;
120
132
  if (format === "json") {
121
133
  const critical = allFindings.filter(f => f.severity === "critical").length;
122
134
  const high = allFindings.filter(f => f.severity === "high").length;
123
135
  const medium = allFindings.filter(f => f.severity === "medium").length;
124
136
  result = JSON.stringify({
125
- summary: { total: allFindings.length, critical, high, medium, changedFiles: changedFiles.length, blocked: critical > 0 || high > 0 },
137
+ summary: { total: allFindings.length, critical, high, medium, changedFiles: changedFiles.length, blocked: critical > 0 || high > 0, diffAware: !allLines, preExistingHidden },
126
138
  findings: allFindings,
127
139
  });
128
140
  }
129
141
  else {
130
- const lines = [`# GuardVibe Diff Report`, ``, `Base: ${base}`, `Changed files: ${changedFiles.length}`, `Issues: ${allFindings.length}`, ``];
142
+ const lines = [`# GuardVibe Diff Report`, ``, `Base: ${base}`, `Mode: ${mode}`, `Changed files: ${changedFiles.length}`, `Issues: ${allFindings.length}`, ``];
143
+ if (!allLines && preExistingHidden > 0) {
144
+ lines.push(`> ${preExistingHidden} pre-existing finding(s) on unchanged lines hidden — re-run with \`--all-lines\` to see them.`, ``);
145
+ }
131
146
  if (allFindings.length === 0) {
132
147
  lines.push(`All changed files passed security checks.`);
133
148
  }
@@ -0,0 +1 @@
1
+ export declare function runSecureThis(args: string[]): Promise<void>;
@@ -0,0 +1,96 @@
1
+ /**
2
+ * CLI: guardvibe secure-this <file> [--write] [--format json]
3
+ *
4
+ * Closes the loop: scans the file, applies only the fixes that verifiably land
5
+ * (each re-scanned, rolled back on regression), and reports a definition-of-done
6
+ * gate. Dry-run by default; `--write` applies the verified fixes to disk.
7
+ *
8
+ * Exit code: 0 when the file is (or was made) clean; 1 while real findings remain
9
+ * — so it can gate a pre-commit hook or CI step.
10
+ */
11
+ import { readFileSync, writeFileSync, existsSync } from "fs";
12
+ import { resolve, extname, basename } from "path";
13
+ import { parseArgs } from "./args.js";
14
+ import { secureThis } from "../tools/secure-this.js";
15
+ import { EXTENSION_MAP, CONFIG_FILE_MAP } from "../utils/constants.js";
16
+ function detectLanguage(resolvedPath) {
17
+ const ext = extname(resolvedPath).toLowerCase();
18
+ let language = EXTENSION_MAP[ext];
19
+ if (!language && basename(resolvedPath).startsWith("Dockerfile"))
20
+ language = "dockerfile";
21
+ if (!language)
22
+ language = CONFIG_FILE_MAP[basename(resolvedPath)];
23
+ return language;
24
+ }
25
+ function renderMarkdown(r, file, wrote) {
26
+ const badge = {
27
+ clean: "CLEAN ✅", secured: "SECURED ✅", partial: "PARTIAL ⚠️", no_autofix: "NO AUTO-FIX ❌",
28
+ };
29
+ const lines = [
30
+ `# GuardVibe secure_this — ${file}`,
31
+ "",
32
+ `**Status:** ${badge[r.status] ?? r.status}`,
33
+ `**Findings:** ${r.initialFindings} → ${r.finalFindings}`,
34
+ "",
35
+ ];
36
+ if (r.applied.length) {
37
+ lines.push(`## Applied & verified (${r.applied.length})`, "");
38
+ for (const a of r.applied) {
39
+ lines.push(`- **${a.ruleId}** (${a.severity}) line ${a.line}: ${a.ruleName}`);
40
+ }
41
+ lines.push("");
42
+ }
43
+ if (r.remaining.length) {
44
+ lines.push(`## Remaining — manual fix required (${r.remaining.length})`, "");
45
+ for (const f of r.remaining) {
46
+ lines.push(`- **${f.ruleId}** (${f.severity}) line ${f.line}: ${f.name}`);
47
+ if (f.fix)
48
+ lines.push(` - Fix: ${f.fix}`);
49
+ }
50
+ lines.push("");
51
+ }
52
+ if (r.changed && !wrote) {
53
+ lines.push("> Dry run — re-run with `--write` to apply the verified fixes above.", "");
54
+ }
55
+ else if (wrote && r.changed) {
56
+ lines.push(`> Wrote ${r.applied.length} verified fix(es) to ${file}.`, "");
57
+ }
58
+ lines.push(`**Definition of done:** ${r.definitionOfDone.passed ? "PASSED ✅" : "FAILED ❌"} — ${r.definitionOfDone.message}`);
59
+ return lines.join("\n");
60
+ }
61
+ export async function runSecureThis(args) {
62
+ const { flags, positional } = parseArgs(args);
63
+ const filePath = positional[0];
64
+ if (!filePath) {
65
+ console.error(" [ERR] Please specify a file: npx guardvibe secure-this src/app/api/route.ts [--write]");
66
+ process.exit(1);
67
+ }
68
+ const resolved = resolve(filePath);
69
+ if (!existsSync(resolved)) {
70
+ console.error(` [ERR] File not found: ${resolved}`);
71
+ process.exit(1);
72
+ }
73
+ const language = detectLanguage(resolved);
74
+ if (!language) {
75
+ console.error(` [ERR] Unsupported file type: ${extname(resolved) || basename(resolved)}`);
76
+ process.exit(1);
77
+ }
78
+ const content = readFileSync(resolved, "utf-8");
79
+ const result = secureThis(content, language, { filePath: resolved });
80
+ const write = flags.write === true || flags.apply === true;
81
+ if (write && result.changed) {
82
+ writeFileSync(resolved, result.fixedCode, "utf-8");
83
+ }
84
+ const format = flags.format === "json" ? "json" : "markdown";
85
+ if (format === "json") {
86
+ console.log(JSON.stringify({ ...result, file: resolved, wrote: write && result.changed }));
87
+ }
88
+ else {
89
+ console.log(renderMarkdown(result, resolved, write && result.changed));
90
+ }
91
+ // Exit code gates a pre-commit hook / CI step.
92
+ // --write: pass iff the file ended clean. Dry-run: pass only if nothing to fix.
93
+ const ok = write ? result.definitionOfDone.passed : result.status === "clean";
94
+ if (!ok)
95
+ process.exit(1);
96
+ }
package/build/cli.js CHANGED
@@ -23,12 +23,13 @@ function printUsage() {
23
23
 
24
24
  Commands:
25
25
  npx guardvibe scan [path] Scan a directory for security issues
26
- npx guardvibe diff [base] Scan only changed files since a git ref
26
+ npx guardvibe diff [base] Scan changed files; reports only newly-introduced issues (--all-lines for whole files)
27
27
  npx guardvibe check <file> Scan a single file for security issues
28
28
  npx guardvibe doctor [path] Run host security audit
29
29
  npx guardvibe audit [path] Full security audit with PASS/FAIL verdict
30
30
  npx guardvibe explain <ruleId> Get detailed remediation guidance for a rule
31
31
  npx guardvibe fix <file> Get security fix suggestions for a file
32
+ npx guardvibe secure-this <file> Scan, apply verified fixes, re-verify (--write to apply)
32
33
  npx guardvibe check-cmd "<cmd>" Check if a shell command is safe to execute
33
34
  npx guardvibe auth-coverage [path] Auth coverage analysis (Next.js routes)
34
35
  npx guardvibe compliance [path] Compliance report (--framework SOC2|GDPR|...)
@@ -49,6 +50,7 @@ function printUsage() {
49
50
  critical (default) | high | medium | low | none
50
51
  --baseline <file> Compare against a previous scan JSON for fix tracking
51
52
  --save-baseline Save current scan as baseline (.guardvibe-baseline.json)
53
+ --all-lines (diff) Report all findings in changed files, not just newly-added lines
52
54
  --version, -V Print version and exit
53
55
  --help, -h Show this help message
54
56
 
@@ -145,6 +147,10 @@ async function main() {
145
147
  const { runFix } = await import("./cli/fix.js");
146
148
  await runFix(subArgs);
147
149
  }
150
+ else if (command === "secure-this" || command === "secure_this") {
151
+ const { runSecureThis } = await import("./cli/secure-this.js");
152
+ await runSecureThis(subArgs);
153
+ }
148
154
  else if (command === "check-cmd") {
149
155
  const { runCheckCmd } = await import("./cli/check-cmd.js");
150
156
  await runCheckCmd(subArgs);
package/build/index.js CHANGED
@@ -41,6 +41,7 @@ import { doctor } from "./tools/doctor.js";
41
41
  import { formatHostFindings, redactSecrets } from "./server/types.js";
42
42
  import { verifyFix } from "./tools/verify-fix.js";
43
43
  import { fixCode as fixCodeTool } from "./tools/fix-code.js";
44
+ import { secureThis } from "./tools/secure-this.js";
44
45
  import { analyzeAuthCoverage, formatAuthCoverage } from "./tools/auth-coverage.js";
45
46
  import { buildDeepScanPrompt, parseDeepScanResult, formatDeepScanFindings, callLLM } from "./tools/deep-scan.js";
46
47
  import { runFullAudit, formatAuditResult } from "./tools/full-audit.js";
@@ -315,6 +316,25 @@ server.tool("fix_code", "Pass vulnerable code as a string and get fix suggestion
315
316
  content: [{ type: "text", text: results }],
316
317
  };
317
318
  });
319
+ // Tool 37: secure_this — close the loop (scan → apply verified fix → re-verify)
320
+ server.tool("secure_this", "Close the loop on vulnerabilities in code: scan, apply only the fixes that VERIFIABLY land (each candidate edit is re-scanned and rolled back if it fails to resolve the issue or introduces a new one), and return the verified code plus a definition-of-done gate. Prefer this over fix_code+verify_fix when you want a guarantee the fix landed — not just a suggestion. Returns { status: clean|secured|partial|no_autofix, fixedCode, applied[], remaining[], definitionOfDone:{passed,message} }. Write fixedCode to disk, then require definitionOfDone.passed before claiming the task complete; anything in remaining[] needs a manual fix. Example: secure_this({code: '...', language: 'typescript'})", {
321
+ code: z.string().describe("The code to scan and secure"),
322
+ language: z
323
+ .enum(["javascript", "typescript", "python", "go", "dockerfile", "html", "sql", "shell", "yaml", "terraform", "firestore"])
324
+ .describe("Programming language of the code"),
325
+ framework: z.string().optional().describe("Framework context (e.g. express, nextjs, react)"),
326
+ filePath: z.string().optional().describe("File path for context-aware analysis (the file is NOT written; apply fixedCode yourself)"),
327
+ }, async ({ code, language, framework, filePath }) => {
328
+ const rules = getRules();
329
+ const result = secureThis(code, language, { framework, filePath, rules });
330
+ if (result.applied.length > 0) {
331
+ try {
332
+ recordFix(process.cwd(), result.applied.length);
333
+ }
334
+ catch { /* stats best-effort */ }
335
+ }
336
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
337
+ });
318
338
  // Tool 13: Cross-file configuration security audit
319
339
  server.tool("audit_config", "Audit application config files (next.config, middleware, .env, vercel.json) for cross-file security gaps: missing headers, unprotected routes, exposed secrets. NOT the same as guardvibe_doctor which checks AI host security (MCP configs, hooks). Example: audit_config({path: '.'})", {
320
340
  path: z.string().describe("Project root directory to audit"),
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Parse unified-diff text and return the set of 1-based line numbers that are
3
+ * ADDED in the new version of the file. Works at any `--unified` context level.
4
+ */
5
+ export declare function addedLinesFromUnifiedDiff(diff: string): Set<number>;
6
+ /** Keep only findings whose line number is in the added-line set. */
7
+ export declare function filterToAddedLines<T extends {
8
+ line: number;
9
+ }>(findings: T[], added: Set<number>): T[];
10
+ /** Lines added in `relPath` relative to a git base ref (branch/commit/HEAD~N). */
11
+ export declare function getAddedLinesForDiff(base: string, relPath: string, cwd: string): Set<number>;
12
+ /** Lines added in `relPath` in the staged (index) changes — for pre-commit gating. */
13
+ export declare function getAddedLinesStaged(relPath: string, cwd: string): Set<number>;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Diff-aware scanning — surface only the issues that were NEWLY introduced.
3
+ *
4
+ * Scanning a changed file whole re-reports pre-existing debt the author didn't
5
+ * touch, which trains agents (and people) to ignore the output. Diff-aware
6
+ * filtering keeps only findings that land on lines the current change actually
7
+ * ADDED, so the gate blocks what you just wrote — not the backlog.
8
+ *
9
+ * The hunk parser is pure and git-free (unit-tested); a thin wrapper shells out
10
+ * to `git diff` to obtain the unified diff for a file.
11
+ */
12
+ import { execFileSync } from "child_process";
13
+ /**
14
+ * Parse unified-diff text and return the set of 1-based line numbers that are
15
+ * ADDED in the new version of the file. Works at any `--unified` context level.
16
+ */
17
+ export function addedLinesFromUnifiedDiff(diff) {
18
+ const added = new Set();
19
+ let newLine = 0;
20
+ let inHunk = false;
21
+ for (const raw of diff.split("\n")) {
22
+ if (raw.startsWith("@@")) {
23
+ // @@ -oldStart,oldCount +newStart,newCount @@
24
+ const m = raw.match(/@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/);
25
+ if (m) {
26
+ newLine = parseInt(m[1], 10);
27
+ inHunk = true;
28
+ }
29
+ continue;
30
+ }
31
+ if (!inHunk || raw === "")
32
+ continue;
33
+ if (raw.startsWith("+++") || raw.startsWith("---"))
34
+ continue;
35
+ const c = raw[0];
36
+ if (c === "+") {
37
+ added.add(newLine);
38
+ newLine++;
39
+ }
40
+ else if (c === "-") {
41
+ // deletion — present only in the old file, does not advance the new line
42
+ }
43
+ else if (c === "\\") {
44
+ // "" — metadata, ignore
45
+ }
46
+ else {
47
+ // context line (leading space) — advances the new-file line counter
48
+ newLine++;
49
+ }
50
+ }
51
+ return added;
52
+ }
53
+ /** Keep only findings whose line number is in the added-line set. */
54
+ export function filterToAddedLines(findings, added) {
55
+ return findings.filter(f => added.has(f.line));
56
+ }
57
+ function gitDiffAddedLines(args, relPath, cwd) {
58
+ try {
59
+ const out = execFileSync("git", ["diff", "--no-color", "--unified=0", ...args, "--", relPath], {
60
+ cwd,
61
+ encoding: "utf-8",
62
+ maxBuffer: 32 * 1024 * 1024,
63
+ });
64
+ return addedLinesFromUnifiedDiff(out);
65
+ }
66
+ catch {
67
+ // Not a git repo, untracked path, or git unavailable — caller decides fallback.
68
+ return new Set();
69
+ }
70
+ }
71
+ /** Lines added in `relPath` relative to a git base ref (branch/commit/HEAD~N). */
72
+ export function getAddedLinesForDiff(base, relPath, cwd) {
73
+ return gitDiffAddedLines([base], relPath, cwd);
74
+ }
75
+ /** Lines added in `relPath` in the staged (index) changes — for pre-commit gating. */
76
+ export function getAddedLinesStaged(relPath, cwd) {
77
+ return gitDiffAddedLines(["--cached"], relPath, cwd);
78
+ }
@@ -0,0 +1,47 @@
1
+ import type { SecurityRule } from "../data/rules/types.js";
2
+ export interface AppliedFix {
3
+ ruleId: string;
4
+ ruleName: string;
5
+ severity: string;
6
+ line: number;
7
+ before: string;
8
+ after: string;
9
+ }
10
+ export interface RemainingFinding {
11
+ ruleId: string;
12
+ name: string;
13
+ severity: string;
14
+ line: number;
15
+ reason: "no_autofix" | "fix_rejected";
16
+ fix: string;
17
+ fixCode?: string;
18
+ }
19
+ export type SecureThisStatus = "clean" | "secured" | "partial" | "no_autofix";
20
+ export interface SecureThisResult {
21
+ status: SecureThisStatus;
22
+ changed: boolean;
23
+ initialFindings: number;
24
+ finalFindings: number;
25
+ resolved: string[];
26
+ applied: AppliedFix[];
27
+ remaining: RemainingFinding[];
28
+ passes: number;
29
+ fixedCode: string;
30
+ definitionOfDone: {
31
+ passed: boolean;
32
+ message: string;
33
+ };
34
+ }
35
+ export interface SecureThisOptions {
36
+ framework?: string;
37
+ filePath?: string;
38
+ configDir?: string;
39
+ rules?: SecurityRule[];
40
+ /** Hard backstop on apply passes (each accepted edit removes >=1 finding). */
41
+ maxPasses?: number;
42
+ }
43
+ /**
44
+ * Scan a file, apply only the fixes that verifiably land, and report a
45
+ * definition-of-done gate.
46
+ */
47
+ export declare function secureThis(code: string, language: string, opts?: SecureThisOptions): SecureThisResult;
Binary file
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "guardvibe",
3
- "version": "3.1.42",
3
+ "version": "3.3.0",
4
4
  "mcpName": "io.github.goklab/guardvibe",
5
- "description": "Security infrastructure your AI can't be — deterministic, current past your model's training cutoff, whole-repo-aware, author-independent. Security MCP for vibe coding. 438 rules, 36 tools, CLI + doctor. Host security, auth coverage mapping, LLM-powered deep scan (IDOR/business logic), taint analysis. 67 CVE rules refreshed daily from GHSA/OSV/CISA KEV — Miasma @redhat-cloud-services compromise, Next.js May 2026 13-advisory cluster, Drizzle/MikroORM/Kysely SQL injection, Axios proxy-auth redirect leak, Hono setCookie attribute injection, Clerk SSRF, tRPC prototype pollution, @tanstack supply-chain, node-ipc protestware, OpenClaude sandbox bypass, plus the full AI-generated stack (Supabase, Stripe, Prisma, Hono, GraphQL, Convex, Turso, Uploadthing, AI SDK). 68 AI-native rules including OWASP MCP Top 10 tool-description prompt injection (VG1068), model-controlled sandbox-disable flag detection (VG1063), Session messenger exfil endpoint IOC (VG1075), and CI/CD supply-chain hardening (VG1070 npm --expect-provenance / --ignore-scripts enforcement).",
5
+ "description": "Security infrastructure your AI can't be — deterministic, current past your model's training cutoff, whole-repo-aware, author-independent. Security MCP for vibe coding. 438 rules, 37 tools, CLI + doctor. Host security, auth coverage mapping, LLM-powered deep scan (IDOR/business logic), taint analysis. 67 CVE rules refreshed daily from GHSA/OSV/CISA KEV — Miasma @redhat-cloud-services compromise, Next.js May 2026 13-advisory cluster, Drizzle/MikroORM/Kysely SQL injection, Axios proxy-auth redirect leak, Hono setCookie attribute injection, Clerk SSRF, tRPC prototype pollution, @tanstack supply-chain, node-ipc protestware, OpenClaude sandbox bypass, plus the full AI-generated stack (Supabase, Stripe, Prisma, Hono, GraphQL, Convex, Turso, Uploadthing, AI SDK). 68 AI-native rules including OWASP MCP Top 10 tool-description prompt injection (VG1068), model-controlled sandbox-disable flag detection (VG1063), Session messenger exfil endpoint IOC (VG1075), and CI/CD supply-chain hardening (VG1070 npm --expect-provenance / --ignore-scripts enforcement).",
6
6
  "type": "module",
7
7
  "bin": {
8
8
  "guardvibe": "build/cli.js",