@clear-capabilities/agentic-security-scanner 0.74.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 (331) hide show
  1. package/CHANGELOG.md +1580 -0
  2. package/bin/.agentic-security/findings.json +1577 -0
  3. package/bin/.agentic-security/last-scan.json +1577 -0
  4. package/bin/.agentic-security/last-scan.json.sig +1 -0
  5. package/bin/.agentic-security/scan-history.json +465 -0
  6. package/bin/.agentic-security/streak.json +25 -0
  7. package/bin/agentic-security-audit.js +198 -0
  8. package/bin/agentic-security-consistency.js +80 -0
  9. package/bin/agentic-security-diff.js +136 -0
  10. package/bin/agentic-security-lsp.js +12 -0
  11. package/bin/agentic-security-mcp.js +40 -0
  12. package/bin/agentic-security-rule.js +153 -0
  13. package/bin/agentic-security.js +1683 -0
  14. package/dist/117.index.js +207 -0
  15. package/dist/178.index.js +250 -0
  16. package/dist/218.index.js +793 -0
  17. package/dist/227.index.js +192 -0
  18. package/dist/301.index.js +167 -0
  19. package/dist/384.index.js +18 -0
  20. package/dist/476.index.js +126 -0
  21. package/dist/513.index.js +373 -0
  22. package/dist/520.index.js +13 -0
  23. package/dist/601.index.js +1038 -0
  24. package/dist/634.index.js +1892 -0
  25. package/dist/637.index.js +216 -0
  26. package/dist/660.index.js +131 -0
  27. package/dist/675.index.js +451 -0
  28. package/dist/826.index.js +188 -0
  29. package/dist/830.index.js +133 -0
  30. package/dist/agentic-security.mjs +272 -0
  31. package/dist/agentic-security.mjs.sha256 +1 -0
  32. package/dist/calibration-seed.json +27 -0
  33. package/package.json +77 -0
  34. package/src/.agentic-security/findings.json +80844 -0
  35. package/src/.agentic-security/last-scan.json +80844 -0
  36. package/src/.agentic-security/last-scan.json.sig +1 -0
  37. package/src/.agentic-security/scan-history.json +8408 -0
  38. package/src/.agentic-security/streak.json +26 -0
  39. package/src/badge.js +188 -0
  40. package/src/compare.js +203 -0
  41. package/src/dataflow/.agentic-security/findings.json +3487 -0
  42. package/src/dataflow/.agentic-security/last-scan.json +3487 -0
  43. package/src/dataflow/.agentic-security/last-scan.json.sig +1 -0
  44. package/src/dataflow/.agentic-security/scan-history.json +735 -0
  45. package/src/dataflow/.agentic-security/streak.json +24 -0
  46. package/src/dataflow/CLAUDE.md +38 -0
  47. package/src/dataflow/access-paths.js +172 -0
  48. package/src/dataflow/async-sequencing.js +177 -0
  49. package/src/dataflow/backward.js +201 -0
  50. package/src/dataflow/catalog-expanded.js +485 -0
  51. package/src/dataflow/catalog.js +659 -0
  52. package/src/dataflow/cross-repo.js +219 -0
  53. package/src/dataflow/engine.js +588 -0
  54. package/src/dataflow/exception-flow.js +116 -0
  55. package/src/dataflow/exploit-prover.js +187 -0
  56. package/src/dataflow/higher-order.js +221 -0
  57. package/src/dataflow/ifds.js +347 -0
  58. package/src/dataflow/implicit-flow.js +129 -0
  59. package/src/dataflow/incremental.js +229 -0
  60. package/src/dataflow/index.js +181 -0
  61. package/src/dataflow/numeric-domain.js +192 -0
  62. package/src/dataflow/path-feasibility.js +114 -0
  63. package/src/dataflow/points-to.js +337 -0
  64. package/src/dataflow/polyglot.js +190 -0
  65. package/src/dataflow/proven-clean.js +159 -0
  66. package/src/dataflow/receiver-context.js +76 -0
  67. package/src/dataflow/sanitizer-proof.js +154 -0
  68. package/src/dataflow/soft-taint.js +140 -0
  69. package/src/dataflow/string-domain.js +234 -0
  70. package/src/dataflow/stub-aware-filter.js +100 -0
  71. package/src/dataflow/summaries.js +132 -0
  72. package/src/dataflow/symbolic-exec.js +238 -0
  73. package/src/dataflow/tabulation.js +135 -0
  74. package/src/engine.js +7763 -0
  75. package/src/history-scan.js +229 -0
  76. package/src/index.js +3 -0
  77. package/src/integrations/.agentic-security/findings.json +1504 -0
  78. package/src/integrations/.agentic-security/last-scan.json +1504 -0
  79. package/src/integrations/.agentic-security/scan-history.json +40 -0
  80. package/src/integrations/.agentic-security/streak.json +21 -0
  81. package/src/integrations/index.js +321 -0
  82. package/src/integrations/tickets.js +200 -0
  83. package/src/ir/.agentic-security/findings.json +3036 -0
  84. package/src/ir/.agentic-security/last-scan.json +3036 -0
  85. package/src/ir/.agentic-security/last-scan.json.sig +1 -0
  86. package/src/ir/.agentic-security/scan-history.json +364 -0
  87. package/src/ir/.agentic-security/streak.json +23 -0
  88. package/src/ir/CLAUDE.md +172 -0
  89. package/src/ir/callgraph.js +73 -0
  90. package/src/ir/class-hierarchy.js +195 -0
  91. package/src/ir/index.js +152 -0
  92. package/src/ir/parser-cs.js +260 -0
  93. package/src/ir/parser-java.js +286 -0
  94. package/src/ir/parser-js.js +413 -0
  95. package/src/ir/parser-kt.js +258 -0
  96. package/src/ir/parser-py-cst.js +136 -0
  97. package/src/ir/parser-py.helper.py +501 -0
  98. package/src/ir/parser-py.js +312 -0
  99. package/src/ir/ssa.js +315 -0
  100. package/src/ir/type-stubs.js +288 -0
  101. package/src/leaderboard.js +152 -0
  102. package/src/llm-validator/.agentic-security/findings.json +1891 -0
  103. package/src/llm-validator/.agentic-security/last-scan.json +1891 -0
  104. package/src/llm-validator/.agentic-security/last-scan.json.sig +1 -0
  105. package/src/llm-validator/.agentic-security/scan-history.json +168 -0
  106. package/src/llm-validator/.agentic-security/streak.json +20 -0
  107. package/src/llm-validator/consistency.js +141 -0
  108. package/src/llm-validator/index.js +437 -0
  109. package/src/lsp/.agentic-security/findings.json +28 -0
  110. package/src/lsp/.agentic-security/last-scan.json +28 -0
  111. package/src/lsp/.agentic-security/scan-history.json +79 -0
  112. package/src/lsp/.agentic-security/streak.json +22 -0
  113. package/src/lsp/server.js +275 -0
  114. package/src/mcp/.agentic-security/findings.json +8358 -0
  115. package/src/mcp/.agentic-security/last-scan.json +8358 -0
  116. package/src/mcp/.agentic-security/last-scan.json.sig +1 -0
  117. package/src/mcp/.agentic-security/scan-history.json +1125 -0
  118. package/src/mcp/.agentic-security/streak.json +22 -0
  119. package/src/mcp/CLAUDE.md +54 -0
  120. package/src/mcp/audit.js +136 -0
  121. package/src/mcp/redact.js +75 -0
  122. package/src/mcp/server.js +158 -0
  123. package/src/mcp/stdio.js +83 -0
  124. package/src/mcp/tools.js +940 -0
  125. package/src/mcp/validate.js +49 -0
  126. package/src/personality.js +164 -0
  127. package/src/poc-video.js +239 -0
  128. package/src/posture/.agentic-security/findings.json +51239 -0
  129. package/src/posture/.agentic-security/last-scan.json +51239 -0
  130. package/src/posture/.agentic-security/last-scan.json.sig +1 -0
  131. package/src/posture/.agentic-security/scan-history.json +5557 -0
  132. package/src/posture/.agentic-security/streak.json +24 -0
  133. package/src/posture/CLAUDE.md +42 -0
  134. package/src/posture/adversarial-self-test.js +114 -0
  135. package/src/posture/adversary-agent.js +204 -0
  136. package/src/posture/agents-memory.js +135 -0
  137. package/src/posture/ai-code-fingerprint.js +171 -0
  138. package/src/posture/aibom.js +284 -0
  139. package/src/posture/api-inventory.js +96 -0
  140. package/src/posture/attack-playbooks.js +305 -0
  141. package/src/posture/auditor-agent.js +115 -0
  142. package/src/posture/auth-posture-import.js +135 -0
  143. package/src/posture/baseline-compare.js +114 -0
  144. package/src/posture/blast-radius.js +836 -0
  145. package/src/posture/bounty-prediction.js +141 -0
  146. package/src/posture/business-logic.js +239 -0
  147. package/src/posture/calibration-drift.js +93 -0
  148. package/src/posture/calibration-seed.json +27 -0
  149. package/src/posture/calibration.js +204 -0
  150. package/src/posture/clustering.js +75 -0
  151. package/src/posture/concurrency-checker.js +265 -0
  152. package/src/posture/confidence.js +65 -0
  153. package/src/posture/container-runtime.js +149 -0
  154. package/src/posture/counterfactual.js +109 -0
  155. package/src/posture/cross-lang-graphql.js +165 -0
  156. package/src/posture/cross-lang-grpc.js +166 -0
  157. package/src/posture/cross-lang-meta.js +101 -0
  158. package/src/posture/cross-lang-openapi.js +187 -0
  159. package/src/posture/cross-lang-orm.js +153 -0
  160. package/src/posture/cross-lang-queues.js +210 -0
  161. package/src/posture/crown-jewels.js +110 -0
  162. package/src/posture/custom-rules.js +361 -0
  163. package/src/posture/cve-alert-daemon.js +433 -0
  164. package/src/posture/cve-lookup.js +129 -0
  165. package/src/posture/dead-code.js +430 -0
  166. package/src/posture/defender-agent.js +158 -0
  167. package/src/posture/deploy-platform.js +204 -0
  168. package/src/posture/detector-fuzz.js +61 -0
  169. package/src/posture/deterministic.js +99 -0
  170. package/src/posture/drift.js +165 -0
  171. package/src/posture/epss.js +156 -0
  172. package/src/posture/exploitability-probability.js +212 -0
  173. package/src/posture/exploitability.js +121 -0
  174. package/src/posture/feature-flags.js +110 -0
  175. package/src/posture/finding-defaults.js +132 -0
  176. package/src/posture/fix-history.js +411 -0
  177. package/src/posture/fix-plan.js +121 -0
  178. package/src/posture/fix-verify-loop.js +157 -0
  179. package/src/posture/fix-verify.js +130 -0
  180. package/src/posture/flow-narration.js +105 -0
  181. package/src/posture/grader-calibration.js +156 -0
  182. package/src/posture/harness-discovery.js +113 -0
  183. package/src/posture/holdout-eval.js +144 -0
  184. package/src/posture/iac-reachability.js +163 -0
  185. package/src/posture/iam-policy.js +128 -0
  186. package/src/posture/integrity.js +97 -0
  187. package/src/posture/learning.js +166 -0
  188. package/src/posture/license-policy.js +109 -0
  189. package/src/posture/llm-redteam-prompts.js +418 -0
  190. package/src/posture/llm-redteam.js +303 -0
  191. package/src/posture/material-change.js +163 -0
  192. package/src/posture/mitigation-composite.js +55 -0
  193. package/src/posture/mttr.js +91 -0
  194. package/src/posture/network-policy-import.js +126 -0
  195. package/src/posture/path-predicates.js +99 -0
  196. package/src/posture/persona-prioritization.js +153 -0
  197. package/src/posture/poc-cwe-map.js +51 -0
  198. package/src/posture/poc-generator.js +500 -0
  199. package/src/posture/policy-gate.js +174 -0
  200. package/src/posture/pre-incident-archaeology.js +110 -0
  201. package/src/posture/profile.js +93 -0
  202. package/src/posture/reachability-filter.js +42 -0
  203. package/src/posture/regression-test-gen.js +200 -0
  204. package/src/posture/reverse-blast-radius.js +110 -0
  205. package/src/posture/router.js +109 -0
  206. package/src/posture/rule-overrides.js +198 -0
  207. package/src/posture/rule-pack-signing.js +209 -0
  208. package/src/posture/rule-packs.js +143 -0
  209. package/src/posture/rule-synthesis.js +108 -0
  210. package/src/posture/ruleset-version.js +71 -0
  211. package/src/posture/sbom.js +129 -0
  212. package/src/posture/schema-aware-bridge.js +207 -0
  213. package/src/posture/security-trend.js +87 -0
  214. package/src/posture/semantic-clone.js +114 -0
  215. package/src/posture/specification-mining.js +170 -0
  216. package/src/posture/stable-id.js +75 -0
  217. package/src/posture/stack-playbook.js +229 -0
  218. package/src/posture/streak.js +249 -0
  219. package/src/posture/suppressions.js +135 -0
  220. package/src/posture/telemetry-ingest.js +112 -0
  221. package/src/posture/threat-model.js +145 -0
  222. package/src/posture/three-agent-pipeline.js +74 -0
  223. package/src/posture/triage.js +146 -0
  224. package/src/posture/trust-boundary-diagram.js +115 -0
  225. package/src/posture/type-narrowing.js +129 -0
  226. package/src/posture/validator-metrics.js +179 -0
  227. package/src/posture/verifier-ephemeral.js +118 -0
  228. package/src/posture/verifier-target.js +147 -0
  229. package/src/posture/verifier.js +257 -0
  230. package/src/posture/version.js +75 -0
  231. package/src/posture/waf-ingest.js +200 -0
  232. package/src/posture/why-fired.js +141 -0
  233. package/src/pr-comment.js +172 -0
  234. package/src/pr-delta.js +198 -0
  235. package/src/report/.agentic-security/findings.json +79 -0
  236. package/src/report/.agentic-security/last-scan.json +79 -0
  237. package/src/report/.agentic-security/last-scan.json.sig +1 -0
  238. package/src/report/.agentic-security/scan-history.json +332 -0
  239. package/src/report/.agentic-security/streak.json +23 -0
  240. package/src/report/index.js +1136 -0
  241. package/src/report/mascot.js +42 -0
  242. package/src/runScan.js +141 -0
  243. package/src/sast/.agentic-security/findings.json +5051 -0
  244. package/src/sast/.agentic-security/last-scan.json +5051 -0
  245. package/src/sast/.agentic-security/last-scan.json.sig +1 -0
  246. package/src/sast/.agentic-security/scan-history.json +788 -0
  247. package/src/sast/.agentic-security/streak.json +23 -0
  248. package/src/sast/CLAUDE.md +39 -0
  249. package/src/sast/_comment-strip.js +46 -0
  250. package/src/sast/agent-tool-escalation.js +131 -0
  251. package/src/sast/auth-provider.js +171 -0
  252. package/src/sast/authz.js +236 -0
  253. package/src/sast/bench-shape/.agentic-security/findings.json +28 -0
  254. package/src/sast/bench-shape/.agentic-security/last-scan.json +28 -0
  255. package/src/sast/bench-shape/.agentic-security/scan-history.json +24 -0
  256. package/src/sast/bench-shape/.agentic-security/streak.json +22 -0
  257. package/src/sast/bench-shape/index.js +62 -0
  258. package/src/sast/claude-hook-injection.js +199 -0
  259. package/src/sast/claude-md-prompt-injection.js +170 -0
  260. package/src/sast/claude-settings.js +165 -0
  261. package/src/sast/client-side.js +149 -0
  262. package/src/sast/cpp-bench-extras.js +122 -0
  263. package/src/sast/cpp-dataflow.js +430 -0
  264. package/src/sast/cpp.js +248 -0
  265. package/src/sast/csharp.js +152 -0
  266. package/src/sast/csrf.js +82 -0
  267. package/src/sast/dart-flutter.js +173 -0
  268. package/src/sast/db-rls.js +147 -0
  269. package/src/sast/db-taint.js +215 -0
  270. package/src/sast/defi-deep.js +242 -0
  271. package/src/sast/deserialization-gadgets.js +113 -0
  272. package/src/sast/django-hardening.js +230 -0
  273. package/src/sast/env-hygiene.js +125 -0
  274. package/src/sast/fastapi-hardening.js +145 -0
  275. package/src/sast/go-extended.js +84 -0
  276. package/src/sast/host-header.js +106 -0
  277. package/src/sast/index.js +17 -0
  278. package/src/sast/java-ast-folding.js +561 -0
  279. package/src/sast/java-bench-extras.js +708 -0
  280. package/src/sast/java-collection-passthrough.js +178 -0
  281. package/src/sast/java-constant-fold.js +244 -0
  282. package/src/sast/java-deserialization.js +125 -0
  283. package/src/sast/jndi.js +104 -0
  284. package/src/sast/juliet-shape.js +324 -0
  285. package/src/sast/jwt-exp.js +104 -0
  286. package/src/sast/kotlin.js +82 -0
  287. package/src/sast/laravel-hardening.js +198 -0
  288. package/src/sast/ldap-injection.js +100 -0
  289. package/src/sast/llm-owasp.js +465 -0
  290. package/src/sast/llm-stored-prompt.js +103 -0
  291. package/src/sast/llm-trading-agent.js +161 -0
  292. package/src/sast/llm.js +308 -0
  293. package/src/sast/logic.js +140 -0
  294. package/src/sast/mass-assignment.js +101 -0
  295. package/src/sast/mcp-audit.js +242 -0
  296. package/src/sast/mobile-manifest.js +195 -0
  297. package/src/sast/model-load.js +164 -0
  298. package/src/sast/mutation-xss.js +87 -0
  299. package/src/sast/nosql-injection.js +82 -0
  300. package/src/sast/open-redirect.js +119 -0
  301. package/src/sast/php.js +91 -0
  302. package/src/sast/pipeline.js +122 -0
  303. package/src/sast/primary-cwe-java.js +155 -0
  304. package/src/sast/prompt-firewall.js +151 -0
  305. package/src/sast/prompt-template.js +157 -0
  306. package/src/sast/prototype-pollution.js +112 -0
  307. package/src/sast/python-sinks.js +195 -0
  308. package/src/sast/quarkus-hardening.js +102 -0
  309. package/src/sast/rag-poisoning.js +118 -0
  310. package/src/sast/rate-limit.js +128 -0
  311. package/src/sast/response-splitting.js +138 -0
  312. package/src/sast/ruby.js +108 -0
  313. package/src/sast/rust.js +105 -0
  314. package/src/sast/solidity.js +167 -0
  315. package/src/sast/springboot-hardening.js +186 -0
  316. package/src/sast/ssrf-cloud-metadata.js +80 -0
  317. package/src/sast/ssti.js +116 -0
  318. package/src/sast/swift.js +162 -0
  319. package/src/sast/toctou.js +95 -0
  320. package/src/sast/webhook.js +101 -0
  321. package/src/sast/xpath-injection.js +51 -0
  322. package/src/sast/xxe.js +140 -0
  323. package/src/sast/zip-slip.js +200 -0
  324. package/src/sca/base-images.json +45 -0
  325. package/src/sca/container.js +107 -0
  326. package/src/sca/dep-confusion.js +134 -0
  327. package/src/sca/index.js +6 -0
  328. package/src/sca/popular-packages.json +41 -0
  329. package/src/sca/sarif-ingest.js +187 -0
  330. package/src/sca/vuln-function-hints.json +89 -0
  331. package/src/secrets/index.js +4 -0
@@ -0,0 +1,198 @@
1
+ // Shadowscan / security-DELTA on PR (v0.72).
2
+ //
3
+ // Most SAST PR-comment integrations show absolute counts — "12 findings
4
+ // detected in changed files." Engineers can't act on that: 11 of those
5
+ // 12 already existed before they touched the file. They want a DELTA:
6
+ // what did THIS PR introduce, what did it remove, what changed.
7
+ //
8
+ // This module diffs two scans (PR branch vs base) by stableId and emits
9
+ // both a JSON delta and a human-readable summary suitable for embedding
10
+ // in a PR comment. Reuses the existing `history-scan.js` machinery for
11
+ // the at-ref scans.
12
+ //
13
+ // Algorithm:
14
+ // 1. Scan the base ref (in-memory via runFullScan, no checkout)
15
+ // 2. Scan the head ref (same way)
16
+ // 3. Key findings by stableId
17
+ // 4. Emit:
18
+ // - introduced: findings in head not in base
19
+ // - resolved: findings in base not in head
20
+ // - persistent: findings in both (changed severity/cwe → 'shifted')
21
+ // 5. Severity-summary counts each side
22
+ //
23
+ // Output shape stays stable so downstream renderers (advisor-tone PR
24
+ // comment) can transform without re-walking IR.
25
+
26
+ import { spawnSync } from 'node:child_process';
27
+ import { runFullScan } from './engine.js';
28
+
29
+ const FILE_EXT_RE = /\.(?:js|jsx|ts|tsx|mjs|cjs|py|java|cs|kt|go|rb|php|sol|swift|rs|tf|yml|yaml|json|toml|md)$/i;
30
+ const SEVERITIES = ['critical', 'high', 'medium', 'low', 'info'];
31
+
32
+ function _git(root, args) {
33
+ const r = spawnSync('git', args, { cwd: root, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
34
+ return { ok: r.status === 0, stdout: r.stdout || '', stderr: r.stderr || '' };
35
+ }
36
+
37
+ function _readFileAtRef(root, ref, file) {
38
+ const r = _git(root, ['show', `${ref}:${file}`]);
39
+ return r.ok ? r.stdout : null;
40
+ }
41
+
42
+ function _listFilesAtRef(root, ref) {
43
+ const r = _git(root, ['ls-tree', '-r', '--name-only', ref]);
44
+ if (!r.ok) return [];
45
+ return r.stdout.trim().split('\n').filter(p => {
46
+ if (!p) return false;
47
+ if (p.includes('/node_modules/') || p.includes('/.venv/')) return false;
48
+ return FILE_EXT_RE.test(p);
49
+ });
50
+ }
51
+
52
+ async function _scanAtRef(root, ref) {
53
+ const files = _listFilesAtRef(root, ref);
54
+ const fileContents = {};
55
+ for (const f of files) {
56
+ const c = _readFileAtRef(root, ref, f);
57
+ if (c != null) fileContents[f] = c;
58
+ }
59
+ return runFullScan({ fileContents, scanRoot: root }, () => {});
60
+ }
61
+
62
+ function _summary(findings) {
63
+ const out = { total: 0 };
64
+ for (const s of SEVERITIES) out[s] = 0;
65
+ for (const f of (findings || [])) {
66
+ const s = f.severity || 'info';
67
+ if (out[s] !== undefined) out[s]++;
68
+ out.total++;
69
+ }
70
+ return out;
71
+ }
72
+
73
+ function _changedFiles(root, baseRef, headRef) {
74
+ const r = _git(root, ['diff', '--name-only', `${baseRef}...${headRef}`]);
75
+ if (!r.ok) return new Set();
76
+ return new Set(r.stdout.trim().split('\n').filter(Boolean));
77
+ }
78
+
79
+ /**
80
+ * Top-level entry: compute the delta between two refs.
81
+ *
82
+ * root: scan root (a git repo)
83
+ * baseRef: the ref to compare against (e.g. main, origin/main)
84
+ * headRef: the ref to score (e.g. HEAD, the PR branch). Defaults HEAD.
85
+ *
86
+ * Returns:
87
+ * {
88
+ * baseRef, headRef,
89
+ * changedFiles: [...], // git diff --name-only base...head
90
+ * base: { findings, summary, secrets, supplyChain, logicVulns },
91
+ * head: { findings, summary, secrets, supplyChain, logicVulns },
92
+ * introduced: Finding[], // new in head only
93
+ * resolved: Finding[], // removed from base
94
+ * persistent: Finding[], // same stableId in both (no semantic change)
95
+ * shifted: Finding[], // same stableId, severity OR cwe changed
96
+ * summary: { introduced: SeveritySummary, resolved, persistent, net },
97
+ * }
98
+ *
99
+ * `net` is per-severity (head − base). A negative critical count means
100
+ * the PR resolved a critical finding overall.
101
+ */
102
+ export async function computePrDelta(root, { baseRef, headRef = 'HEAD' } = {}) {
103
+ if (!baseRef) throw new Error('computePrDelta: baseRef is required');
104
+ const changedFiles = [..._changedFiles(root, baseRef, headRef)];
105
+ const baseScan = await _scanAtRef(root, baseRef);
106
+ const headScan = await _scanAtRef(root, headRef);
107
+ const baseById = new Map();
108
+ const headById = new Map();
109
+ for (const f of (baseScan.findings || [])) {
110
+ const k = f.stableId || f.id;
111
+ if (k) baseById.set(k, f);
112
+ }
113
+ for (const f of (headScan.findings || [])) {
114
+ const k = f.stableId || f.id;
115
+ if (k) headById.set(k, f);
116
+ }
117
+ const introduced = [];
118
+ const resolved = [];
119
+ const persistent = [];
120
+ const shifted = [];
121
+ for (const [k, f] of headById) {
122
+ if (!baseById.has(k)) introduced.push(f);
123
+ else {
124
+ const base = baseById.get(k);
125
+ if (base.severity !== f.severity || base.cwe !== f.cwe) {
126
+ shifted.push({ from: base, to: f });
127
+ } else {
128
+ persistent.push(f);
129
+ }
130
+ }
131
+ }
132
+ for (const [k, f] of baseById) {
133
+ if (!headById.has(k)) resolved.push(f);
134
+ }
135
+ // Net severity (head − base).
136
+ const net = {};
137
+ const baseSummary = _summary(baseScan.findings || []);
138
+ const headSummary = _summary(headScan.findings || []);
139
+ for (const s of [...SEVERITIES, 'total']) net[s] = (headSummary[s] || 0) - (baseSummary[s] || 0);
140
+ return {
141
+ baseRef, headRef,
142
+ changedFiles,
143
+ base: {
144
+ findings: baseScan.findings || [],
145
+ summary: baseSummary,
146
+ secrets: baseScan.secrets || [],
147
+ supplyChain: baseScan.supplyChain || [],
148
+ logicVulns: baseScan.logicVulns || [],
149
+ },
150
+ head: {
151
+ findings: headScan.findings || [],
152
+ summary: headSummary,
153
+ secrets: headScan.secrets || [],
154
+ supplyChain: headScan.supplyChain || [],
155
+ logicVulns: headScan.logicVulns || [],
156
+ },
157
+ introduced,
158
+ resolved,
159
+ persistent,
160
+ shifted,
161
+ summary: {
162
+ introduced: _summary(introduced),
163
+ resolved: _summary(resolved),
164
+ persistent: _summary(persistent),
165
+ net,
166
+ },
167
+ };
168
+ }
169
+
170
+ /**
171
+ * Lightweight text summary used as a CLI fallback when --json isn't set.
172
+ */
173
+ export function renderPrDeltaText(delta) {
174
+ const i = delta.summary.introduced;
175
+ const r = delta.summary.resolved;
176
+ const lines = [];
177
+ lines.push(`Delta: ${delta.baseRef} → ${delta.headRef}`);
178
+ lines.push(`Changed files: ${delta.changedFiles.length}`);
179
+ lines.push('');
180
+ if (delta.introduced.length === 0 && delta.resolved.length === 0 && delta.shifted.length === 0) {
181
+ lines.push('No security delta. Safe to merge.');
182
+ return lines.join('\n');
183
+ }
184
+ lines.push(`Introduced: ${delta.introduced.length} ` +
185
+ `(crit ${i.critical} · high ${i.high} · med ${i.medium} · low ${i.low})`);
186
+ lines.push(`Resolved: ${delta.resolved.length} ` +
187
+ `(crit ${r.critical} · high ${r.high} · med ${r.medium} · low ${r.low})`);
188
+ if (delta.shifted.length) lines.push(`Shifted: ${delta.shifted.length}`);
189
+ if (delta.introduced.length) {
190
+ lines.push('');
191
+ lines.push('Newly introduced:');
192
+ for (const f of delta.introduced.slice(0, 20)) {
193
+ lines.push(` + ${f.severity.padEnd(8)} ${f.cwe || ''} ${f.vuln} (${f.file}:${f.line})`);
194
+ }
195
+ if (delta.introduced.length > 20) lines.push(` … ${delta.introduced.length - 20} more`);
196
+ }
197
+ return lines.join('\n');
198
+ }
@@ -0,0 +1,79 @@
1
+ {
2
+ "scanId": "c3ef4632-79ae-4ffb-8f06-3ff4f6f0fef2",
3
+ "startedAt": "2026-05-19T21:49:07.932Z",
4
+ "durationMs": 196,
5
+ "scanned": {
6
+ "files": 2,
7
+ "lines": 0
8
+ },
9
+ "findings": [],
10
+ "bundles": [],
11
+ "routes": [],
12
+ "components": [],
13
+ "suppressedCount": 0,
14
+ "blastRadiusSignals": {
15
+ "industry": "generic",
16
+ "industryConfidence": "low",
17
+ "jurisdictions": [],
18
+ "controls": [],
19
+ "estimatedUsers": 50,
20
+ "revenueIndicator": "pre-revenue",
21
+ "hasStripe": false,
22
+ "hasAuth": false,
23
+ "hasUserTable": false,
24
+ "hasPII": false,
25
+ "hasPHI": false,
26
+ "hasS3": false
27
+ },
28
+ "_v3": {
29
+ "counterfactual": {
30
+ "spofControls": [],
31
+ "controlsDetected": 167
32
+ },
33
+ "threatModel": {
34
+ "summary": {
35
+ "assetCount": 0,
36
+ "boundaryCount": 0,
37
+ "strideCounts": {
38
+ "spoofing": 0,
39
+ "tampering": 0,
40
+ "repudiation": 0,
41
+ "informationDisclosure": 0,
42
+ "denialOfService": 0,
43
+ "elevationOfPrivilege": 0
44
+ }
45
+ },
46
+ "assets": [],
47
+ "trustBoundaries": [],
48
+ "stride": {
49
+ "spoofing": [],
50
+ "tampering": [],
51
+ "repudiation": [],
52
+ "informationDisclosure": [],
53
+ "denialOfService": [],
54
+ "elevationOfPrivilege": []
55
+ }
56
+ },
57
+ "trustBoundaryDiagram": {
58
+ "mermaid": "flowchart LR\n INTERNET((Internet))\n APP[\"Application\"]\n classDef sev_critical fill:#ffcccc,stroke:#a00,stroke-width:2px;\n classDef sev_high fill:#ffe0b2,stroke:#c60,stroke-width:2px;\n classDef sev_medium fill:#fff3cd,stroke:#a80;\n classDef sev_low fill:#e8eaf6,stroke:#557;",
59
+ "nodes": [
60
+ {
61
+ "id": "INTERNET",
62
+ "kind": "external",
63
+ "label": "Internet"
64
+ },
65
+ {
66
+ "id": "APP",
67
+ "kind": "app",
68
+ "label": "Application"
69
+ }
70
+ ],
71
+ "edges": [],
72
+ "decorations": []
73
+ },
74
+ "calibrationDrift": {
75
+ "alarms": [],
76
+ "note": "no-feedback-data"
77
+ }
78
+ }
79
+ }
@@ -0,0 +1,79 @@
1
+ {
2
+ "scanId": "c3ef4632-79ae-4ffb-8f06-3ff4f6f0fef2",
3
+ "startedAt": "2026-05-19T21:49:07.932Z",
4
+ "durationMs": 196,
5
+ "scanned": {
6
+ "files": 2,
7
+ "lines": 0
8
+ },
9
+ "findings": [],
10
+ "bundles": [],
11
+ "routes": [],
12
+ "components": [],
13
+ "suppressedCount": 0,
14
+ "blastRadiusSignals": {
15
+ "industry": "generic",
16
+ "industryConfidence": "low",
17
+ "jurisdictions": [],
18
+ "controls": [],
19
+ "estimatedUsers": 50,
20
+ "revenueIndicator": "pre-revenue",
21
+ "hasStripe": false,
22
+ "hasAuth": false,
23
+ "hasUserTable": false,
24
+ "hasPII": false,
25
+ "hasPHI": false,
26
+ "hasS3": false
27
+ },
28
+ "_v3": {
29
+ "counterfactual": {
30
+ "spofControls": [],
31
+ "controlsDetected": 167
32
+ },
33
+ "threatModel": {
34
+ "summary": {
35
+ "assetCount": 0,
36
+ "boundaryCount": 0,
37
+ "strideCounts": {
38
+ "spoofing": 0,
39
+ "tampering": 0,
40
+ "repudiation": 0,
41
+ "informationDisclosure": 0,
42
+ "denialOfService": 0,
43
+ "elevationOfPrivilege": 0
44
+ }
45
+ },
46
+ "assets": [],
47
+ "trustBoundaries": [],
48
+ "stride": {
49
+ "spoofing": [],
50
+ "tampering": [],
51
+ "repudiation": [],
52
+ "informationDisclosure": [],
53
+ "denialOfService": [],
54
+ "elevationOfPrivilege": []
55
+ }
56
+ },
57
+ "trustBoundaryDiagram": {
58
+ "mermaid": "flowchart LR\n INTERNET((Internet))\n APP[\"Application\"]\n classDef sev_critical fill:#ffcccc,stroke:#a00,stroke-width:2px;\n classDef sev_high fill:#ffe0b2,stroke:#c60,stroke-width:2px;\n classDef sev_medium fill:#fff3cd,stroke:#a80;\n classDef sev_low fill:#e8eaf6,stroke:#557;",
59
+ "nodes": [
60
+ {
61
+ "id": "INTERNET",
62
+ "kind": "external",
63
+ "label": "Internet"
64
+ },
65
+ {
66
+ "id": "APP",
67
+ "kind": "app",
68
+ "label": "Application"
69
+ }
70
+ ],
71
+ "edges": [],
72
+ "decorations": []
73
+ },
74
+ "calibrationDrift": {
75
+ "alarms": [],
76
+ "note": "no-feedback-data"
77
+ }
78
+ }
79
+ }
@@ -0,0 +1 @@
1
+ 3cd9d9783f17e2685c9bac77499113866f2092dfbc7fd24dc665e09107d1c6f7
@@ -0,0 +1,332 @@
1
+ [
2
+ {
3
+ "timestamp": "2026-05-16T12:14:36.442Z",
4
+ "label": "scan",
5
+ "total": 0,
6
+ "critical": 0,
7
+ "high": 0,
8
+ "medium": 0,
9
+ "low": 0,
10
+ "kev": 0,
11
+ "ids": []
12
+ },
13
+ {
14
+ "timestamp": "2026-05-16T23:36:58.645Z",
15
+ "label": "scan",
16
+ "total": 0,
17
+ "critical": 0,
18
+ "high": 0,
19
+ "medium": 0,
20
+ "low": 0,
21
+ "kev": 0,
22
+ "ids": []
23
+ },
24
+ {
25
+ "timestamp": "2026-05-18T17:48:29.014Z",
26
+ "label": "scan",
27
+ "total": 0,
28
+ "critical": 0,
29
+ "high": 0,
30
+ "medium": 0,
31
+ "low": 0,
32
+ "kev": 0,
33
+ "ids": []
34
+ },
35
+ {
36
+ "timestamp": "2026-05-18T17:56:28.844Z",
37
+ "label": "scan",
38
+ "total": 0,
39
+ "critical": 0,
40
+ "high": 0,
41
+ "medium": 0,
42
+ "low": 0,
43
+ "kev": 0,
44
+ "ids": []
45
+ },
46
+ {
47
+ "timestamp": "2026-05-18T22:34:47.507Z",
48
+ "label": "scan",
49
+ "total": 0,
50
+ "critical": 0,
51
+ "high": 0,
52
+ "medium": 0,
53
+ "low": 0,
54
+ "kev": 0,
55
+ "ids": []
56
+ },
57
+ {
58
+ "timestamp": "2026-05-18T22:59:24.059Z",
59
+ "label": "scan",
60
+ "total": 0,
61
+ "critical": 0,
62
+ "high": 0,
63
+ "medium": 0,
64
+ "low": 0,
65
+ "kev": 0,
66
+ "ids": []
67
+ },
68
+ {
69
+ "timestamp": "2026-05-18T22:59:40.564Z",
70
+ "label": "scan",
71
+ "total": 0,
72
+ "critical": 0,
73
+ "high": 0,
74
+ "medium": 0,
75
+ "low": 0,
76
+ "kev": 0,
77
+ "ids": []
78
+ },
79
+ {
80
+ "timestamp": "2026-05-18T23:08:03.888Z",
81
+ "label": "scan",
82
+ "total": 0,
83
+ "critical": 0,
84
+ "high": 0,
85
+ "medium": 0,
86
+ "low": 0,
87
+ "kev": 0,
88
+ "ids": []
89
+ },
90
+ {
91
+ "timestamp": "2026-05-18T23:08:22.652Z",
92
+ "label": "scan",
93
+ "total": 0,
94
+ "critical": 0,
95
+ "high": 0,
96
+ "medium": 0,
97
+ "low": 0,
98
+ "kev": 0,
99
+ "ids": []
100
+ },
101
+ {
102
+ "timestamp": "2026-05-18T23:10:59.592Z",
103
+ "label": "scan",
104
+ "total": 0,
105
+ "critical": 0,
106
+ "high": 0,
107
+ "medium": 0,
108
+ "low": 0,
109
+ "kev": 0,
110
+ "ids": []
111
+ },
112
+ {
113
+ "timestamp": "2026-05-19T00:09:08.611Z",
114
+ "label": "scan",
115
+ "total": 0,
116
+ "critical": 0,
117
+ "high": 0,
118
+ "medium": 0,
119
+ "low": 0,
120
+ "kev": 0,
121
+ "ids": []
122
+ },
123
+ {
124
+ "timestamp": "2026-05-19T00:09:16.891Z",
125
+ "label": "scan",
126
+ "total": 0,
127
+ "critical": 0,
128
+ "high": 0,
129
+ "medium": 0,
130
+ "low": 0,
131
+ "kev": 0,
132
+ "ids": []
133
+ },
134
+ {
135
+ "timestamp": "2026-05-19T00:10:01.720Z",
136
+ "label": "scan",
137
+ "total": 0,
138
+ "critical": 0,
139
+ "high": 0,
140
+ "medium": 0,
141
+ "low": 0,
142
+ "kev": 0,
143
+ "ids": []
144
+ },
145
+ {
146
+ "timestamp": "2026-05-19T00:10:15.908Z",
147
+ "label": "scan",
148
+ "total": 0,
149
+ "critical": 0,
150
+ "high": 0,
151
+ "medium": 0,
152
+ "low": 0,
153
+ "kev": 0,
154
+ "ids": []
155
+ },
156
+ {
157
+ "timestamp": "2026-05-19T02:01:28.011Z",
158
+ "label": "scan",
159
+ "total": 0,
160
+ "critical": 0,
161
+ "high": 0,
162
+ "medium": 0,
163
+ "low": 0,
164
+ "kev": 0,
165
+ "ids": []
166
+ },
167
+ {
168
+ "timestamp": "2026-05-19T02:09:03.968Z",
169
+ "label": "scan",
170
+ "total": 0,
171
+ "critical": 0,
172
+ "high": 0,
173
+ "medium": 0,
174
+ "low": 0,
175
+ "kev": 0,
176
+ "ids": []
177
+ },
178
+ {
179
+ "timestamp": "2026-05-19T02:17:39.336Z",
180
+ "label": "scan",
181
+ "total": 0,
182
+ "critical": 0,
183
+ "high": 0,
184
+ "medium": 0,
185
+ "low": 0,
186
+ "kev": 0,
187
+ "ids": []
188
+ },
189
+ {
190
+ "timestamp": "2026-05-19T03:11:59.398Z",
191
+ "label": "scan",
192
+ "total": 0,
193
+ "critical": 0,
194
+ "high": 0,
195
+ "medium": 0,
196
+ "low": 0,
197
+ "kev": 0,
198
+ "ids": []
199
+ },
200
+ {
201
+ "timestamp": "2026-05-19T03:13:30.141Z",
202
+ "label": "scan",
203
+ "total": 0,
204
+ "critical": 0,
205
+ "high": 0,
206
+ "medium": 0,
207
+ "low": 0,
208
+ "kev": 0,
209
+ "ids": []
210
+ },
211
+ {
212
+ "timestamp": "2026-05-19T03:21:16.211Z",
213
+ "label": "scan",
214
+ "total": 0,
215
+ "critical": 0,
216
+ "high": 0,
217
+ "medium": 0,
218
+ "low": 0,
219
+ "kev": 0,
220
+ "ids": []
221
+ },
222
+ {
223
+ "timestamp": "2026-05-19T04:45:00.044Z",
224
+ "label": "scan",
225
+ "total": 0,
226
+ "critical": 0,
227
+ "high": 0,
228
+ "medium": 0,
229
+ "low": 0,
230
+ "kev": 0,
231
+ "ids": []
232
+ },
233
+ {
234
+ "timestamp": "2026-05-19T04:45:15.057Z",
235
+ "label": "scan",
236
+ "total": 0,
237
+ "critical": 0,
238
+ "high": 0,
239
+ "medium": 0,
240
+ "low": 0,
241
+ "kev": 0,
242
+ "ids": []
243
+ },
244
+ {
245
+ "timestamp": "2026-05-19T04:54:36.921Z",
246
+ "label": "scan",
247
+ "total": 0,
248
+ "critical": 0,
249
+ "high": 0,
250
+ "medium": 0,
251
+ "low": 0,
252
+ "kev": 0,
253
+ "ids": []
254
+ },
255
+ {
256
+ "timestamp": "2026-05-19T13:24:54.931Z",
257
+ "label": "scan",
258
+ "total": 0,
259
+ "critical": 0,
260
+ "high": 0,
261
+ "medium": 0,
262
+ "low": 0,
263
+ "kev": 0,
264
+ "ids": []
265
+ },
266
+ {
267
+ "timestamp": "2026-05-19T13:25:09.569Z",
268
+ "label": "scan",
269
+ "total": 0,
270
+ "critical": 0,
271
+ "high": 0,
272
+ "medium": 0,
273
+ "low": 0,
274
+ "kev": 0,
275
+ "ids": []
276
+ },
277
+ {
278
+ "timestamp": "2026-05-19T20:25:04.198Z",
279
+ "label": "scan",
280
+ "total": 0,
281
+ "critical": 0,
282
+ "high": 0,
283
+ "medium": 0,
284
+ "low": 0,
285
+ "kev": 0,
286
+ "ids": []
287
+ },
288
+ {
289
+ "timestamp": "2026-05-19T20:26:03.116Z",
290
+ "label": "scan",
291
+ "total": 0,
292
+ "critical": 0,
293
+ "high": 0,
294
+ "medium": 0,
295
+ "low": 0,
296
+ "kev": 0,
297
+ "ids": []
298
+ },
299
+ {
300
+ "timestamp": "2026-05-19T20:26:12.780Z",
301
+ "label": "scan",
302
+ "total": 0,
303
+ "critical": 0,
304
+ "high": 0,
305
+ "medium": 0,
306
+ "low": 0,
307
+ "kev": 0,
308
+ "ids": []
309
+ },
310
+ {
311
+ "timestamp": "2026-05-19T21:46:43.850Z",
312
+ "label": "scan",
313
+ "total": 0,
314
+ "critical": 0,
315
+ "high": 0,
316
+ "medium": 0,
317
+ "low": 0,
318
+ "kev": 0,
319
+ "ids": []
320
+ },
321
+ {
322
+ "timestamp": "2026-05-19T21:49:08.128Z",
323
+ "label": "scan",
324
+ "total": 0,
325
+ "critical": 0,
326
+ "high": 0,
327
+ "medium": 0,
328
+ "low": 0,
329
+ "kev": 0,
330
+ "ids": []
331
+ }
332
+ ]