@clear-capabilities/agentic-security-scanner 0.184.0 → 0.186.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/bin/agentic-security.js +111 -1
  3. package/dist/1128.index.js +912 -0
  4. package/dist/1665.index.js +828 -0
  5. package/dist/2584.index.js +1 -1
  6. package/dist/4171.index.js +2 -2
  7. package/dist/5752.index.js +466 -0
  8. package/dist/7405.index.js +1 -1
  9. package/dist/8158.index.js +1713 -0
  10. package/dist/8798.index.js +1 -1
  11. package/dist/9382.index.js +2 -2
  12. package/dist/9579.index.js +1 -1
  13. package/dist/agentic-security.mjs +29 -29
  14. package/dist/agentic-security.mjs.sha256 +1 -1
  15. package/dist/{dad58d1113a12c23a142.json → ca62ee93079be4c24eee.json} +29 -12
  16. package/dist/frontend/src/shell.js +12 -2
  17. package/package.json +29 -12
  18. package/src/dataflow/CLAUDE.md +46 -1
  19. package/src/dataflow/access-paths.js +12 -2
  20. package/src/dataflow/backward.js +42 -7
  21. package/src/dataflow/cross-service-taint.js +83 -1
  22. package/src/dataflow/demand-query.js +1168 -0
  23. package/src/dataflow/dep-fingerprint.js +718 -0
  24. package/src/dataflow/engine.js +48 -6
  25. package/src/dataflow/exploit-prover.js +6 -2
  26. package/src/dataflow/ifds-precise.js +22 -0
  27. package/src/dataflow/incremental-replay.js +118 -0
  28. package/src/dataflow/incremental-session.js +257 -0
  29. package/src/dataflow/incremental.js +237 -35
  30. package/src/dataflow/index.js +25 -94
  31. package/src/dataflow/ir-cache.js +268 -0
  32. package/src/dataflow/privacy-taint.js +7 -0
  33. package/src/dataflow/summaries.js +72 -6
  34. package/src/dataflow/tabulation.js +80 -24
  35. package/src/engine.js +113 -8
  36. package/src/graph/CLAUDE.md +31 -0
  37. package/src/graph/adapters/artifact.js +81 -0
  38. package/src/graph/adapters/crossrepo.js +75 -0
  39. package/src/graph/adapters/dataflow.js +76 -0
  40. package/src/graph/adapters/provenance.js +92 -0
  41. package/src/graph/adapters/semantic.js +89 -0
  42. package/src/graph/crosswalk-builders.js +152 -0
  43. package/src/graph/crosswalk.js +146 -0
  44. package/src/graph/index.js +15 -0
  45. package/src/graph/observation.js +57 -0
  46. package/src/graph/refs.js +105 -0
  47. package/src/graph/registry.js +129 -0
  48. package/src/graph/relations.js +81 -0
  49. package/src/graph/scc.js +241 -0
  50. package/src/graph/view.js +254 -0
  51. package/src/ir/CLAUDE.md +4 -0
  52. package/src/ir/callgraph.js +36 -8
  53. package/src/ir/index.js +18 -4
  54. package/src/ir/parser-js.js +10 -0
  55. package/src/language/CLAUDE.md +13 -0
  56. package/src/language/nix-option-types.js +170 -0
  57. package/src/language/nix-script-taint.js +46 -3
  58. package/src/language/nix-secrets.js +20 -2
  59. package/src/lineage/CLAUDE.md +72 -8
  60. package/src/lineage/DESIGN_GRAPH_BUILDER.md +1 -1
  61. package/src/lineage/DESIGN_PATH_PROVENANCE.md +6 -0
  62. package/src/lineage/boundary-contract.js +273 -0
  63. package/src/lineage/completion.js +205 -0
  64. package/src/lineage/continuation.js +140 -0
  65. package/src/lineage/control-credit.js +313 -0
  66. package/src/lineage/correlation.js +199 -0
  67. package/src/lineage/coverage.js +8 -1
  68. package/src/lineage/cross-repo-link.js +22 -0
  69. package/src/lineage/cut-planner.js +548 -0
  70. package/src/lineage/driver.js +219 -66
  71. package/src/lineage/engine.js +166 -21
  72. package/src/lineage/export-json.js +5 -0
  73. package/src/lineage/graph-builder.js +84 -7
  74. package/src/lineage/haskell-view.js +59 -0
  75. package/src/lineage/index.js +3 -0
  76. package/src/lineage/nix-view.js +35 -0
  77. package/src/lineage/owned-build.js +77 -0
  78. package/src/lineage/owned-worker-entry.js +22 -0
  79. package/src/lineage/owned-worker.js +95 -0
  80. package/src/lineage/path-evidence.js +123 -0
  81. package/src/lineage/path-predicates.js +529 -0
  82. package/src/lineage/path-query.js +189 -20
  83. package/src/lineage/path-store.js +191 -17
  84. package/src/lineage/scc-solver.js +186 -0
  85. package/src/lineage/smt-orchestrator.js +174 -0
  86. package/src/lineage/smt-z3-backend.js +294 -0
  87. package/src/lineage/source-seeding.js +36 -2
  88. package/src/lineage/summaries.js +66 -4
  89. package/src/lineage/value-versions.js +130 -0
  90. package/src/lineage/witness-selection.js +95 -0
  91. package/src/pipeline/scan-health.js +18 -0
  92. package/src/posture/CLAUDE.md +17 -0
  93. package/src/posture/business-logic.js +16 -7
  94. package/src/posture/dag-commands.js +442 -0
  95. package/src/posture/evidence-bundle.js +1 -1
  96. package/src/posture/finding-defaults.js +19 -0
  97. package/src/posture/git-history.js +91 -1
  98. package/src/posture/witness-bundle.js +573 -0
  99. package/src/posture/witness-runtime.js +276 -0
  100. package/src/report/index.js +2 -0
  101. package/src/sast/CLAUDE.md +2 -0
  102. package/src/sast/_call-args.js +70 -0
  103. package/src/sast/init-scope.js +87 -0
  104. package/src/sast/listen-bind-address.js +49 -0
  105. package/src/sast/redirect-target.js +106 -0
  106. package/src/sast/reflected-input.js +76 -0
  107. package/src/sast/send-file-root.js +27 -0
  108. package/src/sast/sensitive-data-logging.js +38 -1
  109. package/dist/119.index.js +0 -197
  110. package/dist/128.index.js +0 -129
  111. package/dist/1293.index.js +0 -5689
  112. package/dist/1336.index.js +0 -16182
  113. package/dist/1351.index.js +0 -133
  114. package/dist/1387.index.js +0 -271
  115. package/dist/1437.index.js +0 -23
  116. package/dist/1445.index.js +0 -110
  117. package/dist/1505.index.js +0 -151
  118. package/dist/1557.index.js +0 -293
  119. package/dist/1621.index.js +0 -311
  120. package/dist/1751.index.js +0 -160
  121. package/dist/1765.index.js +0 -727
  122. package/dist/1861.index.js +0 -690
  123. package/dist/1906.index.js +0 -433
  124. package/dist/208.index.js +0 -1631
  125. package/dist/2223.index.js +0 -159
  126. package/dist/2238.index.js +0 -295
  127. package/dist/2530.index.js +0 -152
  128. package/dist/2565.index.js +0 -116
  129. package/dist/2574.index.js +0 -127
  130. package/dist/2620.index.js +0 -345
  131. package/dist/2773.index.js +0 -98
  132. package/dist/2775.index.js +0 -32
  133. package/dist/2966.index.js +0 -171
  134. package/dist/2972.index.js +0 -87
  135. package/dist/2991.index.js +0 -131
  136. package/dist/3063.index.js +0 -833
  137. package/dist/3075.index.js +0 -227
  138. package/dist/3121.index.js +0 -297
  139. package/dist/3314.index.js +0 -263
  140. package/dist/3480.index.js +0 -1822
  141. package/dist/3481.index.js +0 -24
  142. package/dist/3506.index.js +0 -268
  143. package/dist/3533.index.js +0 -591
  144. package/dist/3653.index.js +0 -450
  145. package/dist/3740.index.js +0 -722
  146. package/dist/3822.index.js +0 -131
  147. package/dist/3868.index.js +0 -292
  148. package/dist/3918.index.js +0 -192
  149. package/dist/4090.index.js +0 -288
  150. package/dist/4113.index.js +0 -1286
  151. package/dist/4121.index.js +0 -1190
  152. package/dist/4142.index.js +0 -690
  153. package/dist/4168.index.js +0 -509
  154. package/dist/4281.index.js +0 -993
  155. package/dist/4336.index.js +0 -436
  156. package/dist/4387.index.js +0 -532
  157. package/dist/4413.index.js +0 -302
  158. package/dist/4476.index.js +0 -4510
  159. package/dist/4491.index.js +0 -133
  160. package/dist/4538.index.js +0 -185
  161. package/dist/4684.index.js +0 -319
  162. package/dist/4740.index.js +0 -165
  163. package/dist/4780.index.js +0 -209
  164. package/dist/4802.index.js +0 -225
  165. package/dist/4812.index.js +0 -379
  166. package/dist/4835.index.js +0 -126
  167. package/dist/494.index.js +0 -226
  168. package/dist/4991.index.js +0 -549
  169. package/dist/5199.index.js +0 -305
  170. package/dist/5216.index.js +0 -109
  171. package/dist/5439.index.js +0 -301
  172. package/dist/5443.index.js +0 -97
  173. package/dist/5496.index.js +0 -377
  174. package/dist/5738.index.js +0 -240
  175. package/dist/5801.index.js +0 -588
  176. package/dist/5817.index.js +0 -714
  177. package/dist/5858.index.js +0 -223
  178. package/dist/5933.index.js +0 -143
  179. package/dist/601.index.js +0 -23
  180. package/dist/6173.index.js +0 -273
  181. package/dist/6291.index.js +0 -1871
  182. package/dist/6312.index.js +0 -666
  183. package/dist/634.index.js +0 -16182
  184. package/dist/644.index.js +0 -87
  185. package/dist/6508.index.js +0 -283
  186. package/dist/6560.index.js +0 -645
  187. package/dist/6576.index.js +0 -422
  188. package/dist/6579.index.js +0 -271
  189. package/dist/6655.index.js +0 -3221
  190. package/dist/6745.index.js +0 -305
  191. package/dist/6818.index.js +0 -21642
  192. package/dist/6932.index.js +0 -1190
  193. package/dist/6972.index.js +0 -167
  194. package/dist/6995.index.js +0 -163
  195. package/dist/7249.index.js +0 -191
  196. package/dist/7372.index.js +0 -1197
  197. package/dist/7546.index.js +0 -541
  198. package/dist/76.index.js +0 -448
  199. package/dist/7879.index.js +0 -163
  200. package/dist/8025.index.js +0 -130
  201. package/dist/8054.index.js +0 -248
  202. package/dist/808.index.js +0 -1330
  203. package/dist/8097.index.js +0 -201
  204. package/dist/8126.index.js +0 -191
  205. package/dist/8178.index.js +0 -78
  206. package/dist/8382.index.js +0 -93
  207. package/dist/8408.index.js +0 -261
  208. package/dist/8540.index.js +0 -174
  209. package/dist/8635.index.js +0 -802
  210. package/dist/8688.index.js +0 -410
  211. package/dist/8699.index.js +0 -779
  212. package/dist/8891.index.js +0 -457
  213. package/dist/8916.index.js +0 -885
  214. package/dist/9146.index.js +0 -170
  215. package/dist/9168.index.js +0 -841
  216. package/dist/9292.index.js +0 -369
  217. package/dist/9422.index.js +0 -866
  218. package/dist/9440.index.js +0 -453
  219. package/dist/9479.index.js +0 -152
  220. package/dist/9481.index.js +0 -220
  221. package/dist/9539.index.js +0 -100
  222. package/dist/9547.index.js +0 -103
  223. package/dist/9692.index.js +0 -90
  224. package/dist/9800.index.js +0 -462
  225. package/dist/9899.index.js +0 -138
  226. package/dist/9981.index.js +0 -206
  227. package/dist/999.index.js +0 -117
  228. package/dist/9999.index.js +0 -1698
@@ -1,377 +0,0 @@
1
- export const id = 5496;
2
- export const ids = [5496,4780];
3
- export const modules = {
4
-
5
- /***/ 44780:
6
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7
-
8
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9
- /* harmony export */ iI: () => (/* binding */ summarizeForBadge),
10
- /* harmony export */ renderBadge: () => (/* binding */ renderBadge)
11
- /* harmony export */ });
12
- /* unused harmony exports badgeFromScanRoot, renderSvg, _internal */
13
- /* harmony import */ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73024);
14
- /* harmony import */ var node_path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(76760);
15
- /* harmony import */ var _posture_state_dir_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(69259);
16
- // Live SVG badge generator (v0.72).
17
- //
18
- // Every repo can drop a badge in its README pulling from the latest scan:
19
- //
20
- // ![agentic-security](https://agentic-security.dev/badge?repo=<slug>)
21
- //
22
- // or self-hosted via the CLI subcommand emitting an inline <img> URL or
23
- // a static SVG. The badge format borrows from shields.io for visual
24
- // consistency. Reads from .agentic-security/last-scan.json or accepts a
25
- // scan object directly.
26
- //
27
- // Output formats:
28
- // - 'svg' — inline SVG string (default; the bytes you'd serve)
29
- // - 'json' — { label, count, color, severity } for a frontend renderer
30
- //
31
- // Style variants:
32
- // - 'flat' — shields.io flat
33
- // - 'for-the-badge' — caps + thicker
34
- //
35
- // Color is driven by the highest non-zero severity:
36
- // critical → red
37
- // high → orange
38
- // medium → yellow
39
- // low → blue
40
- // info → lightgrey
41
- // none → brightgreen
42
-
43
-
44
-
45
-
46
-
47
- const COLORS = {
48
- critical: '#e05d44', // red
49
- high: '#fe7d37', // orange
50
- medium: '#dfb317', // yellow
51
- low: '#007ec6', // blue
52
- info: '#9f9f9f', // grey
53
- none: '#4c1', // brightgreen
54
- label: '#555',
55
- };
56
-
57
- const SEVERITIES = ['critical', 'high', 'medium', 'low', 'info'];
58
-
59
- function _readLastScan(scanRoot) {
60
- if (!scanRoot) return null;
61
- const fp = (0,_posture_state_dir_js__WEBPACK_IMPORTED_MODULE_2__.statePath)(scanRoot, 'last-scan.json');
62
- if (!node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(fp)) return null;
63
- try { return JSON.parse(node_fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(fp, 'utf8')); }
64
- catch { return null; }
65
- }
66
-
67
- function _ageString(ts) {
68
- if (!ts) return null;
69
- const ageMs = Date.now() - new Date(ts).getTime();
70
- if (isNaN(ageMs) || ageMs < 0) return null;
71
- const min = Math.floor(ageMs / 60_000);
72
- if (min < 60) return `${min}m ago`;
73
- const hr = Math.floor(min / 60);
74
- if (hr < 24) return `${hr}h ago`;
75
- const day = Math.floor(hr / 24);
76
- return `${day}d ago`;
77
- }
78
-
79
- /**
80
- * Compute the badge value from a scan object.
81
- *
82
- * Returns:
83
- * {
84
- * label: 'agentic-security',
85
- * summary: 'critical 0 · high 2 · medium 5' | 'passing' | 'no scan',
86
- * color: '#fe7d37',
87
- * highest: 'high' | 'none' | 'unknown',
88
- * ageStr: '4h ago' | null,
89
- * counts: { critical, high, medium, low, info },
90
- * total: 7,
91
- * }
92
- */
93
- function summarizeForBadge(scan) {
94
- if (!scan || !Array.isArray(scan.findings)) {
95
- return {
96
- label: 'agentic-security',
97
- summary: 'no scan',
98
- color: COLORS.info,
99
- highest: 'unknown',
100
- ageStr: null,
101
- counts: { critical: 0, high: 0, medium: 0, low: 0, info: 0 },
102
- total: 0,
103
- };
104
- }
105
- const counts = { critical: 0, high: 0, medium: 0, low: 0, info: 0 };
106
- for (const f of scan.findings) {
107
- const s = f.severity || 'info';
108
- if (counts[s] !== undefined) counts[s]++;
109
- }
110
- let highest = 'none';
111
- for (const s of SEVERITIES) { if (counts[s] > 0) { highest = s; break; } }
112
- const color = COLORS[highest] || COLORS.info;
113
- const summary = highest === 'none'
114
- ? 'passing'
115
- : `crit ${counts.critical} · high ${counts.high} · med ${counts.medium}`;
116
- const total = SEVERITIES.reduce((a, s) => a + counts[s], 0);
117
- return {
118
- label: 'agentic-security',
119
- summary,
120
- color,
121
- highest,
122
- ageStr: _ageString(scan.timestamp || scan.when || scan.lastScan),
123
- counts,
124
- total,
125
- };
126
- }
127
-
128
- /**
129
- * Compute the badge from .agentic-security/last-scan.json under `scanRoot`.
130
- */
131
- function badgeFromScanRoot(scanRoot) {
132
- return summarizeForBadge(_readLastScan(scanRoot));
133
- }
134
-
135
- function _xmlEscape(s) {
136
- return String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
137
- }
138
-
139
- function _textWidth(s) {
140
- // Rough character width — works fine for the small badge label range.
141
- return s.length * 7 + 10;
142
- }
143
-
144
- /**
145
- * Render an inline SVG matching shields.io's flat style. Self-contained
146
- * (no external font references) so the badge works in any README.
147
- */
148
- function renderSvg(b, opts = {}) {
149
- if (!b) b = summarizeForBadge(null);
150
- const style = opts.style || 'flat';
151
- const labelText = b.label;
152
- const valueText = b.ageStr ? `${b.summary} · ${b.ageStr}` : b.summary;
153
- const lblW = _textWidth(labelText);
154
- const valW = _textWidth(valueText);
155
- const totalW = lblW + valW;
156
- const h = style === 'for-the-badge' ? 28 : 20;
157
- const fontSize = style === 'for-the-badge' ? 12 : 11;
158
- return `<svg xmlns="http://www.w3.org/2000/svg" width="${totalW}" height="${h}" role="img" aria-label="${_xmlEscape(labelText)}: ${_xmlEscape(valueText)}">
159
- <title>${_xmlEscape(labelText)}: ${_xmlEscape(valueText)}</title>
160
- <linearGradient id="s" x2="0" y2="100%">
161
- <stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
162
- <stop offset="1" stop-opacity=".1"/>
163
- </linearGradient>
164
- <clipPath id="r"><rect width="${totalW}" height="${h}" rx="3" fill="#fff"/></clipPath>
165
- <g clip-path="url(#r)">
166
- <rect width="${lblW}" height="${h}" fill="${COLORS.label}"/>
167
- <rect x="${lblW}" width="${valW}" height="${h}" fill="${b.color}"/>
168
- <rect width="${totalW}" height="${h}" fill="url(#s)"/>
169
- </g>
170
- <g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="${fontSize}">
171
- <text aria-hidden="true" x="${lblW / 2}" y="${h - 6}" fill="#010101" fill-opacity=".3">${_xmlEscape(labelText)}</text>
172
- <text x="${lblW / 2}" y="${h - 7}">${_xmlEscape(labelText)}</text>
173
- <text aria-hidden="true" x="${lblW + valW / 2}" y="${h - 6}" fill="#010101" fill-opacity=".3">${_xmlEscape(valueText)}</text>
174
- <text x="${lblW + valW / 2}" y="${h - 7}">${_xmlEscape(valueText)}</text>
175
- </g>
176
- </svg>`;
177
- }
178
-
179
- /**
180
- * Public entry: produce the badge in the requested format.
181
- *
182
- * format: 'svg' (default) | 'json'
183
- * style: 'flat' (default) | 'for-the-badge'
184
- * scanRoot: directory containing .agentic-security/last-scan.json
185
- * scan: pre-loaded scan object (skips disk read)
186
- */
187
- function renderBadge({ format = 'svg', style = 'flat', scanRoot, scan } = {}) {
188
- const summary = summarizeForBadge(scan || _readLastScan(scanRoot));
189
- if (format === 'json') {
190
- return JSON.stringify({
191
- schemaVersion: 1,
192
- label: summary.label,
193
- message: summary.summary,
194
- color: summary.color,
195
- highest: summary.highest,
196
- ageStr: summary.ageStr,
197
- counts: summary.counts,
198
- total: summary.total,
199
- });
200
- }
201
- return renderSvg(summary, { style });
202
- }
203
-
204
- const _internal = { COLORS, _ageString, _readLastScan };
205
-
206
-
207
- /***/ }),
208
-
209
- /***/ 55496:
210
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
211
-
212
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
213
- /* harmony export */ leaderboardRowFor: () => (/* binding */ leaderboardRowFor)
214
- /* harmony export */ });
215
- /* unused harmony exports rankRows, _internal */
216
- /* harmony import */ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73024);
217
- /* harmony import */ var node_path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(76760);
218
- /* harmony import */ var _badge_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(44780);
219
- /* harmony import */ var _posture_state_dir_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(69259);
220
- // Leaderboard backend (v0.72).
221
- //
222
- // Generates the data shape that powers the future public leaderboard at
223
- // agentic-security.dev/leaderboard. The leaderboard ranks repos by their
224
- // security posture under our scanner — F1-on-CVE-history when we can
225
- // compute it, otherwise just last-scan severity counts.
226
- //
227
- // Public hosting of the site is deferred — we ship the data side now so
228
- // the future site is a thin frontend over this JSON.
229
- //
230
- // One leaderboard row per repo:
231
- //
232
- // {
233
- // repo: 'owner/name',
234
- // score: { critical, high, medium, low, info, total },
235
- // postureGrade: 'A' | 'B' | 'C' | 'D' | 'F',
236
- // lastScanAge: '4h',
237
- // topCwe: 'CWE-89',
238
- // deltaTrend: 'improving' | 'flat' | 'regressing',
239
- // badgeUrl: 'https://agentic-security.dev/badge?repo=…',
240
- // }
241
- //
242
- // The grader is intentionally coarse — single letter — so the leaderboard
243
- // stays scannable. Tie-break by lowest critical-count, then by recency.
244
-
245
-
246
-
247
-
248
-
249
-
250
- // Grade thresholds. Critical findings dominate; high/medium contribute
251
- // secondarily. These numbers are heuristic — calibrate against the
252
- // public leaderboard corpus once data lands.
253
- function _postureGrade(counts) {
254
- if (!counts) return 'F';
255
- const c = counts.critical || 0;
256
- const h = counts.high || 0;
257
- const m = counts.medium || 0;
258
- if (c === 0 && h === 0 && m === 0) return 'A';
259
- if (c === 0 && h === 0 && m <= 5) return 'B';
260
- if (c === 0 && h <= 2) return 'C';
261
- if (c <= 1 && h <= 5) return 'D';
262
- return 'F';
263
- }
264
-
265
- function _ageString(ts) {
266
- if (!ts) return null;
267
- const ageMs = Date.now() - new Date(ts).getTime();
268
- if (isNaN(ageMs) || ageMs < 0) return null;
269
- const min = Math.floor(ageMs / 60_000);
270
- if (min < 60) return `${min}m`;
271
- const hr = Math.floor(min / 60);
272
- if (hr < 24) return `${hr}h`;
273
- const day = Math.floor(hr / 24);
274
- return `${day}d`;
275
- }
276
-
277
- function _topCwe(scan) {
278
- if (!scan || !Array.isArray(scan.findings)) return null;
279
- const counts = new Map();
280
- for (const f of scan.findings) {
281
- if (!f.cwe) continue;
282
- counts.set(f.cwe, (counts.get(f.cwe) || 0) + 1);
283
- }
284
- let topCwe = null, topN = 0;
285
- for (const [cwe, n] of counts) {
286
- if (n > topN) { topCwe = cwe; topN = n; }
287
- }
288
- return topCwe;
289
- }
290
-
291
- function _deltaTrend(history) {
292
- // history: array of past scan summaries with `.timestamp` + `.severityCounts.critical`
293
- if (!Array.isArray(history) || history.length < 2) return 'flat';
294
- const recent = history.slice(-3);
295
- const first = recent[0].severityCounts || {};
296
- const last = recent[recent.length - 1].severityCounts || {};
297
- const fScore = (first.critical || 0) * 4 + (first.high || 0);
298
- const lScore = (last.critical || 0) * 4 + (last.high || 0);
299
- if (lScore < fScore - 1) return 'improving';
300
- if (lScore > fScore + 1) return 'regressing';
301
- return 'flat';
302
- }
303
-
304
- /**
305
- * Build a single leaderboard row for a repo. Reads the latest scan from
306
- * `<scanRoot>/.agentic-security/last-scan.json` and (optionally) history
307
- * from `<scanRoot>/.agentic-security/scan-history.jsonl`.
308
- *
309
- * `repo` is the GitHub slug ('owner/name'); used to drive the badge URL.
310
- */
311
- function leaderboardRowFor({ scanRoot, repo, badgeBase = 'https://agentic-security.dev/badge' } = {}) {
312
- if (!repo) throw new Error('leaderboardRowFor: repo slug is required');
313
- const lastScanPath = (0,_posture_state_dir_js__WEBPACK_IMPORTED_MODULE_3__.statePath)(scanRoot || '.', 'last-scan.json');
314
- let scan = null;
315
- try { scan = JSON.parse(node_fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(lastScanPath, 'utf8')); } catch {}
316
- const summary = (0,_badge_js__WEBPACK_IMPORTED_MODULE_2__/* .summarizeForBadge */ .iI)(scan);
317
- const grade = _postureGrade(summary.counts);
318
- const topCwe = _topCwe(scan);
319
-
320
- // Optional scan history for the trend signal.
321
- const historyPath = (0,_posture_state_dir_js__WEBPACK_IMPORTED_MODULE_3__.statePath)(scanRoot || '.', 'scan-history.jsonl');
322
- let history = [];
323
- if (node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(historyPath)) {
324
- try {
325
- history = node_fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(historyPath, 'utf8').split('\n')
326
- .map(l => l.trim()).filter(Boolean)
327
- .map(l => { try { return JSON.parse(l); } catch { return null; } })
328
- .filter(Boolean);
329
- } catch {}
330
- }
331
- const deltaTrend = _deltaTrend(history);
332
-
333
- return {
334
- repo,
335
- score: { ...summary.counts, total: summary.total },
336
- postureGrade: grade,
337
- lastScanAge: _ageString(scan?.timestamp || scan?.when),
338
- topCwe,
339
- deltaTrend,
340
- badgeUrl: `${badgeBase}?repo=${encodeURIComponent(repo)}`,
341
- badgeMarkdown: `![agentic-security](${badgeBase}?repo=${encodeURIComponent(repo)})`,
342
- };
343
- }
344
-
345
- /**
346
- * Rank a list of rows for the leaderboard. Sort by:
347
- * 1. lower critical count
348
- * 2. lower high count
349
- * 3. higher postureGrade (A > F)
350
- * 4. fresher lastScanAge
351
- *
352
- * Returns the input rows annotated with `rank` (1-indexed).
353
- */
354
- function rankRows(rows) {
355
- if (!Array.isArray(rows)) return [];
356
- const gradeOrder = { A: 0, B: 1, C: 2, D: 3, F: 4 };
357
- const sorted = [...rows].sort((a, b) => {
358
- const ac = a.score?.critical || 0;
359
- const bc = b.score?.critical || 0;
360
- if (ac !== bc) return ac - bc;
361
- const ah = a.score?.high || 0;
362
- const bh = b.score?.high || 0;
363
- if (ah !== bh) return ah - bh;
364
- const ag = gradeOrder[a.postureGrade] ?? 5;
365
- const bg = gradeOrder[b.postureGrade] ?? 5;
366
- if (ag !== bg) return ag - bg;
367
- return 0;
368
- });
369
- return sorted.map((r, i) => ({ ...r, rank: i + 1 }));
370
- }
371
-
372
- const _internal = { _postureGrade, _ageString, _topCwe, _deltaTrend };
373
-
374
-
375
- /***/ })
376
-
377
- };
@@ -1,240 +0,0 @@
1
- export const id = 5738;
2
- export const ids = [5738];
3
- export const modules = {
4
-
5
- /***/ 35738:
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
- cmdProof: () => (/* binding */ cmdProof),
14
- cmdProve: () => (/* binding */ cmdProve),
15
- formatResult: () => (/* binding */ formatResult),
16
- loadReproducerFor: () => (/* binding */ loadReproducerFor)
17
- });
18
-
19
- // EXTERNAL MODULE: external "node:fs"
20
- var external_node_fs_ = __webpack_require__(73024);
21
- // EXTERNAL MODULE: external "node:os"
22
- var external_node_os_ = __webpack_require__(48161);
23
- // EXTERNAL MODULE: external "node:path"
24
- var external_node_path_ = __webpack_require__(76760);
25
- // EXTERNAL MODULE: ./src/posture/state-dir.js
26
- var state_dir = __webpack_require__(31174);
27
- // EXTERNAL MODULE: ./src/posture/proof-fabric/orchestrator.js
28
- var orchestrator = __webpack_require__(3740);
29
- // EXTERNAL MODULE: ./src/posture/encryption-provider.js
30
- var encryption_provider = __webpack_require__(39984);
31
- // EXTERNAL MODULE: ./src/llm-validator/redact.js
32
- var redact = __webpack_require__(65388);
33
- // EXTERNAL MODULE: ./src/posture/proof-fabric/reproducer.js
34
- var reproducer = __webpack_require__(37055);
35
- ;// CONCATENATED MODULE: ./src/posture/proof-fabric/store.js
36
- // Proof artifact store: `.agentic-security/proofs/<findingKey>/<recordDigest>.json`.
37
- //
38
- // Reuses the existing state machinery rather than adding another: `safeWriteState` (refuses unsafe dirs and symlinks),
39
- // `maybeEncryptForWrite` / `maybeDecryptForRead` (the `proofs` artifact is registered `confidential`), retention
40
- // (evidence class) and legal holds (a hold on `proofs` blocks purge). Nothing persisted contains a plaintext credential:
41
- // records are passed through a recursive secret filter first, and the runner never returns its per-run nonce or secrets.
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
- const PROOF_RECORD_SCHEMA = 'agentic-security/proof-record';
50
- const PROOFS_DIR = 'proofs';
51
- const MAX_RECORD_BYTES = 512 * 1024;
52
-
53
- const findingKey = (id) => `${String(id).replace(/[^A-Za-z0-9._-]/g, '_').slice(0, 80)}-${(0,reproducer/* sha256 */.sc)(String(id)).slice(0, 8)}`;
54
-
55
- // The shared redactor catches key=value shapes; bare tokens need their own pass, so persisted evidence cannot carry one.
56
- const BARE_SECRET_RES = [
57
- /\b(?:ghp|gho|ghu|ghs|ghr|github_pat)_[A-Za-z0-9_]{20,}\b/g, /\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/g, /\bsk-[A-Za-z0-9_-]{20,}\b/g,
58
- /\bxox[abprs]-[A-Za-z0-9-]{10,}\b/g, /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g,
59
- /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g, /\bSECRET-[0-9a-f]{24}-[a-z0-9_-]+\b/g,
60
- ];
61
- function scrubString(text) {
62
- let t = String(text);
63
- try { t = (0,redact/* redactSecrets */.f)(t).text; } catch { return '[unredactable]'; }
64
- for (const re of BARE_SECRET_RES) t = t.replace(re, '[REDACTED-SECRET]');
65
- return t;
66
- }
67
-
68
- /** Deep-copy `v` with every string passed through the secret redactor. */
69
- function scrubDeep(v) {
70
- if (typeof v === 'string') return scrubString(v);
71
- if (Array.isArray(v)) return v.map(scrubDeep);
72
- if (v && typeof v === 'object') return Object.fromEntries(Object.entries(v).map(([k, x]) => [k, scrubDeep(x)]));
73
- return v;
74
- }
75
-
76
- function recordDigest(record) {
77
- const { recordDigest: _omit, ...rest } = record;
78
- return (0,reproducer/* sha256 */.sc)((0,reproducer/* canonicalize */.dw)(rest));
79
- }
80
-
81
- function saveProof(scanRoot, record) {
82
- const safe = scrubDeep(record);
83
- safe.schema = PROOF_RECORD_SCHEMA;
84
- safe.recordDigest = recordDigest(safe);
85
- const text = JSON.stringify(safe, null, 2);
86
- if (Buffer.byteLength(text) > MAX_RECORD_BYTES) return { ok: false, reason: 'proof record exceeds the size limit' };
87
- if (!(0,state_dir/* ensureStateDir */.xH)(scanRoot)) return { ok: false, reason: 'no safe state directory for this project' };
88
- const enc = (0,encryption_provider/* maybeEncryptForWrite */.v2)(scanRoot, PROOFS_DIR, text);
89
- if (!enc.ok) return { ok: false, reason: enc.reason };
90
- const file = (0,state_dir.statePath)(scanRoot, PROOFS_DIR, findingKey(record.findingId), `${safe.recordDigest}.json`);
91
- if (!(0,state_dir/* safeWriteState */.Ep)(file, enc.content)) return { ok: false, reason: 'state write refused' };
92
- return { ok: true, file, digest: safe.recordDigest, encrypted: enc.encrypted };
93
- }
94
-
95
- function readRecord(file) {
96
- const text = (0,encryption_provider.maybeDecryptForRead)(external_node_fs_.readFileSync(file, 'utf8'));
97
- const rec = JSON.parse(text);
98
- // A record whose content no longer matches its own digest was modified after it was written.
99
- if (rec.recordDigest !== recordDigest(rec)) return { tampered: true, record: rec };
100
- return { tampered: false, record: rec };
101
- }
102
-
103
- /** Newest-first records for a finding. Tampered records are returned flagged, never silently dropped or trusted. */
104
- function listProofs(scanRoot, findingId) {
105
- const dir = (0,state_dir.statePath)(scanRoot, PROOFS_DIR, findingKey(findingId));
106
- let names = [];
107
- try { names = external_node_fs_.readdirSync(dir).filter((n) => n.endsWith('.json')); } catch { return []; }
108
- const out = [];
109
- for (const n of names) {
110
- const f = external_node_path_.join(dir, n);
111
- try { const { tampered, record } = readRecord(f); out.push({ file: f, tampered, record, mtime: external_node_fs_.statSync(f).mtimeMs }); } catch { out.push({ file: f, tampered: true, record: null, mtime: 0 }); }
112
- }
113
- return out.sort((a, b) => b.mtime - a.mtime);
114
- }
115
-
116
- function latestProof(scanRoot, findingId) {
117
- return listProofs(scanRoot, findingId).find((p) => p.record) ?? null;
118
- }
119
-
120
- // EXTERNAL MODULE: ./src/posture/proof-fabric/runner.js
121
- var runner = __webpack_require__(2998);
122
- ;// CONCATENATED MODULE: ./src/posture/proof-fabric/cli.js
123
- // CLI surface for the proof fabric: `proof show|replay|doctor`, `triage exploit|validate`. Non-interactive by design: no
124
- // command reads stdin, every run is bounded by the policy timeouts, and a missing reproducer is a typed exit code, not a
125
- // prompt. Exit codes: 0 confirmed/ok, 1 not confirmed (any reason), 4 usage/precondition.
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
- function loadFinding(root, id) {
137
- const p = (0,state_dir.statePath)(root, 'last-scan.json');
138
- if (!external_node_fs_.existsSync(p)) return null;
139
- const last = JSON.parse(external_node_fs_.readFileSync(p, 'utf8'));
140
- return (last.findings || []).find((f) => f.id === id || f.stableId === id) ?? null;
141
- }
142
-
143
- function loadReproducerFor(root, id, flagPath) { return loadReproducer(root, id, flagPath); }
144
-
145
- function loadReproducer(root, id, flagPath) {
146
- const candidates = [flagPath && external_node_path_.resolve(String(flagPath)), (0,state_dir.statePath)(root, 'reproducers', `${findingKey(id)}.json`)].filter(Boolean);
147
- for (const c of candidates) {
148
- try { return { reproducer: JSON.parse(external_node_fs_.readFileSync(c, 'utf8')), file: c }; } catch { /* next */ }
149
- }
150
- return null;
151
- }
152
-
153
- function formatResult(r) {
154
- const env = r.environment ? `${r.environment.mode} (${r.environment.assurance} assurance)` : 'none';
155
- return [
156
- `Finding: ${r.findingId}`,
157
- `Evidence: ${r.state}`,
158
- `Oracle: ${r.oracle}`,
159
- `Reproductions: ${r.attempts?.successes ?? 0}/${r.attempts?.run ?? 0} (required ${r.attempts?.required})`,
160
- `Independent replay: ${r.independentReplay?.status ?? 'not-run'}`,
161
- `Environment: ${env}`,
162
- `Completeness: ${r.completeness}`,
163
- `Duration: ${(r.timing.proofMs / 1000).toFixed(1)}s`,
164
- ...(r.degradation?.length ? [`Degraded: ${r.degradation.join(', ')}`] : []),
165
- ...(r.note ? [`Note: ${r.note}`] : []),
166
- ].join('\n');
167
- }
168
-
169
- async function cmdProve(args, root, { json = false } = {}) {
170
- const id = String(args._[2] ?? '');
171
- if (!id) { console.error('usage: triage exploit <finding-id> --prove [--reproducer file] [--attempts N] [--required N]'); return 4; }
172
- const finding = loadFinding(root, id);
173
- if (!finding) { console.error(`Finding ${id} not found in last scan.`); return 4; }
174
- const loaded = loadReproducer(root, id, args.flags.reproducer);
175
- if (!loaded) { console.error(`No reproducer for ${id}. Supply one with --reproducer <file> or place it at .agentic-security/reproducers/. Nothing was executed.`); return 4; }
176
- const errs = (0,reproducer/* validateReproducer */.mC)(loaded.reproducer);
177
- if (errs.length) { console.error(`Invalid reproducer: ${errs.join('; ')}`); return 4; }
178
- const policy = {};
179
- if (args.flags.attempts) policy.attempts = Number(args.flags.attempts);
180
- if (args.flags.required) policy.required = Number(args.flags.required);
181
- if (args.flags.timeout) policy.timeoutMs = Number(args.flags.timeout) * 1000;
182
- if (args.flags['require-container']) policy.requireContainer = true;
183
- const ac = new AbortController();
184
- const onSig = () => ac.abort();
185
- process.once('SIGINT', onSig);
186
- let result;
187
- try { result = await (0,orchestrator/* proveFinding */.kO)({ finding, reproducer: loaded.reproducer, revision: args.flags.revision ?? null, policy, signal: ac.signal }); } finally { process.off('SIGINT', onSig); }
188
- const saved = saveProof(root, { ...result, reproducer: loaded.reproducer });
189
- if (json || args.flags.json) console.log(JSON.stringify({ ...result, stored: saved.ok ? saved.file : null }, null, 2));
190
- else { console.log(formatResult(result)); if (!saved.ok) console.log(`(proof not stored: ${saved.reason})`); }
191
- return result.state === 'EXPLOIT_CONFIRMED' ? 0 : 1;
192
- }
193
-
194
- async function cmdProof(args, root) {
195
- const sub = args._[1];
196
- if (sub === 'doctor') return doctor(args);
197
- const id = String(args._[2] ?? '');
198
- if (!id) { console.error('usage: proof show <finding-id> | proof replay <finding-id> | proof doctor'); return 4; }
199
- if (sub === 'show') {
200
- const all = listProofs(root, id);
201
- if (!all.length) { console.error(`No stored proof for ${id}.`); return 4; }
202
- const latest = all.find((p) => p.record);
203
- if (all.some((p) => p.tampered)) console.error(`WARNING: ${all.filter((p) => p.tampered).length} stored record(s) failed their integrity check and are not trusted.`);
204
- const good = all.find((p) => p.record && !p.tampered);
205
- if (!good) { console.error('No intact proof record.'); return 1; }
206
- if (args.flags.json) console.log(JSON.stringify(good.record, null, 2)); else console.log(formatResult(good.record));
207
- void latest;
208
- return 0;
209
- }
210
- if (sub === 'replay') {
211
- const stored = latestProof(root, id);
212
- if (!stored?.record?.reproducer) { console.error(`No stored reproducer for ${id}.`); return 4; }
213
- const tmpDir = external_node_fs_.mkdtempSync(external_node_path_.join(external_node_os_.tmpdir(), 'proof-replay-'));
214
- const tmp = external_node_path_.join(tmpDir, 'reproducer.json');
215
- external_node_fs_.writeFileSync(tmp, JSON.stringify(stored.record.reproducer));
216
- args.flags.reproducer = tmp;
217
- args._ = ['triage', 'exploit', id];
218
- try { return await cmdProve(args, root); } finally { external_node_fs_.rmSync(tmpDir, { recursive: true, force: true }); }
219
- }
220
- console.error('usage: proof show|replay <finding-id> | proof doctor');
221
- return 4;
222
- }
223
-
224
- function doctor(args) {
225
- const tools = (0,runner/* hostTools */.qV)();
226
- const rows = reproducer/* LANGUAGES */.Yj.map((l) => ({ lang: l, ...(0,runner/* languageSupport */.ql)(l, tools) }));
227
- const envs = ['javascript', 'python'].map((l) => ({ lang: l, ...(0,runner/* selectEnvironment */.aP)({ lang: l }) }));
228
- if (args.flags.json) { console.log(JSON.stringify({ tools, languages: rows, environments: envs }, null, 2)); return 0; }
229
- console.log('Proof fabric doctor');
230
- for (const r of rows) console.log(` ${r.lang.padEnd(11)} ${r.supported ? 'supported' : `unsupported (${r.reason})`}`);
231
- for (const e of envs) console.log(` environment for ${e.lang}: ${e.mode}, ${e.assurance} assurance${e.reason ? ` (${e.reason})` : ''}${e.containerSkipped ? `; container skipped: ${e.containerSkipped}` : ''}`);
232
- const usable = envs.some((e) => e.mode !== 'unavailable');
233
- if (!usable) console.log(' RESULT: no execution environment available; proofs will report blocked, never clean.');
234
- return usable ? 0 : 1;
235
- }
236
-
237
-
238
- /***/ })
239
-
240
- };