@clear-capabilities/agentic-security-scanner 0.127.0 → 0.130.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.
Files changed (88) hide show
  1. package/CHANGELOG.md +161 -0
  2. package/bin/agentic-security.js +33 -0
  3. package/dist/11.index.js +353 -0
  4. package/dist/113.index.js +727 -0
  5. package/dist/178.index.js +1 -1
  6. package/dist/207.index.js +217 -0
  7. package/dist/384.index.js +1 -1
  8. package/dist/415.index.js +1 -1
  9. package/dist/435.index.js +19 -8
  10. package/dist/526.index.js +555 -0
  11. package/dist/637.index.js +1 -1
  12. package/dist/826.index.js +4 -1
  13. package/dist/830.index.js +1 -1
  14. package/dist/agentic-security.mjs +113 -163
  15. package/dist/agentic-security.mjs.sha256 +1 -1
  16. package/package.json +23 -15
  17. package/src/dataflow/CLAUDE.md +4 -1
  18. package/src/dataflow/async-sequencing.js +8 -3
  19. package/src/dataflow/catalog.js +278 -11
  20. package/src/dataflow/cross-repo.js +1 -1
  21. package/src/dataflow/cross-service-taint.js +1 -1
  22. package/src/dataflow/engine.js +182 -61
  23. package/src/dataflow/ifds.js +10 -5
  24. package/src/dataflow/index.js +15 -3
  25. package/src/dataflow/points-to.js +8 -2
  26. package/src/dataflow/proof-gate.js +7 -0
  27. package/src/dataflow/sanitizer-gate.js +89 -0
  28. package/src/dataflow/tabulation.js +14 -3
  29. package/src/engine.js +181 -8
  30. package/src/integrations/index.js +1 -1
  31. package/src/integrations/tickets.js +9 -3
  32. package/src/ir/CLAUDE.md +49 -4
  33. package/src/ir/call-sites.js +66 -0
  34. package/src/ir/callgraph.js +174 -7
  35. package/src/ir/class-hierarchy.js +22 -2
  36. package/src/ir/index.js +138 -51
  37. package/src/ir/ir-stats.js +126 -0
  38. package/src/ir/parser-cpp.js +829 -0
  39. package/src/ir/parser-cs.js +4 -1
  40. package/src/ir/parser-go.js +4 -1
  41. package/src/ir/parser-js.js +5 -1
  42. package/src/ir/parser-kt.js +4 -1
  43. package/src/ir/parser-php.js +10 -3
  44. package/src/ir/parser-py-cst.js +62 -10
  45. package/src/ir/tree-sitter-loader.js +13 -1
  46. package/src/llm-validator/index.js +9 -2
  47. package/src/llm-validator/redact.js +157 -0
  48. package/src/mcp/tools.js +17 -6
  49. package/src/posture/CLAUDE.md +122 -0
  50. package/src/posture/accuracy-scorecard.js +317 -0
  51. package/src/posture/api-contract.js +1 -1
  52. package/src/posture/attestation.js +199 -0
  53. package/src/posture/auditor-walkthrough.js +12 -3
  54. package/src/posture/compliance-policy.js +1 -1
  55. package/src/posture/cross-lang-openapi.js +1 -1
  56. package/src/posture/custom-rules.js +1 -1
  57. package/src/posture/entrypoint-inventory.js +248 -0
  58. package/src/posture/execution-proof.js +52 -0
  59. package/src/posture/exploitability-probability.js +1 -1
  60. package/src/posture/falsification.js +165 -0
  61. package/src/posture/fix-honesty-gate.js +175 -0
  62. package/src/posture/fix-verify.js +71 -3
  63. package/src/posture/license-policy.js +1 -1
  64. package/src/posture/model-routing.js +126 -0
  65. package/src/posture/profile.js +1 -1
  66. package/src/posture/proof-tier.js +33 -0
  67. package/src/posture/relevance.js +379 -0
  68. package/src/posture/root-cause-sweep.js +262 -0
  69. package/src/posture/rule-overrides.js +1 -1
  70. package/src/posture/sca-policy.js +1 -1
  71. package/src/posture/scan-checkpoint.js +277 -0
  72. package/src/posture/suppressions.js +1 -1
  73. package/src/posture/test-runner.js +147 -0
  74. package/src/posture/verification-separation.js +131 -0
  75. package/src/pr-comment.js +3 -1
  76. package/src/report/index.js +11 -0
  77. package/src/runScan.js +3 -1
  78. package/src/sandbox/CLAUDE.md +218 -0
  79. package/src/sandbox/backend-disabled.js +14 -0
  80. package/src/sandbox/backend-namespace.js +83 -0
  81. package/src/sandbox/backend-userspace.js +100 -0
  82. package/src/sandbox/capabilities.js +53 -0
  83. package/src/sandbox/index.js +30 -0
  84. package/src/sandbox/limits.js +42 -0
  85. package/src/sandbox/result.js +104 -0
  86. package/src/sca/dep-confusion.js +1 -1
  87. package/src/util/untrusted.js +148 -0
  88. package/src/util/yaml.js +24 -0
@@ -0,0 +1,555 @@
1
+ export const id = 526;
2
+ export const ids = [526];
3
+ export const modules = {
4
+
5
+ /***/ 3526:
6
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7
+
8
+ // ESM COMPAT FLAG
9
+ __webpack_require__.r(__webpack_exports__);
10
+
11
+ // EXPORTS
12
+ __webpack_require__.d(__webpack_exports__, {
13
+ runProjectLinter: () => (/* binding */ runProjectLinter),
14
+ verifyFix: () => (/* binding */ verifyFix),
15
+ verifyPatch: () => (/* binding */ verifyPatch)
16
+ });
17
+
18
+ // EXTERNAL MODULE: external "node:child_process"
19
+ var external_node_child_process_ = __webpack_require__(1421);
20
+ // EXTERNAL MODULE: external "node:fs"
21
+ var external_node_fs_ = __webpack_require__(3024);
22
+ // EXTERNAL MODULE: external "node:path"
23
+ var external_node_path_ = __webpack_require__(6760);
24
+ // EXTERNAL MODULE: ./src/engine.js + 595 modules
25
+ var engine = __webpack_require__(4660);
26
+ ;// CONCATENATED MODULE: ./src/posture/fix-honesty-gate.js
27
+ // Deterministic honesty gates on fix / finding output (#7).
28
+ //
29
+ // The project's verification discipline (scanner/CLAUDE.md) exists because
30
+ // several releases shipped broken or false because work was reported as done
31
+ // without confirming the artifact changed. Two of those failure modes are
32
+ // *textual* — they live in the prose an agent emits alongside a fix — and can
33
+ // be caught deterministically, with no LLM and no network:
34
+ //
35
+ // 1. Hand-wave residual-risk prose. "The input is adequately handled",
36
+ // "future work", "tbd", "later" — vague assurances that claim safety
37
+ // without naming a concrete remaining vector. A residual you can't name
38
+ // is a residual you're guessing about; reject the guess.
39
+ //
40
+ // 2. An unbacked "this is a false positive / provably safe" verdict. Marking
41
+ // a finding safe is a coverage *reduction* — it must cite a `file:line`
42
+ // that shows why, exactly like the rules-override gate refuses to silently
43
+ // shrink coverage.
44
+ //
45
+ // Plus a conservative fix-tier classifier so a partial remediation can never be
46
+ // labelled FULL: any workaround-only signal (rate-limit, docs, log-without-
47
+ // reject) is WORKAROUND; anything short of (sink signature changed + all callers
48
+ // routed + a discriminating test) is at most MITIGATION; only the full set with
49
+ // no partial-sanitization caveat earns FULL.
50
+ //
51
+ // Pure functions, no side effects, no throwing — safe to call from a command,
52
+ // a hook, or the MCP verify_fix path.
53
+
54
+ // Vague-assurance phrases that a real residual must never hide behind. Matched
55
+ // case-insensitively with word boundaries so "later" doesn't trip on
56
+ // "collateral" and "tbd" doesn't trip on a longer token.
57
+ const BANNED_RESIDUAL_PHRASES = Object.freeze([
58
+ 'adequately handled',
59
+ 'adequately handles',
60
+ 'properly validated',
61
+ 'properly handled',
62
+ 'handled properly',
63
+ 'handled safely',
64
+ 'future work',
65
+ 'more work needed',
66
+ 'to be done',
67
+ 'tbd',
68
+ 'later',
69
+ ]);
70
+
71
+ // A citation shaped like `file:line` — one or more non-space, non-colon chars,
72
+ // a colon, then digits. Unanchored: it need only appear somewhere in the item.
73
+ const CITATION_RE = /[^\s:]+:\d+/;
74
+
75
+ // Verdicts that assert the finding is not real and therefore demand a citation.
76
+ // Compared after normalizing separators (`_`/space → `-`) and lowercasing, so
77
+ // FALSE_POSITIVE, false-positive, and "provably safe" all land here.
78
+ const FP_VERDICTS = Object.freeze(new Set(['false-positive', 'provably-safe', 'safe']));
79
+
80
+ function _escapeRe(s) {
81
+ return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
82
+ }
83
+
84
+ /**
85
+ * Reject vague-assurance / hand-wave residual-risk prose.
86
+ *
87
+ * An empty or whitespace-only residual is ok — there is no residual to lie
88
+ * about. A non-empty residual is rejected when it contains any banned phrase;
89
+ * each match yields one violation naming the offending phrase.
90
+ *
91
+ * @param {string} residualText
92
+ * @returns {{ ok: boolean, violations: string[] }}
93
+ */
94
+ function checkResidualHonesty(residualText) {
95
+ const text = typeof residualText === 'string' ? residualText : '';
96
+ if (text.trim() === '') return { ok: true, violations: [] };
97
+
98
+ const violations = [];
99
+ for (const phrase of BANNED_RESIDUAL_PHRASES) {
100
+ const re = new RegExp(`\\b${_escapeRe(phrase)}\\b`, 'i');
101
+ if (re.test(text)) {
102
+ violations.push(`vague-assurance phrase: "${phrase}"`);
103
+ }
104
+ }
105
+ return { ok: violations.length === 0, violations };
106
+ }
107
+
108
+ function _isCitation(item) {
109
+ if (typeof item === 'string') return CITATION_RE.test(item);
110
+ if (item && typeof item === 'object' && typeof item.location === 'string') {
111
+ return CITATION_RE.test(item.location);
112
+ }
113
+ return false;
114
+ }
115
+
116
+ function _normalizeVerdict(verdict) {
117
+ return String(verdict).trim().toLowerCase().replace(/[_\s]+/g, '-');
118
+ }
119
+
120
+ /**
121
+ * Require a file:line citation behind a "this is not real" verdict.
122
+ *
123
+ * For a false-positive / provably-safe / safe verdict (case-insensitive; also
124
+ * accepts FALSE_POSITIVE), at least one evidence item must be a `file:line`
125
+ * citation — either a string matching /[^\s:]+:\d+/ or an object
126
+ * `{ location: "file:line" }`. Any other verdict passes unconditionally.
127
+ *
128
+ * @param {string} verdict
129
+ * @param {Array|string|object} evidence
130
+ * @returns {{ ok: boolean, violations: string[] }}
131
+ */
132
+ function requireCitedEvidence(verdict, evidence) {
133
+ if (typeof verdict !== 'string' || !FP_VERDICTS.has(_normalizeVerdict(verdict))) {
134
+ return { ok: true, violations: [] };
135
+ }
136
+ const items = Array.isArray(evidence)
137
+ ? evidence
138
+ : evidence == null
139
+ ? []
140
+ : [evidence];
141
+ if (items.some(_isCitation)) return { ok: true, violations: [] };
142
+ return {
143
+ ok: false,
144
+ violations: ['false-positive/safe verdict requires a file:line citation'],
145
+ };
146
+ }
147
+
148
+ /**
149
+ * Classify a fix into FULL | MITIGATION | WORKAROUND, conservative-first.
150
+ *
151
+ * @param {object} signals
152
+ * @param {boolean} signals.sinkSignatureChanged
153
+ * @param {boolean} signals.allCallersRouted
154
+ * @param {boolean} signals.testDiscriminates - a test that fails pre-fix, passes post-fix
155
+ * @param {boolean} [signals.rateLimitOnly]
156
+ * @param {boolean} [signals.docsOnly]
157
+ * @param {boolean} [signals.logOnlyNoReject]
158
+ * @param {boolean} [signals.partialSanitization]
159
+ * @returns {'FULL'|'MITIGATION'|'WORKAROUND'}
160
+ */
161
+ function computeFixTier(signals) {
162
+ const s = signals && typeof signals === 'object' ? signals : {};
163
+ if (s.rateLimitOnly || s.docsOnly || s.logOnlyNoReject) return 'WORKAROUND';
164
+ const complete = s.sinkSignatureChanged && s.allCallersRouted && s.testDiscriminates;
165
+ if (s.partialSanitization || !complete) return 'MITIGATION';
166
+ return 'FULL';
167
+ }
168
+
169
+ /**
170
+ * Compose the three gates for a single fix's output.
171
+ *
172
+ * ok = residual-honesty ok AND evidence-citation ok, further constrained by the
173
+ * tier/residual consistency invariant:
174
+ * - a FULL tier must NOT carry a residual (a full fix has nothing left);
175
+ * - a non-FULL tier MUST document a residual (say what's still open).
176
+ *
177
+ * @param {{ residual?: string, verdict?: string, evidence?: any, signals?: object }} input
178
+ * @returns {{ ok: boolean, tier: string, violations: string[] }}
179
+ */
180
+ function gateFixOutput({ residual, verdict, evidence, signals } = {}) {
181
+ const tier = computeFixTier(signals);
182
+ const residualCheck = checkResidualHonesty(residual);
183
+ const evidenceCheck = requireCitedEvidence(verdict, evidence);
184
+
185
+ const violations = [...residualCheck.violations, ...evidenceCheck.violations];
186
+ let ok = residualCheck.ok && evidenceCheck.ok;
187
+
188
+ const residualEmpty = typeof residual !== 'string' || residual.trim() === '';
189
+ if (tier === 'FULL' && !residualEmpty) {
190
+ violations.push('FULL tier cannot carry a residual');
191
+ ok = false;
192
+ }
193
+ if (tier !== 'FULL' && residualEmpty) {
194
+ violations.push('non-FULL tier must document a residual');
195
+ ok = false;
196
+ }
197
+
198
+ return { ok, tier, violations };
199
+ }
200
+
201
+ const _internals = Object.freeze({ BANNED_RESIDUAL_PHRASES, CITATION_RE, FP_VERDICTS });
202
+
203
+ ;// CONCATENATED MODULE: ./src/posture/test-runner.js
204
+ // R5 (partial, roadmap) — the project's own test suite as a verification
205
+ // stage for `verifyFix()` (see `fix-verify.js`). Closes the gap where a
206
+ // "verified" fix only proved a finding's stableId stopped firing — a patch
207
+ // that deletes the feature entirely would satisfy that just as well as a
208
+ // real fix. Running the project's own tests is the cheapest available check
209
+ // that the application still works.
210
+ //
211
+ // Execution-safety note: this spawns the TARGET PROJECT's own test command
212
+ // in the target project's own directory. That is deliberately NOT routed
213
+ // through the R1 confinement sandbox (`../sandbox/`). That sandbox exists to
214
+ // contain untrusted proof-of-concept exploit code the scanner itself
215
+ // synthesizes — code nobody has vetted, being run for the first time. A
216
+ // project's pre-existing test suite is the opposite case: it is the
217
+ // project's own trusted source, already sitting on disk, and running it is
218
+ // exactly what a human developer does by hand before trusting a fix.
219
+ // Wrapping "npm test" / "pytest" / "go test" in the PoC sandbox's
220
+ // syscall/network/filesystem restrictions would break the large majority of
221
+ // real test suites (they bind local ports, spawn child processes, write temp
222
+ // fixtures, etc.) for no corresponding security benefit.
223
+
224
+
225
+
226
+
227
+
228
+ const DEFAULT_TIMEOUT_MS = 300_000;
229
+ const NPM_PLACEHOLDER = /Error: no test specified/i;
230
+
231
+ function _exists(scanRoot, rel) {
232
+ try { return external_node_fs_.existsSync(external_node_path_.join(scanRoot, rel)); } catch { return false; }
233
+ }
234
+
235
+ function _isDir(scanRoot, rel) {
236
+ try { return external_node_fs_.statSync(external_node_path_.join(scanRoot, rel)).isDirectory(); } catch { return false; }
237
+ }
238
+
239
+ function _binaryAvailable(cmd) {
240
+ try {
241
+ const r = (0,external_node_child_process_.spawnSync)(cmd, ['--version'], { timeout: 5_000, stdio: 'ignore' });
242
+ return !(r.error && r.error.code === 'ENOENT');
243
+ } catch {
244
+ return false;
245
+ }
246
+ }
247
+
248
+ // Detect the project's test command. Read-only — never spawns the actual
249
+ // test run, only (optionally) a cheap `--version` probe to confirm a tool
250
+ // like `pytest` is actually installed before committing to it. Returns
251
+ // `null` when nothing detectable is found — most scanned repos will hit
252
+ // this path, and that must not be treated as a failure by callers.
253
+ function detectTestCommand(scanRoot) {
254
+ if (!scanRoot) return null;
255
+
256
+ // JS/TS — package.json with a real (non-placeholder) `scripts.test`.
257
+ let pkg = null;
258
+ try { pkg = JSON.parse(external_node_fs_.readFileSync(external_node_path_.join(scanRoot, 'package.json'), 'utf8')); } catch { pkg = null; }
259
+ const testScript = pkg && pkg.scripts && pkg.scripts.test;
260
+ if (testScript && !NPM_PLACEHOLDER.test(String(testScript))) {
261
+ if (_exists(scanRoot, 'pnpm-lock.yaml')) return { cmd: 'pnpm', args: ['test'], kind: 'pnpm' };
262
+ if (_exists(scanRoot, 'yarn.lock')) return { cmd: 'yarn', args: ['test'], kind: 'yarn' };
263
+ if (_exists(scanRoot, 'bun.lockb') || _exists(scanRoot, 'bun.lock')) return { cmd: 'bun', args: ['test'], kind: 'bun' };
264
+ return { cmd: 'npm', args: ['test', '--silent'], kind: 'npm' };
265
+ }
266
+
267
+ // Python — pytest.ini / pyproject.toml / tox.ini / a tests/ dir, and the
268
+ // `pytest` binary actually available. If pytest isn't installed we do NOT
269
+ // report a python test command — falling through lets a later language
270
+ // marker (e.g. go.mod in a polyglot repo) still be detected.
271
+ const pyMarker = _exists(scanRoot, 'pytest.ini') || _exists(scanRoot, 'pyproject.toml') ||
272
+ _exists(scanRoot, 'tox.ini') || _isDir(scanRoot, 'tests');
273
+ if (pyMarker && _binaryAvailable('pytest')) {
274
+ return { cmd: 'pytest', args: ['-q'], kind: 'pytest' };
275
+ }
276
+
277
+ // Go
278
+ if (_exists(scanRoot, 'go.mod')) {
279
+ return { cmd: 'go', args: ['test', './...'], kind: 'go' };
280
+ }
281
+
282
+ return null;
283
+ }
284
+
285
+ // Run the detected test command with a walltime budget. Always returns a
286
+ // result object — never throws. Distinguishes four outcomes:
287
+ // - no detectable/runnable command -> status: 'skipped' (does NOT fail)
288
+ // - ran and exited 0 -> status: 'passed'
289
+ // - ran and exited non-zero -> status: 'failed'
290
+ // - ran past the timeout budget -> status: 'failed', timedOut: true
291
+ function runProjectTests(scanRoot, { timeoutMs = DEFAULT_TIMEOUT_MS } = {}) {
292
+ const startedAt = Date.now();
293
+ const command = detectTestCommand(scanRoot);
294
+ if (!command) {
295
+ return {
296
+ status: 'skipped', passed: null, skipped: true,
297
+ reason: 'no-test-command-detected', exitCode: null, timedOut: false,
298
+ durationMs: Date.now() - startedAt,
299
+ };
300
+ }
301
+
302
+ let r;
303
+ try {
304
+ r = (0,external_node_child_process_.spawnSync)(command.cmd, command.args, {
305
+ cwd: scanRoot,
306
+ encoding: 'utf8',
307
+ timeout: timeoutMs,
308
+ env: { ...process.env, CI: '1' },
309
+ });
310
+ } catch (e) {
311
+ // The spawn call itself threw (rare — e.g. cwd vanished). Treat as
312
+ // "could not run", not "ran and failed".
313
+ return {
314
+ status: 'skipped', passed: null, skipped: true,
315
+ reason: `spawn-error: ${e.message}`, exitCode: null, timedOut: false,
316
+ durationMs: Date.now() - startedAt,
317
+ };
318
+ }
319
+ const durationMs = Date.now() - startedAt;
320
+
321
+ if (r.error && r.error.code === 'ENOENT') {
322
+ // The detected tool isn't actually installed on this machine. Not a
323
+ // test failure — the suite never ran.
324
+ return {
325
+ status: 'skipped', passed: null, skipped: true,
326
+ reason: `${command.kind}-not-installed`, exitCode: null, timedOut: false, durationMs,
327
+ };
328
+ }
329
+
330
+ if (r.status === null) {
331
+ // spawnSync sets status:null both on timeout-kill and on being killed by
332
+ // another signal; either way the run did not complete, which is a
333
+ // verification failure, never a skip — we asked for a result and the
334
+ // process was terminated before producing one.
335
+ return {
336
+ status: 'failed', passed: false, skipped: false,
337
+ reason: 'timed-out', exitCode: null, timedOut: true, durationMs,
338
+ };
339
+ }
340
+
341
+ return {
342
+ status: r.status === 0 ? 'passed' : 'failed',
343
+ passed: r.status === 0,
344
+ skipped: false,
345
+ reason: r.status === 0 ? null : 'test-failures',
346
+ exitCode: r.status,
347
+ timedOut: false,
348
+ durationMs,
349
+ };
350
+ }
351
+
352
+ ;// CONCATENATED MODULE: ./src/posture/fix-verify.js
353
+ // Closed-loop /fix verification (Sentinel-parity FR-L4-4, FR-L4-5).
354
+ //
355
+ // Given a candidate patch (the new file content + the finding stableId being
356
+ // fixed), verify it:
357
+ //
358
+ // 1. The original finding's stableId no longer fires on the patched file.
359
+ // 2. No new findings at severity ≥ medium were introduced by the patch.
360
+ // 3. The project's existing linter (when present) passes on the patched file.
361
+ // 4. The project's own test suite (when detectable) still passes. This is
362
+ // the R5 gap-closer: a patch that silently deletes the feature would
363
+ // satisfy (1) and (2) just as well as a real fix — only running the
364
+ // tests catches that. See `test-runner.js` for detection + execution.
365
+ //
366
+ // If any of those fail, the caller is expected to NOT apply the patch and
367
+ // instead surface a "fix plan" — a numbered list of steps the engineer can
368
+ // follow — rather than dump a broken patch on the user.
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+ const SEVERITY_RANK = { critical: 0, high: 1, medium: 2, low: 3, info: 4 };
378
+
379
+ // Run a focused re-scan over just the patched file(s) using the in-memory
380
+ // engine. No filesystem write needed — we hand the new content in via the
381
+ // fileContents map.
382
+ async function verifyPatch({
383
+ scanRoot,
384
+ originalFindingStableId,
385
+ files, // { [relPath]: newContent }
386
+ depFileContents = {},
387
+ } = {}) {
388
+ if (!files || typeof files !== 'object') return { ok: false, reason: 'no-files-provided' };
389
+ const fileContents = { ...files };
390
+ let scan;
391
+ try {
392
+ scan = await (0,engine/* runFullScan */.wW)({ fileContents, depFileContents, scanRoot }, () => {});
393
+ } catch (e) {
394
+ return { ok: false, reason: 'rescan-failed', error: e.message };
395
+ }
396
+ const findings = (scan && scan.findings) || [];
397
+ const stillHasOriginal = !!originalFindingStableId &&
398
+ findings.some(f => f.stableId === originalFindingStableId);
399
+ if (stillHasOriginal) {
400
+ return { ok: false, reason: 'original-finding-still-present', stableId: originalFindingStableId };
401
+ }
402
+ const introducedHighOrAbove = findings.filter(f =>
403
+ (SEVERITY_RANK[f.severity] ?? 9) <= SEVERITY_RANK.medium);
404
+ // Don't count findings on lines outside the patched files — but our
405
+ // fileContents map IS the patched files, so every finding is in-scope.
406
+ return {
407
+ ok: introducedHighOrAbove.length === 0,
408
+ reason: introducedHighOrAbove.length === 0 ? 'verified' : 'introduced-new-findings',
409
+ introduced: introducedHighOrAbove.map(f => ({
410
+ vuln: f.vuln, file: f.file, line: f.line, severity: f.severity,
411
+ stableId: f.stableId,
412
+ })),
413
+ };
414
+ }
415
+
416
+ // Detect which linter the project uses and run it on the patched files.
417
+ // Returns { ok, runner, output } or { ok: true, runner: 'none' } when no
418
+ // linter is configured (silent pass).
419
+ function runProjectLinter(scanRoot, filePaths) {
420
+ if (!scanRoot || !Array.isArray(filePaths) || filePaths.length === 0) {
421
+ return { ok: true, runner: 'none' };
422
+ }
423
+ const has = (p) => { try { return external_node_fs_.existsSync(external_node_path_.join(scanRoot, p)); } catch { return false; } };
424
+ // Pick the linter by config file present in the repo root.
425
+ const jsFiles = filePaths.filter(f => /\.(?:js|jsx|ts|tsx|mjs|cjs)$/i.test(f));
426
+ const pyFiles = filePaths.filter(f => /\.py$/i.test(f));
427
+ const goFiles = filePaths.filter(f => /\.go$/i.test(f));
428
+ const javaFiles = filePaths.filter(f => /\.java$/i.test(f));
429
+
430
+ if (jsFiles.length && (has('.eslintrc') || has('.eslintrc.json') || has('.eslintrc.js') || has('eslint.config.js') || has('eslint.config.mjs'))) {
431
+ return runLinter(scanRoot, 'eslint', ['--no-error-on-unmatched-pattern', ...jsFiles]);
432
+ }
433
+ if (pyFiles.length && (has('pyproject.toml') || has('ruff.toml') || has('.ruff.toml'))) {
434
+ return runLinter(scanRoot, 'ruff', ['check', ...pyFiles]);
435
+ }
436
+ if (pyFiles.length && has('.flake8')) {
437
+ return runLinter(scanRoot, 'flake8', pyFiles);
438
+ }
439
+ if (goFiles.length && (has('.golangci.yml') || has('.golangci.yaml'))) {
440
+ return runLinter(scanRoot, 'golangci-lint', ['run', ...goFiles]);
441
+ }
442
+ if (javaFiles.length && has('checkstyle.xml')) {
443
+ return runLinter(scanRoot, 'checkstyle', ['-c', 'checkstyle.xml', ...javaFiles]);
444
+ }
445
+ return { ok: true, runner: 'none' };
446
+ }
447
+
448
+ function runLinter(cwd, cmd, args) {
449
+ let r;
450
+ try {
451
+ r = (0,external_node_child_process_.spawnSync)(cmd, args, { cwd, encoding: 'utf8', timeout: 60_000 });
452
+ } catch (e) {
453
+ return { ok: true, runner: cmd, skipped: true, reason: 'binary-missing', error: e.message };
454
+ }
455
+ if (r.error && r.error.code === 'ENOENT') {
456
+ return { ok: true, runner: cmd, skipped: true, reason: 'binary-missing' };
457
+ }
458
+ if (r.status === null) {
459
+ return { ok: false, runner: cmd, reason: 'timed-out', output: (r.stderr || r.stdout || '').slice(-2000) };
460
+ }
461
+ return {
462
+ ok: r.status === 0,
463
+ runner: cmd,
464
+ exitCode: r.status,
465
+ output: ((r.stderr || '') + (r.stdout || '')).slice(-2000),
466
+ };
467
+ }
468
+
469
+ // Top-level verify: re-scan + lint. Returns the combined verdict + a
470
+ // human-readable summary string suitable for surfacing to the user.
471
+ // Addition #7 — deterministic honesty gates on fix output. When the caller
472
+ // supplies `fixMeta` ({ residual, verdict, evidence, signals }) — e.g. the
473
+ // security-fixer agent's residual-risk text + completeness signals — the fix's
474
+ // claims are checked mechanically (no hand-wave residual prose, a cited
475
+ // file:line for any FP/safe verdict, and a FULL/MITIGATION/WORKAROUND tier). A
476
+ // dishonest or over-claiming fix fails the gate. When `fixMeta` is absent
477
+ // (the deterministic MCP write path, which has no claims to check) the honesty
478
+ // gate is skipped and behavior is unchanged.
479
+ // R5 (partial) — the test-suite stage. Runs the target project's own tests,
480
+ // in the target project's own directory, against whatever is currently on
481
+ // disk there. See `test-runner.js`'s header comment for why that run is
482
+ // deliberately NOT routed through the R1 PoC-confinement sandbox: this is
483
+ // the project's own already-trusted suite, not untrusted synthesized code.
484
+ //
485
+ // Caveat that matters for callers: `verifyPatch` above re-scans the
486
+ // candidate patch purely in memory (no write to disk), but a test runner
487
+ // needs real files — there is no cheap way to hand a runner an in-memory
488
+ // overlay. So this leg reports on the CURRENT on-disk tree, not the
489
+ // candidate `files` map, when `verifyFix` is used as a pre-write preview
490
+ // (e.g. the `verify_fix` MCP tool). Callers that apply the patch first and
491
+ // then re-verify get the strongest signal; that ordering is not enforced
492
+ // here — it's the caller's responsibility, same as it already is for the
493
+ // closed-loop `fix-verify-loop.js` path.
494
+ // Does the caller's candidate patch differ from what is on disk right now?
495
+ // If so, any test run necessarily exercised the pre-patch tree. Compared by
496
+ // content so a patch that happens to match disk (already applied) is correctly
497
+ // treated as NOT pre-patch.
498
+ function _candidateDiffersFromDisk(scanRoot, files) {
499
+ if (!files || typeof files !== 'object') return false;
500
+ for (const [rel, content] of Object.entries(files)) {
501
+ if (typeof content !== 'string') continue;
502
+ try {
503
+ const abs = external_node_path_.resolve(scanRoot, rel);
504
+ if (external_node_fs_.readFileSync(abs, 'utf8') !== content) return true;
505
+ } catch {
506
+ return true; // candidate file absent on disk -> definitely not applied
507
+ }
508
+ }
509
+ return false;
510
+ }
511
+
512
+ async function verifyFix({
513
+ scanRoot,
514
+ originalFindingStableId,
515
+ files,
516
+ depFileContents,
517
+ fixMeta,
518
+ testTimeoutMs,
519
+ } = {}) {
520
+ const rescan = await verifyPatch({ scanRoot, originalFindingStableId, files, depFileContents });
521
+ const lint = runProjectLinter(scanRoot, Object.keys(files || {}));
522
+ const tests = runProjectTests(scanRoot, testTimeoutMs != null ? { timeoutMs: testTimeoutMs } : {});
523
+ // True when a candidate patch was supplied but has not been written, so the
524
+ // suite necessarily ran against the pre-patch tree. Surfaced in the summary
525
+ // and on the result so a caller cannot mistake it for a verified patch.
526
+ const _testedPrePatch = !tests.skipped && _candidateDiffersFromDisk(scanRoot, files);
527
+ const testsOk = tests.skipped ? true : tests.passed === true;
528
+ let honesty = null;
529
+ if (fixMeta && typeof fixMeta === 'object') {
530
+ try { honesty = gateFixOutput(fixMeta); } catch { honesty = null; }
531
+ }
532
+ const ok = rescan.ok && (lint.ok || lint.skipped) && testsOk && (honesty ? honesty.ok : true);
533
+ const summary = [
534
+ `re-scan: ${rescan.ok ? 'PASS' : 'FAIL — ' + rescan.reason}`,
535
+ `linter: ${lint.runner === 'none' ? 'skipped (no linter config)'
536
+ : lint.skipped ? `${lint.runner} not installed`
537
+ : lint.ok ? `${lint.runner} PASS`
538
+ : `${lint.runner} FAIL (exit ${lint.exitCode})`}`,
539
+ // Say which tree the suite actually ran against. `files` is a candidate
540
+ // patch held in memory; the runner needs real files, so it sees whatever is
541
+ // on disk. Reporting a bare "PASS" here would let a caller believe the
542
+ // PATCH passed the tests when the suite may have run on unpatched code.
543
+ `tests: ${tests.skipped ? `skipped (${tests.reason})`
544
+ : tests.timedOut ? 'FAIL (timed out)'
545
+ : tests.passed ? `PASS${_testedPrePatch ? ' — on the CURRENT on-disk tree, NOT the candidate patch' : ''}`
546
+ : `FAIL (exit ${tests.exitCode})`}`,
547
+ honesty ? `honesty: ${honesty.ok ? `PASS (${honesty.tier})` : 'FAIL — ' + honesty.violations.join('; ')}` : null,
548
+ ].filter(Boolean).join('\n');
549
+ return { ok, rescan, lint, tests, testedPrePatch: _testedPrePatch, honesty, summary };
550
+ }
551
+
552
+
553
+ /***/ })
554
+
555
+ };
package/dist/637.index.js CHANGED
@@ -11,7 +11,7 @@ export const modules = {
11
11
  /* harmony export */ renderPrDeltaText: () => (/* binding */ renderPrDeltaText)
12
12
  /* harmony export */ });
13
13
  /* harmony import */ var node_child_process__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1421);
14
- /* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3793);
14
+ /* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4660);
15
15
  // Shadowscan / security-DELTA on PR (v0.72).
16
16
  //
17
17
  // Most SAST PR-comment integrations show absolute counts — "12 findings
package/dist/826.index.js CHANGED
@@ -9,6 +9,7 @@ export const modules = {
9
9
  /* harmony export */ renderPrComment: () => (/* binding */ renderPrComment)
10
10
  /* harmony export */ });
11
11
  /* unused harmony export _internal */
12
+ /* harmony import */ var _util_untrusted_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7097);
12
13
  // Advisor-tone PR comment renderer (v0.72).
13
14
  //
14
15
  // Replaces the typical "12 findings detected, see SARIF" wall of text
@@ -36,6 +37,8 @@ export const modules = {
36
37
  // route through an LLM for richer prose when AGENTIC_SECURITY_LLM_ENDPOINT
37
38
  // is configured.
38
39
 
40
+
41
+
39
42
  const SEVERITY_GLYPH = {
40
43
  critical: '🟥',
41
44
  high: '🟧',
@@ -147,7 +150,7 @@ function renderPrComment(delta, { repoName, prNumber, prTitle } = {}) {
147
150
  const sev = SEVERITY_GLYPH[f.severity] || '⬜';
148
151
  const route = _route(f);
149
152
  const where = route ? `\`${route}\` (\`${f.file}:${f.line}\`)` : `\`${f.file}:${f.line}\``;
150
- lines.push(`${sev} **${meta?.name || f.vuln}** — ${where}`);
153
+ lines.push(`${sev} **${meta?.name || (0,_util_untrusted_js__WEBPACK_IMPORTED_MODULE_0__/* .escapeMarkdown */ .FV)(f.vuln)}** — ${where}`);
151
154
  if (meta) lines.push(` > ${meta.why}`);
152
155
  if (f.remediation) {
153
156
  const onelineFix = String(f.remediation).split('\n')[0].slice(0, 240);
package/dist/830.index.js CHANGED
@@ -2,7 +2,7 @@ export const id = 830;
2
2
  export const ids = [830];
3
3
  export const modules = {
4
4
 
5
- /***/ 449:
5
+ /***/ 2830:
6
6
  /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7
7
 
8
8
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {