@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,301 +0,0 @@
1
- export const id = 5439;
2
- export const ids = [5439,119];
3
- export const modules = {
4
-
5
- /***/ 35439:
6
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7
-
8
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9
- /* harmony export */ analyzeLayerSecrets: () => (/* binding */ analyzeLayerSecrets)
10
- /* harmony export */ });
11
- /* unused harmony export DEFAULT_SECRET_SCAN_LIMITS */
12
- /* harmony import */ var _safe_tar_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(30119);
13
- // PRD 5 P0 §3 — Layer Secret Analysis: a secret added in one layer and later
14
- // deleted (via an overlay whiteout) is still sitting in that earlier layer's
15
- // raw tar bytes inside the image archive — recoverable by anyone who has the
16
- // archive, even though it is invisible in `docker run`'s final filesystem.
17
- //
18
- // The actual credential detection is INJECTED as `detectFn` (the exact
19
- // `(filePath, rawText) -> Finding[]` shape `src/posture/secret-history.js`
20
- // already uses for the git-history analog of this same idea), so this module
21
- // never imports `engine.js` and stays a pure, independently-testable
22
- // transform over the layer data `filesystem.js` already extracted. The
23
- // injected detector (`scanCredentials`) already returns only redacted/masked
24
- // values (`masked`, a redacted `snippet`) — this module never re-touches raw
25
- // file content once a finding exists, so there is no second place a value
26
- // could leak back in.
27
-
28
-
29
- const DEFAULT_SECRET_SCAN_LIMITS = Object.freeze({
30
- maxFileBytes: 512 * 1024,
31
- });
32
-
33
- /**
34
- * `readLayersResult` is `filesystem.js#readLayers`'s output (ordered,
35
- * per-layer, pre-merge entries — the only shape that preserves "this path
36
- * existed in layer 3" even after a later layer's whiteout removes it from
37
- * the merged view). `deletedPaths` is `mergeLayers`'s output.
38
- *
39
- * Returns `{ findings, deletedButRecoverable, materializationSkipped }`:
40
- * - `findings`: every detector hit across every layer's added files, each
41
- * tagged with `path`/`layerIndex` and the detector's own (already
42
- * redacted) finding fields — this is the full history sweep, not just
43
- * the deleted-but-recoverable subset.
44
- * - `deletedButRecoverable`: the subset of `findings` whose `path` was
45
- * later removed by a whiteout in a LATER layer — PRD 5's named scenario.
46
- * - `materializationSkipped`: paths whose content was too large to scan
47
- * (disclosed, never silently treated as "no secret found").
48
- */
49
- function analyzeLayerSecrets({ readLayersResult, deletedPaths, detectFn, limits = DEFAULT_SECRET_SCAN_LIMITS }) {
50
- if (typeof detectFn !== 'function') throw new TypeError('analyzeLayerSecrets requires a detectFn(filePath, rawText) -> Finding[]');
51
- if (!readLayersResult || !Array.isArray(readLayersResult.layers)) throw new TypeError('analyzeLayerSecrets requires filesystem.js#readLayers output');
52
-
53
- const deletedAtByPath = new Map(); // path -> earliest layer index that deleted it
54
- for (const d of deletedPaths || []) {
55
- if (d.opaque) continue; // opaque-directory deletions are reported separately below
56
- if (!deletedAtByPath.has(d.path) || d.deletedAtLayer < deletedAtByPath.get(d.path)) {
57
- deletedAtByPath.set(d.path, d.deletedAtLayer);
58
- }
59
- }
60
- const opaqueDirs = (deletedPaths || []).filter((d) => d.opaque);
61
-
62
- const findings = [];
63
- const materializationSkipped = [];
64
-
65
- for (const { layerIndex, entries } of readLayersResult.layers) {
66
- for (const e of entries) {
67
- if ((0,_safe_tar_js__WEBPACK_IMPORTED_MODULE_0__/* .isWhiteoutName */ .l0)(e.name)) continue;
68
- if (e.typeflag !== '0' && e.typeflag !== '') continue; // regular files only
69
- if (e.size > limits.maxFileBytes) {
70
- materializationSkipped.push({ path: e.name, layerIndex, sizeBytes: e.size });
71
- continue;
72
- }
73
- let text;
74
- try {
75
- text = e.data.toString('utf8');
76
- } catch {
77
- continue; // not decodable as text — not a candidate for a text-pattern secret scan
78
- }
79
- let hits;
80
- try {
81
- hits = detectFn(e.name, text) || [];
82
- } catch {
83
- hits = []; // a detector failure on hostile/malformed content must never abort the sweep
84
- }
85
- for (const hit of hits) {
86
- const deletedAtLayer = deletedAtByPath.has(e.name) && deletedAtByPath.get(e.name) > layerIndex
87
- ? deletedAtByPath.get(e.name)
88
- : null;
89
- const underOpaqueDir = opaqueDirs.some((d) => d.deletedAtLayer > layerIndex && (e.name === d.path || e.name.startsWith(`${d.path}/`)));
90
- findings.push({
91
- ...hit,
92
- path: e.name,
93
- addedAtLayer: layerIndex,
94
- deletedAtLayer: deletedAtLayer ?? (underOpaqueDir ? opaqueDirs.find((d) => d.deletedAtLayer > layerIndex && (e.name === d.path || e.name.startsWith(`${d.path}/`))).deletedAtLayer : null),
95
- recoverable: deletedAtLayer != null || underOpaqueDir,
96
- });
97
- }
98
- }
99
- }
100
-
101
- const deletedButRecoverable = findings.filter((f) => f.recoverable);
102
-
103
- return { findings, deletedButRecoverable, materializationSkipped };
104
- }
105
-
106
-
107
- /***/ }),
108
-
109
- /***/ 30119:
110
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
111
-
112
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
113
- /* harmony export */ ET: () => (/* binding */ readTarEntries),
114
- /* harmony export */ Jn: () => (/* binding */ whiteoutTarget),
115
- /* harmony export */ TarSafetyError: () => (/* binding */ TarSafetyError),
116
- /* harmony export */ dR: () => (/* binding */ DEFAULT_LIMITS),
117
- /* harmony export */ l0: () => (/* binding */ isWhiteoutName),
118
- /* harmony export */ zr: () => (/* binding */ decompressIfGzip)
119
- /* harmony export */ });
120
- /* unused harmony export isSafeEntryName */
121
- /* harmony import */ var node_zlib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(38522);
122
- // Hand-rolled, hardened POSIX/GNU tar reader for OCI/Docker image archives.
123
- //
124
- // Why hand-rolled instead of a dependency: this repo has no tar library (see
125
- // `src/artifact/CLAUDE.md`), and PRD 5's own Safety Requirements ask for exact
126
- // control over the failure modes a generic tar library treats as implementation
127
- // detail: malicious entry paths, decompression bombs, giant layers, oversized
128
- // archives. Rolling it ourselves means every one of those limits is a named,
129
- // tested constant in this file rather than a library default we'd have to audit.
130
- //
131
- // Scope: ustar + GNU longname ('L' typeflag) + base-256 size fields. PAX extended
132
- // headers ('x'/'g') and GNU longlink ('K') are structurally skipped (their data
133
- // block is consumed so offsets stay correct, but their content is not applied) —
134
- // a disclosed limitation, not a silent one. Real docker-save/oci-archive output
135
- // from Go's archive/tar for images in this size/complexity class essentially
136
- // never needs them; synthetic fixtures in this codebase never emit them either.
137
-
138
-
139
- const BLOCK = 512;
140
-
141
- const DEFAULT_LIMITS = Object.freeze({
142
- maxEntries: 200_000,
143
- maxEntrySize: 512 * 1024 * 1024, // 512MB per tar entry
144
- maxTotalSize: 4 * 1024 * 1024 * 1024, // 4GB per archive (sum of entry sizes)
145
- maxGunzipOutput: 4 * 1024 * 1024 * 1024, // decompression-bomb guard
146
- });
147
-
148
- class TarSafetyError extends Error {
149
- constructor(message, code) {
150
- super(message);
151
- this.name = 'TarSafetyError';
152
- this.code = code;
153
- }
154
- }
155
-
156
- function parseSizeField(buf) {
157
- if (buf[0] & 0x80) {
158
- // GNU base-256 extension for sizes that don't fit in octal-ASCII.
159
- let n = 0n;
160
- for (let i = 1; i < buf.length; i++) n = (n << 8n) | BigInt(buf[i]);
161
- return Number(n);
162
- }
163
- const s = buf.toString('ascii').replace(/\0.*$/, '').trim();
164
- if (!s) return 0;
165
- const n = parseInt(s, 8);
166
- return Number.isFinite(n) ? n : 0;
167
- }
168
-
169
- function cstr(buf) {
170
- return buf.toString('utf8').replace(/\0.*$/, '');
171
- }
172
-
173
- // A tar entry name is unsafe when it would escape a virtual extraction root:
174
- // absolute paths, `..` segments, embedded NULs, or an unreasonable length.
175
- // Because this module never writes to a real filesystem path (every caller
176
- // keeps extracted content in an in-memory Map keyed by this string), the
177
- // classic zip-slip *write* vulnerability cannot occur here — but a hostile
178
- // name must still never be silently treated as an ordinary path by downstream
179
- // manifest/package-DB matching, so unsafe entries are flagged, never dropped
180
- // silently and never accepted as-is.
181
- function isSafeEntryName(name) {
182
- if (typeof name !== 'string' || name.length === 0 || name.length > 4096) return false;
183
- if (name.includes('\0')) return false;
184
- const norm = name.replace(/\\/g, '/');
185
- if (norm.startsWith('/')) return false;
186
- if (norm.split('/').some((p) => p === '..')) return false;
187
- return true;
188
- }
189
-
190
- function isWhiteoutName(name) {
191
- return (name.split('/').pop() || '').startsWith('.wh.');
192
- }
193
-
194
- // Resolves a whiteout entry name to what it deletes. `.wh..wh..opq` marks a
195
- // directory as "opaque" (everything from earlier layers under it is hidden,
196
- // not individually deleted) — reported distinctly so callers don't conflate
197
- // it with a single-file deletion.
198
- function whiteoutTarget(name) {
199
- const parts = name.split('/');
200
- const base = parts.pop();
201
- if (base === '.wh..wh..opq') return { opaque: true, dir: parts.join('/') };
202
- return { opaque: false, path: [...parts, base.slice(4)].join('/') };
203
- }
204
-
205
- // Decompresses a gzip member with a hard output-size cap (Node's native
206
- // ERR_BUFFER_TOO_LARGE on overflow — no custom streaming counter needed).
207
- // Returns the input unchanged when it isn't gzip-magic (plain tar).
208
- function decompressIfGzip(buf, limits = DEFAULT_LIMITS) {
209
- if (buf.length >= 2 && buf[0] === 0x1f && buf[1] === 0x8b) {
210
- try {
211
- return node_zlib__WEBPACK_IMPORTED_MODULE_0__.gunzipSync(buf, { maxOutputLength: limits.maxGunzipOutput });
212
- } catch (err) {
213
- if (err && err.code === 'ERR_BUFFER_TOO_LARGE') {
214
- throw new TarSafetyError('decompressed layer exceeds the decompression-bomb guard', 'gunzip_too_large');
215
- }
216
- throw new TarSafetyError(`gzip stream is malformed: ${err.message}`, 'gunzip_malformed');
217
- }
218
- }
219
- return buf;
220
- }
221
-
222
- /**
223
- * Reads a decompressed tar buffer and yields one record per entry:
224
- * { name, size, typeflag, linkname, data, unsafe }
225
- * `data` is a Buffer view into `buf` (never copied) for safe entries, `null`
226
- * for unsafe ones. Throws TarSafetyError (never returns a partial result) the
227
- * moment any configured limit is exceeded.
228
- */
229
- function* readTarEntries(buf, limits = DEFAULT_LIMITS) {
230
- if (!Buffer.isBuffer(buf)) throw new TarSafetyError('tar input must be a Buffer', 'bad_input');
231
- let offset = 0;
232
- let count = 0;
233
- let totalSize = 0;
234
- let pendingLongName = null;
235
-
236
- while (offset + BLOCK <= buf.length) {
237
- const header = buf.subarray(offset, offset + BLOCK);
238
- if (header.every((b) => b === 0)) {
239
- offset += BLOCK;
240
- continue; // end-of-archive zero-fill padding
241
- }
242
-
243
- count += 1;
244
- if (count > limits.maxEntries) {
245
- throw new TarSafetyError(`tar archive has more than ${limits.maxEntries} entries`, 'too_many_entries');
246
- }
247
-
248
- let name = cstr(header.subarray(0, 100));
249
- const typeflag = String.fromCharCode(header[156] || 0);
250
- const linkname = cstr(header.subarray(157, 257));
251
- const magic = header.subarray(257, 263).toString('ascii');
252
- const prefix = magic.startsWith('ustar') ? cstr(header.subarray(345, 500)) : '';
253
- if (prefix) name = `${prefix}/${name}`;
254
- const size = parseSizeField(header.subarray(124, 136));
255
-
256
- offset += BLOCK;
257
-
258
- if (size < 0 || !Number.isFinite(size)) {
259
- throw new TarSafetyError(`tar entry "${name}" has an invalid size field`, 'bad_size');
260
- }
261
- if (size > limits.maxEntrySize) {
262
- throw new TarSafetyError(`tar entry "${name}" (${size} bytes) exceeds the per-entry size limit`, 'entry_too_large');
263
- }
264
- totalSize += size;
265
- if (totalSize > limits.maxTotalSize) {
266
- throw new TarSafetyError('tar archive exceeds the total-size limit', 'archive_too_large');
267
- }
268
-
269
- const dataBlocks = Math.ceil(size / BLOCK);
270
- if (offset + size > buf.length) {
271
- throw new TarSafetyError(`tar entry "${name}" claims more data than the archive contains`, 'truncated');
272
- }
273
- const data = size > 0 ? buf.subarray(offset, offset + size) : Buffer.alloc(0);
274
- offset += dataBlocks * BLOCK;
275
-
276
- const resolvedName = pendingLongName ? pendingLongName : name;
277
- pendingLongName = null;
278
-
279
- if (typeflag === 'L') {
280
- // GNU longname: this entry's data IS the next entry's real name.
281
- pendingLongName = cstr(data);
282
- continue;
283
- }
284
- if (typeflag === 'K' || typeflag === 'x' || typeflag === 'g') {
285
- // GNU longlink / PAX extended header — structurally skipped (see header comment).
286
- continue;
287
- }
288
-
289
- if (!isSafeEntryName(resolvedName)) {
290
- yield { name: resolvedName, size, typeflag, linkname, data: null, unsafe: true };
291
- continue;
292
- }
293
-
294
- yield { name: resolvedName.replace(/\\/g, '/'), size, typeflag, linkname, data, unsafe: false };
295
- }
296
- }
297
-
298
-
299
- /***/ })
300
-
301
- };
@@ -1,97 +0,0 @@
1
- export const id = 5443;
2
- export const ids = [5443];
3
- export const modules = {
4
-
5
- /***/ 45443:
6
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7
-
8
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9
- /* harmony export */ buildDeletionReport: () => (/* binding */ buildDeletionReport),
10
- /* harmony export */ buildExportReport: () => (/* binding */ buildExportReport),
11
- /* harmony export */ writeDeletionReport: () => (/* binding */ writeDeletionReport),
12
- /* harmony export */ writeExportReport: () => (/* binding */ writeExportReport)
13
- /* harmony export */ });
14
- /* unused harmony exports DELETION_REPORT_FILE, EXPORT_REPORT_FILE */
15
- /* harmony import */ var _state_dir_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(69259);
16
- // FR-706 (assurance-hardening PRD): manifest-based export and deletion
17
- // reports — "Operators can prove what was exported, deleted, retained, or
18
- // failed."
19
- //
20
- // Two report kinds, one shared per-item shape ({name, status, ...}), each
21
- // written by its one real caller in bin/agentic-security.js:
22
- // - `cmdReset` builds a deletion report from the SAME target/preserved
23
- // data it already computes for its console output (see FR-702/FR-703),
24
- // reshaped into a durable, structured artifact instead of only ever
25
- // printed and lost. Written on BOTH a dry run (items carry status
26
- // 'planned') and a real run (status 'deleted'/'failed'), so an operator
27
- // can prove either "what would happen" or "what did happen" depending
28
- // on which they asked for — `dryRun` on the report says which.
29
- // - `cmdExport` (new) builds an export report after copying every
30
- // currently-present registered artifact to an operator-chosen
31
- // destination, naming what was copied (with a hash) and what failed.
32
- //
33
- // Each report is a SINGLE OVERWRITTEN file per kind — the same "last
34
- // action" precedent as last-scan.json, not an ever-growing log. An
35
- // operator who needs a persistent audit trail across many runs should
36
- // retain these externally (commit them, forward to their own SIEM); this
37
- // module's job is only to make the LAST action's outcome durable and
38
- // provable, not to be the audit log itself.
39
-
40
-
41
-
42
- const DELETION_REPORT_FILE = 'deletion-report.json';
43
- const EXPORT_REPORT_FILE = 'export-report.json';
44
-
45
- function buildDeletionReport({ mode, dryRun, root, items, preserved }) {
46
- const list = Array.isArray(items) ? items : [];
47
- const preservedList = Array.isArray(preserved) ? preserved : [];
48
- return {
49
- schema: 'agentic-security/deletion-report@1',
50
- generatedAt: new Date().toISOString(),
51
- mode: mode || 'reset',
52
- dryRun: !!dryRun,
53
- root: root || null,
54
- items: list,
55
- preserved: preservedList,
56
- summary: {
57
- planned: list.filter(i => i.status === 'planned').length,
58
- deleted: list.filter(i => i.status === 'deleted').length,
59
- failed: list.filter(i => i.status === 'failed').length,
60
- preserved: preservedList.length,
61
- },
62
- };
63
- }
64
-
65
- function writeDeletionReport(scanRoot, report) {
66
- try {
67
- const fp = (0,_state_dir_js__WEBPACK_IMPORTED_MODULE_0__.statePath)(scanRoot, DELETION_REPORT_FILE);
68
- return (0,_state_dir_js__WEBPACK_IMPORTED_MODULE_0__.safeWriteState)(fp, JSON.stringify(report, null, 2) + '\n') ? fp : null;
69
- } catch { return null; }
70
- }
71
-
72
- function buildExportReport({ root, outDir, items }) {
73
- const list = Array.isArray(items) ? items : [];
74
- return {
75
- schema: 'agentic-security/export-report@1',
76
- generatedAt: new Date().toISOString(),
77
- root: root || null,
78
- outDir: outDir || null,
79
- items: list,
80
- summary: {
81
- exported: list.filter(i => i.status === 'exported').length,
82
- failed: list.filter(i => i.status === 'failed').length,
83
- },
84
- };
85
- }
86
-
87
- function writeExportReport(scanRoot, report) {
88
- try {
89
- const fp = (0,_state_dir_js__WEBPACK_IMPORTED_MODULE_0__.statePath)(scanRoot, EXPORT_REPORT_FILE);
90
- return (0,_state_dir_js__WEBPACK_IMPORTED_MODULE_0__.safeWriteState)(fp, JSON.stringify(report, null, 2) + '\n') ? fp : null;
91
- } catch { return null; }
92
- }
93
-
94
-
95
- /***/ })
96
-
97
- };