guardvibe 3.11.0 → 3.13.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,24 @@ 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.13.0] - 2026-06-07
9
+
10
+ ### Added — Season 3 S3-3: PR-native, author-independent review (441 rules / 37 tools)
11
+ - **`guardvibe ci github --pr`** generates a `.github/workflows/guardvibe-pr-review.yml` that, on every pull request, runs a **diff-aware** scan (only the issues the PR newly introduced) and posts them as **inline review comments** on the exact file + line — the moat made visible where AI-written code lands: whole-repo aware, independent of the author, in the loop.
12
+ - Uses `actions/github-script` to create the PR review (no extra runtime dependency), with `pull-requests: write` and a graceful fallback to a summary comment if inline review can't be posted. Pinned + auto-upgraded like the existing scan workflow.
13
+ - Completes Season 3 (S3-1 autonomous/prioritized intel, S3-2 proof-carrying fixes, S3-3 PR-native review). New exported `buildGithubPrReviewWorkflow`; 6 tests. No rule or tool changes (441 / 37).
14
+
15
+ Gate green (build / lint / test / self-audit PASS / A / 0).
16
+
17
+ ## [3.12.0] - 2026-06-07
18
+
19
+ ### Added — Season 3 S3-2: proof-carrying fixes (441 rules / 37 tools)
20
+ - **`secure_this` now returns a `proofTest`** when it applies fixes — a runnable regression test that proves the resolved findings stay fixed, using GuardVibe's deterministic scan as the oracle: it **fails on the vulnerable code and passes on the fixed code**. It's an honest scan-based proof (not an exploit test), and a real CI regression guard: drop it in the suite and the build breaks if the vuln is reintroduced.
21
+ - **CLI:** `guardvibe secure-this <file>` shows the proof test in markdown; `--emit-proof [path]` writes it (default `<file>.guardvibe.test.ts`). **MCP:** the `secure_this` result carries `proofTest` so agents can drop it into the project.
22
+ - Generated only when fixes were applied (nothing to prove for already-clean or non-auto-fixable code). New `node:test`-based template; 4 new tests. No rule or tool changes (441 / 37).
23
+
24
+ Gate green (build / lint / test / self-audit PASS / A / 0).
25
+
8
26
  ## [3.11.0] - 2026-06-07
9
27
 
10
28
  ### Changed — S3-1 (cont.): reachability-weighted dependency prioritization (441 rules / 37 tools)
package/README.md CHANGED
@@ -150,7 +150,8 @@ npx guardvibe hook uninstall # Remove hook
150
150
  ### CI/CD (GitHub Actions)
151
151
 
152
152
  ```bash
153
- npx guardvibe ci github # Generates .github/workflows/guardvibe.yml
153
+ npx guardvibe ci github # Generates .github/workflows/guardvibe.yml (SARIF scan)
154
+ npx guardvibe ci github --pr # + a diff-aware PR review workflow that posts inline comments
154
155
  ```
155
156
 
156
157
  ## What GuardVibe Scans
package/build/cli/ci.d.ts CHANGED
@@ -2,4 +2,11 @@
2
2
  * CLI: guardvibe ci <provider>
3
3
  * Generates CI/CD workflow configurations.
4
4
  */
5
+ /**
6
+ * PR-native, author-independent review workflow: on each PR, run a DIFF-AWARE scan
7
+ * (only issues newly introduced by the PR) and post them as inline review comments
8
+ * via actions/github-script — no extra runtime dependency. The moat made visible
9
+ * exactly where AI-written code lands.
10
+ */
11
+ export declare function buildGithubPrReviewWorkflow(version: string): string;
5
12
  export declare function runCi(args: string[]): void;
package/build/cli/ci.js CHANGED
@@ -45,6 +45,78 @@ jobs:
45
45
  category: guardvibe
46
46
  `;
47
47
  }
48
+ /**
49
+ * PR-native, author-independent review workflow: on each PR, run a DIFF-AWARE scan
50
+ * (only issues newly introduced by the PR) and post them as inline review comments
51
+ * via actions/github-script — no extra runtime dependency. The moat made visible
52
+ * exactly where AI-written code lands.
53
+ */
54
+ export function buildGithubPrReviewWorkflow(version) {
55
+ return `name: GuardVibe PR Review
56
+ # Pinned to guardvibe@${version}. Re-run \`npx guardvibe ci github --pr\` to upgrade.
57
+ # Diff-aware: comments only on issues this PR newly introduced (not pre-existing debt).
58
+
59
+ on:
60
+ pull_request:
61
+ branches: [main, master]
62
+
63
+ permissions:
64
+ contents: read
65
+ pull-requests: write
66
+
67
+ jobs:
68
+ guardvibe-pr-review:
69
+ name: GuardVibe PR Review
70
+ runs-on: ubuntu-latest
71
+ steps:
72
+ - uses: actions/checkout@v4
73
+ with:
74
+ fetch-depth: 0
75
+ persist-credentials: false
76
+
77
+ - uses: actions/setup-node@v4
78
+ with:
79
+ node-version: "22"
80
+
81
+ - name: GuardVibe diff-aware scan (newly-introduced issues only)
82
+ run: |
83
+ git fetch --no-tags --depth=1 origin "\${{ github.base_ref }}"
84
+ npx -y guardvibe@${version} diff "origin/\${{ github.base_ref }}" --format json --output gv-diff.json || true
85
+
86
+ - name: Post findings as PR review comments
87
+ uses: actions/github-script@v7
88
+ with:
89
+ script: |
90
+ const fs = require('fs');
91
+ let data;
92
+ try { data = JSON.parse(fs.readFileSync('gv-diff.json', 'utf8')); } catch (e) { return; }
93
+ const findings = (data.findings || []).filter(f => f.line > 0);
94
+ if (!findings.length) return;
95
+ const comments = findings.map(f => ({
96
+ path: f.file,
97
+ line: f.line,
98
+ body: '**GuardVibe ' + String(f.severity).toUpperCase() + ': ' + f.name + '** (' + f.id + ')\\n\\n' + (f.fix || '')
99
+ }));
100
+ const summary = 'GuardVibe found ' + findings.length + ' newly-introduced issue(s) in this PR.';
101
+ try {
102
+ await github.rest.pulls.createReview({
103
+ owner: context.repo.owner,
104
+ repo: context.repo.repo,
105
+ pull_number: context.issue.number,
106
+ event: 'COMMENT',
107
+ body: summary,
108
+ comments
109
+ });
110
+ } catch (e) {
111
+ await github.rest.issues.createComment({
112
+ owner: context.repo.owner,
113
+ repo: context.repo.repo,
114
+ issue_number: context.issue.number,
115
+ body: summary + ' (inline review unavailable: ' + e.message + ')'
116
+ });
117
+ }
118
+ `;
119
+ }
48
120
  /** Extract a pinned guardvibe version from a generated workflow YAML, or "latest"/null for legacy/unrecognized forms. */
49
121
  function extractPinnedVersionFromWorkflow(content) {
50
122
  const pinned = content.match(/guardvibe@(\d+\.\d+\.\d+(?:-[\w.]+)?)/);
@@ -85,14 +157,43 @@ function generateGitHubActions() {
85
157
  console.log(` [OK] Created .github/workflows/guardvibe.yml (pinned to v${pkg.version}).`);
86
158
  console.log(" [OK] SARIF results will appear in GitHub Security tab.");
87
159
  }
160
+ function generateGitHubPrReview() {
161
+ const workflowDir = join(process.cwd(), ".github", "workflows");
162
+ if (!existsSync(workflowDir))
163
+ mkdirSync(workflowDir, { recursive: true });
164
+ const workflowPath = join(workflowDir, "guardvibe-pr-review.yml");
165
+ const fresh = buildGithubPrReviewWorkflow(pkg.version);
166
+ if (existsSync(workflowPath)) {
167
+ const existingPin = extractPinnedVersionFromWorkflow(readFileSync(workflowPath, "utf-8"));
168
+ if (existingPin === pkg.version) {
169
+ console.log(` [OK] .github/workflows/guardvibe-pr-review.yml already up-to-date (pinned to v${pkg.version}).`);
170
+ return;
171
+ }
172
+ if (existingPin) {
173
+ writeFileSync(workflowPath, fresh, "utf-8");
174
+ console.log(` [OK] Updated .github/workflows/guardvibe-pr-review.yml (${existingPin} → ${pkg.version}).`);
175
+ return;
176
+ }
177
+ console.log(" [OK] .github/workflows/guardvibe-pr-review.yml exists with custom contents — leaving as-is.");
178
+ return;
179
+ }
180
+ writeFileSync(workflowPath, fresh, "utf-8");
181
+ console.log(` [OK] Created .github/workflows/guardvibe-pr-review.yml (pinned to v${pkg.version}).`);
182
+ console.log(" [OK] PRs will get inline, diff-aware GuardVibe review comments.");
183
+ }
88
184
  export function runCi(args) {
89
185
  const provider = args[0]?.toLowerCase();
186
+ const wantPr = args.includes("--pr");
90
187
  console.log(`\n GuardVibe CI/CD Setup\n`);
91
188
  if (provider === "github") {
92
189
  generateGitHubActions();
190
+ if (wantPr)
191
+ generateGitHubPrReview();
192
+ else
193
+ console.log(" [tip] Add --pr to also generate a diff-aware PR review workflow (inline comments).");
93
194
  }
94
195
  else {
95
- console.error(" [ERR] Unknown CI provider. Usage: npx guardvibe ci github");
196
+ console.error(" [ERR] Unknown CI provider. Usage: npx guardvibe ci github [--pr]");
96
197
  process.exit(1);
97
198
  }
98
199
  console.log();
@@ -56,6 +56,9 @@ function renderMarkdown(r, file, wrote) {
56
56
  lines.push(`> Wrote ${r.applied.length} verified fix(es) to ${file}.`, "");
57
57
  }
58
58
  lines.push(`**Definition of done:** ${r.definitionOfDone.passed ? "PASSED ✅" : "FAILED ❌"} — ${r.definitionOfDone.message}`);
59
+ if (r.proofTest) {
60
+ lines.push("", "## Regression proof test", "Run on the fixed file to prove it stays fixed (`--emit-proof <path>` to save it):", "", "```ts", r.proofTest.trimEnd(), "```");
61
+ }
59
62
  return lines.join("\n");
60
63
  }
61
64
  export async function runSecureThis(args) {
@@ -81,6 +84,13 @@ export async function runSecureThis(args) {
81
84
  if (write && result.changed) {
82
85
  writeFileSync(resolved, result.fixedCode, "utf-8");
83
86
  }
87
+ // --emit-proof [path]: write the regression proof test (default: <file>.guardvibe.test.ts).
88
+ const emitProof = flags["emit-proof"];
89
+ if (emitProof && result.proofTest) {
90
+ const proofPath = typeof emitProof === "string" ? resolve(emitProof) : `${resolved}.guardvibe.test.ts`;
91
+ writeFileSync(proofPath, result.proofTest, "utf-8");
92
+ console.log(` [OK] Proof test written to ${proofPath}`);
93
+ }
84
94
  const format = flags.format === "json" ? "json" : "markdown";
85
95
  if (format === "json") {
86
96
  console.log(JSON.stringify({ ...result, file: resolved, wrote: write && result.changed }));
package/build/cli.js CHANGED
@@ -37,7 +37,7 @@ function printUsage() {
37
37
  npx guardvibe init <platform> Setup MCP server configuration
38
38
  npx guardvibe hook install Install pre-commit security hook
39
39
  npx guardvibe hook uninstall Remove pre-commit security hook
40
- npx guardvibe ci github Generate GitHub Actions workflow
40
+ npx guardvibe ci github [--pr] Generate GitHub Actions workflow (--pr: diff-aware PR review with inline comments)
41
41
 
42
42
  Scan CLI (used by pre-commit hook and CI):
43
43
  npx guardvibe-scan Scan git-staged files
package/build/index.js CHANGED
@@ -319,7 +319,7 @@ server.tool("fix_code", "Pass vulnerable code as a string and get fix suggestion
319
319
  };
320
320
  });
321
321
  // Tool 37: secure_this — close the loop (scan → apply verified fix → re-verify)
322
- 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'})", {
322
+ 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}, proofTest }. Write fixedCode to disk, then require definitionOfDone.passed before claiming the task complete; anything in remaining[] needs a manual fix. When fixes were applied, proofTest is a runnable regression test (GuardVibe-as-oracle) you can drop into the project to guard against regressions. Example: secure_this({code: '...', language: 'typescript'})", {
323
323
  code: z.string().describe("The code to scan and secure"),
324
324
  language: z
325
325
  .enum(["javascript", "typescript", "python", "go", "dockerfile", "html", "sql", "shell", "yaml", "terraform", "firestore"])
@@ -31,6 +31,12 @@ export interface SecureThisResult {
31
31
  passed: boolean;
32
32
  message: string;
33
33
  };
34
+ /**
35
+ * A runnable regression test that proves the resolved findings stay fixed.
36
+ * Deterministic scan-based proof (GuardVibe is the oracle): run on the vulnerable
37
+ * code it fails, on the fixed code it passes. Present only when fixes were applied.
38
+ */
39
+ proofTest?: string;
34
40
  }
35
41
  export interface SecureThisOptions {
36
42
  framework?: string;
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "guardvibe",
3
- "version": "3.11.0",
3
+ "version": "3.13.0",
4
4
  "mcpName": "io.github.goklab/guardvibe",
5
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. 441 rules, 37 tools, CLI + doctor. Host security, auth coverage mapping, LLM-powered deep scan (IDOR/business logic), taint analysis. 70 CVE rules refreshed daily from GHSA/OSV/CISA KEV — React Router 7 cluster, DOMPurify XSS, Better Auth bypass, 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",