@clear-capabilities/agentic-security-scanner 0.185.0 → 0.186.2

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 (174) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/bin/agentic-security.js +66 -18
  3. package/dist/1128.index.js +25 -21
  4. package/dist/{5817.index.js → 1602.index.js} +378 -29
  5. package/dist/2584.index.js +1 -1
  6. package/dist/4171.index.js +2 -2
  7. package/dist/{0b301d45b231f144a1b4.json → 4d06c8944ae121d7085c.json} +8 -8
  8. package/dist/5752.index.js +466 -0
  9. package/dist/7405.index.js +1 -1
  10. package/dist/8158.index.js +1713 -0
  11. package/dist/8798.index.js +1 -1
  12. package/dist/9382.index.js +2 -2
  13. package/dist/9560.index.js +1 -1
  14. package/dist/9579.index.js +1 -1
  15. package/dist/agentic-security.mjs +29 -29
  16. package/dist/agentic-security.mjs.sha256 +1 -1
  17. package/package.json +8 -8
  18. package/src/dataflow/CLAUDE.md +6 -3
  19. package/src/dataflow/access-paths.js +12 -2
  20. package/src/dataflow/demand-query.js +279 -40
  21. package/src/dataflow/dep-fingerprint.js +1 -1
  22. package/src/dataflow/exploit-prover.js +6 -2
  23. package/src/dataflow/ir-cache.js +268 -0
  24. package/src/dataflow/privacy-taint.js +7 -0
  25. package/src/engine.js +62 -5
  26. package/src/ir/CLAUDE.md +4 -0
  27. package/src/ir/callgraph.js +36 -8
  28. package/src/ir/index.js +18 -4
  29. package/src/ir/parser-js.js +10 -0
  30. package/src/language/CLAUDE.md +13 -0
  31. package/src/language/nix-option-types.js +170 -0
  32. package/src/language/nix-script-taint.js +46 -3
  33. package/src/language/nix-secrets.js +20 -2
  34. package/src/lineage/CLAUDE.md +2 -1
  35. package/src/lineage/smt-orchestrator.js +47 -11
  36. package/src/lineage/smt-z3-backend.js +294 -0
  37. package/src/posture/CLAUDE.md +5 -1
  38. package/src/posture/business-logic.js +16 -7
  39. package/src/posture/dag-commands.js +442 -0
  40. package/src/posture/finding-defaults.js +19 -0
  41. package/src/posture/git-history.js +91 -1
  42. package/src/posture/proof-fabric/cli.js +1 -1
  43. package/src/posture/proof-fabric/container.js +2 -2
  44. package/src/posture/proof-fabric/generate-haskell.js +205 -0
  45. package/src/posture/proof-fabric/generate.js +6 -3
  46. package/src/posture/proof-fabric/reproducer.js +4 -2
  47. package/src/posture/proof-fabric/runner.js +4 -4
  48. package/src/sast/CLAUDE.md +2 -0
  49. package/src/sast/_call-args.js +70 -0
  50. package/src/sast/init-scope.js +87 -0
  51. package/src/sast/listen-bind-address.js +49 -0
  52. package/src/sast/redirect-target.js +106 -0
  53. package/src/sast/reflected-input.js +76 -0
  54. package/src/sast/send-file-root.js +27 -0
  55. package/src/sast/sensitive-data-logging.js +38 -1
  56. package/dist/119.index.js +0 -197
  57. package/dist/128.index.js +0 -129
  58. package/dist/1293.index.js +0 -5689
  59. package/dist/1336.index.js +0 -16331
  60. package/dist/1351.index.js +0 -133
  61. package/dist/1387.index.js +0 -271
  62. package/dist/1437.index.js +0 -23
  63. package/dist/1445.index.js +0 -110
  64. package/dist/1505.index.js +0 -151
  65. package/dist/1557.index.js +0 -293
  66. package/dist/1621.index.js +0 -311
  67. package/dist/1751.index.js +0 -160
  68. package/dist/1765.index.js +0 -727
  69. package/dist/1861.index.js +0 -690
  70. package/dist/1906.index.js +0 -433
  71. package/dist/208.index.js +0 -1631
  72. package/dist/2223.index.js +0 -159
  73. package/dist/2238.index.js +0 -295
  74. package/dist/2530.index.js +0 -152
  75. package/dist/2565.index.js +0 -116
  76. package/dist/2574.index.js +0 -127
  77. package/dist/2620.index.js +0 -345
  78. package/dist/2773.index.js +0 -98
  79. package/dist/2775.index.js +0 -32
  80. package/dist/2966.index.js +0 -171
  81. package/dist/2972.index.js +0 -87
  82. package/dist/2991.index.js +0 -131
  83. package/dist/3063.index.js +0 -833
  84. package/dist/3075.index.js +0 -227
  85. package/dist/3121.index.js +0 -297
  86. package/dist/3314.index.js +0 -263
  87. package/dist/3480.index.js +0 -1822
  88. package/dist/3481.index.js +0 -24
  89. package/dist/3506.index.js +0 -268
  90. package/dist/3533.index.js +0 -591
  91. package/dist/3653.index.js +0 -450
  92. package/dist/3740.index.js +0 -722
  93. package/dist/3822.index.js +0 -131
  94. package/dist/3868.index.js +0 -292
  95. package/dist/3918.index.js +0 -192
  96. package/dist/4090.index.js +0 -288
  97. package/dist/4113.index.js +0 -1286
  98. package/dist/4121.index.js +0 -1190
  99. package/dist/4142.index.js +0 -690
  100. package/dist/4168.index.js +0 -509
  101. package/dist/4281.index.js +0 -993
  102. package/dist/4336.index.js +0 -436
  103. package/dist/4387.index.js +0 -532
  104. package/dist/4413.index.js +0 -302
  105. package/dist/4476.index.js +0 -4510
  106. package/dist/4491.index.js +0 -133
  107. package/dist/4538.index.js +0 -185
  108. package/dist/4684.index.js +0 -319
  109. package/dist/4740.index.js +0 -165
  110. package/dist/4780.index.js +0 -209
  111. package/dist/4802.index.js +0 -225
  112. package/dist/4812.index.js +0 -379
  113. package/dist/4835.index.js +0 -126
  114. package/dist/494.index.js +0 -226
  115. package/dist/4991.index.js +0 -549
  116. package/dist/5199.index.js +0 -305
  117. package/dist/5216.index.js +0 -109
  118. package/dist/5439.index.js +0 -301
  119. package/dist/5443.index.js +0 -97
  120. package/dist/5496.index.js +0 -377
  121. package/dist/5738.index.js +0 -240
  122. package/dist/5801.index.js +0 -588
  123. package/dist/5858.index.js +0 -223
  124. package/dist/5933.index.js +0 -143
  125. package/dist/601.index.js +0 -23
  126. package/dist/6173.index.js +0 -273
  127. package/dist/6291.index.js +0 -1871
  128. package/dist/6312.index.js +0 -666
  129. package/dist/634.index.js +0 -16182
  130. package/dist/644.index.js +0 -87
  131. package/dist/6508.index.js +0 -283
  132. package/dist/6560.index.js +0 -645
  133. package/dist/6576.index.js +0 -422
  134. package/dist/6579.index.js +0 -271
  135. package/dist/6655.index.js +0 -3221
  136. package/dist/6745.index.js +0 -305
  137. package/dist/6818.index.js +0 -21642
  138. package/dist/6932.index.js +0 -1190
  139. package/dist/6972.index.js +0 -167
  140. package/dist/6995.index.js +0 -163
  141. package/dist/7249.index.js +0 -191
  142. package/dist/7372.index.js +0 -1197
  143. package/dist/7546.index.js +0 -541
  144. package/dist/76.index.js +0 -448
  145. package/dist/7879.index.js +0 -163
  146. package/dist/8025.index.js +0 -130
  147. package/dist/8054.index.js +0 -248
  148. package/dist/808.index.js +0 -1330
  149. package/dist/8097.index.js +0 -201
  150. package/dist/8126.index.js +0 -191
  151. package/dist/8178.index.js +0 -78
  152. package/dist/8382.index.js +0 -93
  153. package/dist/8408.index.js +0 -261
  154. package/dist/8540.index.js +0 -174
  155. package/dist/8635.index.js +0 -802
  156. package/dist/8688.index.js +0 -410
  157. package/dist/8699.index.js +0 -779
  158. package/dist/8891.index.js +0 -457
  159. package/dist/8916.index.js +0 -885
  160. package/dist/9146.index.js +0 -170
  161. package/dist/9168.index.js +0 -841
  162. package/dist/9292.index.js +0 -369
  163. package/dist/9422.index.js +0 -866
  164. package/dist/9440.index.js +0 -453
  165. package/dist/9479.index.js +0 -152
  166. package/dist/9481.index.js +0 -220
  167. package/dist/9539.index.js +0 -100
  168. package/dist/9547.index.js +0 -103
  169. package/dist/9692.index.js +0 -90
  170. package/dist/9800.index.js +0 -462
  171. package/dist/9899.index.js +0 -138
  172. package/dist/9981.index.js +0 -206
  173. package/dist/999.index.js +0 -117
  174. package/dist/9999.index.js +0 -1698
@@ -1,453 +0,0 @@
1
- export const id = 9440;
2
- export const ids = [9440];
3
- export const modules = {
4
-
5
- /***/ 29440:
6
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7
-
8
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9
- /* harmony export */ runOnce: () => (/* binding */ runOnce)
10
- /* harmony export */ });
11
- /* unused harmony exports readDeps, _queryOsvForDep, loadState, persistState, loadConfig, formatPayload, _internals */
12
- /* harmony import */ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73024);
13
- /* harmony import */ var node_path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(76760);
14
- /* harmony import */ var _state_dir_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(69259);
15
- // Continuous CVE-watch daemon.
16
- //
17
- // Polls OSV for the project's dependency tree on a schedule (or one-shot),
18
- // diffs new advisories against state, fires the configured webhook on each
19
- // new ID. Multi-ecosystem: reads npm / pip / cargo / gem / pub / composer /
20
- // go.mod / maven manifests via the same DEP_FILE_NAMES list runScan uses.
21
- //
22
- // Why this exists separately from `/scan --sca`:
23
- // - `/scan` is interactive; this runs unattended, daily, in a cron / GitHub Action.
24
- // - `/scan` reports the FULL set of advisories for the tree; this reports
25
- // only the DELTA since the last run.
26
- // - This produces a webhook fire, not a console report.
27
- //
28
- // Configuration is read from `.agentic-security/cve-alerts.json`:
29
- // {
30
- // "alertUrl": "https://hooks.slack.com/services/...",
31
- // "alertType": "slack" | "discord" | "generic",
32
- // "minSeverity": "low" | "medium" | "high" | "critical" (optional)
33
- // }
34
- //
35
- // State is persisted to `.agentic-security/cve-alerts-state.json`:
36
- // { "known": ["CVE-2024-1234", "GHSA-...", ...], "lastRun": "2026-…" }
37
- //
38
- // The daemon NEVER fires a webhook for an advisory ID it has already seen;
39
- // the state file is the deduplication primitive.
40
-
41
-
42
-
43
-
44
-
45
- const OSV_API = 'https://api.osv.dev/v1/query';
46
-
47
-
48
- // Multi-ecosystem dep extraction. Each entry: { manifest filename → ecosystem }
49
- const ECOSYSTEM_BY_MANIFEST = {
50
- 'package.json': 'npm',
51
- 'requirements.txt':'PyPI',
52
- 'pyproject.toml': 'PyPI',
53
- 'Pipfile': 'PyPI',
54
- 'Pipfile.lock': 'PyPI',
55
- 'poetry.lock': 'PyPI',
56
- 'Gemfile': 'RubyGems',
57
- 'Gemfile.lock': 'RubyGems',
58
- 'go.mod': 'Go',
59
- 'go.sum': 'Go',
60
- 'Cargo.toml': 'crates.io',
61
- 'Cargo.lock': 'crates.io',
62
- 'composer.json': 'Packagist',
63
- 'composer.lock': 'Packagist',
64
- 'pom.xml': 'Maven',
65
- 'build.gradle': 'Maven',
66
- 'build.gradle.kts':'Maven',
67
- 'pubspec.yaml': 'Pub',
68
- 'pubspec.lock': 'Pub',
69
- };
70
-
71
- // ─── Manifest readers ─────────────────────────────────────────────────────
72
-
73
- function _readPackageJson(content) {
74
- try {
75
- const j = JSON.parse(content);
76
- return [
77
- ...Object.keys(j.dependencies || {}),
78
- ...Object.keys(j.devDependencies || {}),
79
- ...Object.keys(j.peerDependencies || {}),
80
- ...Object.keys(j.optionalDependencies || {}),
81
- ];
82
- } catch { return []; }
83
- }
84
-
85
- function _readRequirementsTxt(content) {
86
- // Each non-blank, non-comment line is "pkg" or "pkg==1.2.3" or "pkg>=1.2".
87
- const out = [];
88
- for (const raw of content.split('\n')) {
89
- const line = raw.trim();
90
- if (!line || line.startsWith('#') || line.startsWith('-')) continue;
91
- const m = /^([A-Za-z0-9_.\-]+)/.exec(line);
92
- if (m) out.push(m[1]);
93
- }
94
- return out;
95
- }
96
-
97
- function _readPyprojectToml(content) {
98
- // We don't ship a TOML parser; do a best-effort line scan for the common
99
- // dep-table shapes. Caller is OK if this misses some — the full SCA scan
100
- // does the heavy lifting.
101
- const out = new Set();
102
- // PEP 621 [project] dependencies = ["foo", "bar>=1.0"]
103
- // Poetry [tool.poetry.dependencies] foo = "^1.0"
104
- let inDeps = false;
105
- for (const raw of content.split('\n')) {
106
- const line = raw.trim();
107
- if (!line || line.startsWith('#')) continue;
108
- if (/^\[(?:tool\.poetry\.)?(?:dev-)?dependencies\]/i.test(line) || /^\[project\.optional-dependencies\.[^\]]+\]/.test(line)) {
109
- inDeps = true; continue;
110
- }
111
- if (/^\[[^\]]+\]/.test(line)) { inDeps = false; continue; }
112
- // Inline "dependencies = [...]" form within [project]
113
- const inline = /dependencies\s*=\s*\[([^\]]+)\]/i.exec(line);
114
- if (inline) {
115
- for (const item of inline[1].split(',')) {
116
- const m = /^[\s"']*([A-Za-z0-9_.\-]+)/.exec(item);
117
- if (m) out.add(m[1]);
118
- }
119
- }
120
- if (inDeps) {
121
- const m = /^([A-Za-z0-9_.\-]+)\s*=/.exec(line);
122
- if (m && m[1] !== 'python') out.add(m[1]);
123
- }
124
- }
125
- return [...out];
126
- }
127
-
128
- function _readGemfile(content) {
129
- const out = [];
130
- for (const raw of content.split('\n')) {
131
- const m = /^\s*gem\s+['"]([^'"]+)['"]/.exec(raw);
132
- if (m) out.push(m[1]);
133
- }
134
- return out;
135
- }
136
-
137
- function _readGoMod(content) {
138
- const out = [];
139
- let inRequire = false;
140
- for (const raw of content.split('\n')) {
141
- const line = raw.trim();
142
- if (line.startsWith('require (')) { inRequire = true; continue; }
143
- if (inRequire && line === ')') { inRequire = false; continue; }
144
- if (inRequire || line.startsWith('require ')) {
145
- // "require module/path v1.2.3" or just "module/path v1.2.3" inside block
146
- const m = /(?:require\s+)?([A-Za-z0-9_./\-]+)\s+v/.exec(line);
147
- if (m) out.push(m[1]);
148
- }
149
- }
150
- return out;
151
- }
152
-
153
- function _readCargoToml(content) {
154
- // Lines under [dependencies] / [dev-dependencies] / [build-dependencies]
155
- // shaped as `pkg = "1.0"` or `pkg = { … }`.
156
- const out = new Set();
157
- let inDeps = false;
158
- for (const raw of content.split('\n')) {
159
- const line = raw.trim();
160
- if (/^\[(?:dev-|build-)?dependencies\]/.test(line)) { inDeps = true; continue; }
161
- if (/^\[[^\]]+\]/.test(line)) { inDeps = false; continue; }
162
- if (inDeps) {
163
- const m = /^([A-Za-z0-9_\-]+)\s*=/.exec(line);
164
- if (m) out.add(m[1]);
165
- }
166
- }
167
- return [...out];
168
- }
169
-
170
- function _readComposerJson(content) {
171
- try {
172
- const j = JSON.parse(content);
173
- return [
174
- ...Object.keys(j.require || {}).filter(k => k !== 'php'),
175
- ...Object.keys(j['require-dev'] || {}).filter(k => k !== 'php'),
176
- ];
177
- } catch { return []; }
178
- }
179
-
180
- function _readMavenLikeXml(content) {
181
- // crude <artifactId>x</artifactId> extraction. Misses parent POM inheritance;
182
- // for full coverage the /scan --sca path is the right tool.
183
- const out = [];
184
- const re = /<artifactId>\s*([^<\s]+)\s*<\/artifactId>/g;
185
- let m;
186
- while ((m = re.exec(content)) !== null) out.push(m[1]);
187
- return out;
188
- }
189
-
190
- function _readPubspecYaml(content) {
191
- const out = new Set();
192
- let inDeps = false;
193
- for (const raw of content.split('\n')) {
194
- const line = raw.trimEnd();
195
- if (/^(dev_|)dependencies\s*:/i.test(line)) { inDeps = true; continue; }
196
- if (line && !line.startsWith(' ') && !line.startsWith('\t')) {
197
- // top-level key other than dependencies / dev_dependencies
198
- if (!/^(dev_|)dependencies\s*:/i.test(line)) inDeps = false;
199
- }
200
- if (inDeps) {
201
- const m = /^\s+([A-Za-z0-9_]+)\s*:/.exec(line);
202
- if (m && m[1] !== 'sdk' && m[1] !== 'flutter') out.add(m[1]);
203
- }
204
- }
205
- return [...out];
206
- }
207
-
208
- const MANIFEST_READERS = {
209
- 'package.json': _readPackageJson,
210
- 'requirements.txt': _readRequirementsTxt,
211
- 'pyproject.toml': _readPyprojectToml,
212
- 'Pipfile': _readPyprojectToml, // close-enough shape
213
- 'Gemfile': _readGemfile,
214
- 'go.mod': _readGoMod,
215
- 'Cargo.toml': _readCargoToml,
216
- 'composer.json': _readComposerJson,
217
- 'pom.xml': _readMavenLikeXml,
218
- 'build.gradle': _readMavenLikeXml,
219
- 'build.gradle.kts': _readMavenLikeXml,
220
- 'pubspec.yaml': _readPubspecYaml,
221
- };
222
-
223
- function readDeps(scanRoot) {
224
- // Walks the scan root looking for known manifest files. Returns a flat
225
- // [{name, ecosystem}, ...] list; deduplicated across manifests so a
226
- // package in both package.json and yarn.lock isn't queried twice.
227
- const seen = new Set();
228
- const out = [];
229
- function walk(dir, depth) {
230
- if (depth > 4) return; // shallow walk; manifests live near the root
231
- let entries;
232
- try { entries = node_fs__WEBPACK_IMPORTED_MODULE_0__.readdirSync(dir, { withFileTypes: true }); } catch { return; }
233
- for (const e of entries) {
234
- if (e.name.startsWith('.') && e.name !== '.gradle') continue;
235
- if (e.name === 'node_modules' || e.name === 'venv' || e.name === '__pycache__'
236
- || e.name === 'vendor' || e.name === 'dist' || e.name === 'build'
237
- || e.name === 'target') continue;
238
- const fp = node_path__WEBPACK_IMPORTED_MODULE_1__.join(dir, e.name);
239
- if (e.isDirectory()) { walk(fp, depth + 1); continue; }
240
- if (!ECOSYSTEM_BY_MANIFEST[e.name]) continue;
241
- let content;
242
- try { content = node_fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(fp, 'utf8'); } catch { continue; }
243
- const reader = MANIFEST_READERS[e.name];
244
- if (!reader) continue;
245
- const ecosystem = ECOSYSTEM_BY_MANIFEST[e.name];
246
- for (const name of reader(content)) {
247
- const key = `${ecosystem}::${name}`;
248
- if (seen.has(key)) continue;
249
- seen.add(key);
250
- out.push({ name, ecosystem });
251
- }
252
- }
253
- }
254
- walk(scanRoot, 0);
255
- return out;
256
- }
257
-
258
- // ─── OSV query ────────────────────────────────────────────────────────────
259
-
260
- async function _queryOsvForDep({ name, ecosystem }, { fetchImpl = globalThis.fetch, timeoutMs = 4000 } = {}) {
261
- // POST { package: { name, ecosystem } } — returns the full vulnerability
262
- // list for the package (any version). The daemon doesn't filter by version
263
- // because we treat "new advisory ID" as the signal, not "your installed
264
- // version is affected" — that's what /scan --sca produces.
265
- try {
266
- const controller = new AbortController();
267
- const t = setTimeout(() => controller.abort(), timeoutMs);
268
- const res = await fetchImpl(OSV_API, {
269
- method: 'POST',
270
- headers: { 'Content-Type': 'application/json' },
271
- body: JSON.stringify({ package: { name, ecosystem } }),
272
- signal: controller.signal,
273
- });
274
- clearTimeout(t);
275
- if (!res.ok) return [];
276
- const j = await res.json();
277
- return Array.isArray(j.vulns) ? j.vulns : [];
278
- } catch { return []; }
279
- }
280
-
281
- // ─── State persistence ───────────────────────────────────────────────────
282
-
283
- function loadState(scanRoot) {
284
- const fp = (0,_state_dir_js__WEBPACK_IMPORTED_MODULE_2__.statePath)(scanRoot, 'cve-alerts-state.json');
285
- if (!node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(fp)) return { known: new Set(), lastRun: null };
286
- try {
287
- const j = JSON.parse(node_fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(fp, 'utf8'));
288
- return { known: new Set(j.known || []), lastRun: j.lastRun || null };
289
- } catch { return { known: new Set(), lastRun: null }; }
290
- }
291
-
292
- function persistState(scanRoot, state) {
293
- const fp = (0,_state_dir_js__WEBPACK_IMPORTED_MODULE_2__.statePath)(scanRoot, 'cve-alerts-state.json');
294
- if (!(0,_state_dir_js__WEBPACK_IMPORTED_MODULE_2__.stateWritesEnabled)()) return;
295
- node_fs__WEBPACK_IMPORTED_MODULE_0__.mkdirSync(node_path__WEBPACK_IMPORTED_MODULE_1__.dirname(fp), { recursive: true });
296
- node_fs__WEBPACK_IMPORTED_MODULE_0__.writeFileSync(fp, JSON.stringify({
297
- known: [...state.known].sort(),
298
- lastRun: state.lastRun,
299
- }, null, 2));
300
- }
301
-
302
- function loadConfig(scanRoot) {
303
- const fp = (0,_state_dir_js__WEBPACK_IMPORTED_MODULE_2__.statePath)(scanRoot, 'cve-alerts.json');
304
- if (!node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(fp)) return null;
305
- try { return JSON.parse(node_fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(fp, 'utf8')); } catch { return null; }
306
- }
307
-
308
- // ─── Webhook formatting ──────────────────────────────────────────────────
309
-
310
- function _truncate(s, n) { s = String(s || ''); return s.length > n ? s.slice(0, n) + '…' : s; }
311
-
312
- function formatPayload(alertType, newAdvisories) {
313
- // alertType: 'slack' | 'discord' | 'generic'
314
- // Slack and Discord both accept `{ text }` for simple messages.
315
- const lines = newAdvisories.slice(0, 10).map(a =>
316
- `• \`${a.ecosystem}:${a.pkg}\` — ${a.id} (${a.severity || 'unknown'})${a.summary ? ' — ' + _truncate(a.summary, 100) : ''}`
317
- );
318
- const overflow = newAdvisories.length > 10 ? `\n+${newAdvisories.length - 10} more` : '';
319
- const text = `🚨 *New CVEs in your dependencies* (${newAdvisories.length})\n` + lines.join('\n') + overflow + '\n\nRun `/scan --all` to assess impact.';
320
- if (alertType === 'slack' || alertType === 'discord') return { text };
321
- // Generic webhook: full structured payload.
322
- return { event: 'new_cve', count: newAdvisories.length, advisories: newAdvisories };
323
- }
324
-
325
- async function _post(url, payload, { fetchImpl = globalThis.fetch, timeoutMs = 4000 } = {}) {
326
- try {
327
- const controller = new AbortController();
328
- const t = setTimeout(() => controller.abort(), timeoutMs);
329
- const res = await fetchImpl(url, {
330
- method: 'POST',
331
- headers: { 'Content-Type': 'application/json' },
332
- body: JSON.stringify(payload),
333
- signal: controller.signal,
334
- });
335
- clearTimeout(t);
336
- return { ok: res.ok, status: res.status };
337
- } catch (e) { return { ok: false, error: String(e?.message || e).slice(0, 200) }; }
338
- }
339
-
340
- // ─── Severity filter ─────────────────────────────────────────────────────
341
-
342
- const SEV_RANK = { critical: 4, high: 3, medium: 2, low: 1, unknown: 0 };
343
-
344
- function _normalizeSeverity(vuln) {
345
- // OSV severity has a few possible shapes. Best-effort.
346
- const dbSpec = vuln.database_specific?.severity || '';
347
- if (/critical/i.test(dbSpec)) return 'critical';
348
- if (/high/i.test(dbSpec)) return 'high';
349
- if (/medium|moderate/i.test(dbSpec)) return 'medium';
350
- if (/low/i.test(dbSpec)) return 'low';
351
- // CVSS score
352
- const score = vuln.severity?.[0]?.score;
353
- if (typeof score === 'number') {
354
- if (score >= 9) return 'critical';
355
- if (score >= 7) return 'high';
356
- if (score >= 4) return 'medium';
357
- return 'low';
358
- }
359
- return 'unknown';
360
- }
361
-
362
- // ─── Main entry — runOnce ───────────────────────────────────────────────
363
-
364
- async function runOnce(scanRoot, opts = {}) {
365
- // opts: { alertUrl, alertType, minSeverity, dryRun, offline, fetchImpl,
366
- // logger, throttleMs }
367
- const log = opts.logger || ((msg) => process.stderr.write(msg + '\n'));
368
- const cfg = loadConfig(scanRoot);
369
- const alertUrl = opts.alertUrl || cfg?.alertUrl || process.env.CVE_ALERT_URL;
370
- const alertType = opts.alertType || cfg?.alertType || 'slack';
371
- const minSeverity = opts.minSeverity || cfg?.minSeverity || 'low';
372
- const dryRun = !!opts.dryRun;
373
- const offline = !!opts.offline || process.env.AGENTIC_SECURITY_OFFLINE === '1';
374
- const fetchImpl = opts.fetchImpl || globalThis.fetch;
375
- const throttleMs = typeof opts.throttleMs === 'number' ? opts.throttleMs : 50;
376
-
377
- if (offline && !dryRun) {
378
- return { ok: false, reason: 'offline-mode-set' };
379
- }
380
- if (typeof fetchImpl !== 'function') {
381
- return { ok: false, reason: 'fetch-unavailable' };
382
- }
383
-
384
- const deps = readDeps(scanRoot);
385
- if (deps.length === 0) {
386
- return { ok: true, depsChecked: 0, newAdvisories: [], alertSent: false, reason: 'no-deps-found' };
387
- }
388
-
389
- const state = loadState(scanRoot);
390
- const newAdvisories = [];
391
- const sevFloor = SEV_RANK[minSeverity] ?? 0;
392
-
393
- for (const dep of deps) {
394
- const vulns = await _queryOsvForDep(dep, { fetchImpl, timeoutMs: opts.timeoutMs });
395
- for (const v of vulns) {
396
- if (!v.id || state.known.has(v.id)) continue;
397
- const sev = _normalizeSeverity(v);
398
- if ((SEV_RANK[sev] ?? 0) < sevFloor) {
399
- // Below user's floor; remember the ID so we don't re-fire next run,
400
- // but don't surface in the alert.
401
- state.known.add(v.id);
402
- continue;
403
- }
404
- newAdvisories.push({
405
- id: v.id,
406
- pkg: dep.name,
407
- ecosystem: dep.ecosystem,
408
- severity: sev,
409
- summary: v.summary || '',
410
- published: v.published || null,
411
- });
412
- state.known.add(v.id);
413
- }
414
- if (throttleMs > 0) await new Promise(r => setTimeout(r, throttleMs));
415
- }
416
-
417
- state.lastRun = new Date().toISOString();
418
- if (!dryRun) persistState(scanRoot, state);
419
-
420
- let alertSent = false;
421
- let alertError = null;
422
- if (newAdvisories.length > 0 && alertUrl && !dryRun) {
423
- const payload = formatPayload(alertType, newAdvisories);
424
- const r = await _post(alertUrl, payload, { fetchImpl, timeoutMs: opts.timeoutMs });
425
- alertSent = r.ok;
426
- if (!r.ok) alertError = r.error || `HTTP ${r.status}`;
427
- }
428
-
429
- log(`agentic-security cve-watch: deps=${deps.length} new=${newAdvisories.length} sent=${alertSent}${alertError ? ' err=' + alertError : ''}${dryRun ? ' (dry-run)' : ''}`);
430
-
431
- return {
432
- ok: true,
433
- depsChecked: deps.length,
434
- newAdvisories,
435
- alertSent,
436
- alertError,
437
- minSeverity,
438
- dryRun,
439
- };
440
- }
441
-
442
- const _internals = {
443
- ECOSYSTEM_BY_MANIFEST,
444
- MANIFEST_READERS,
445
- _readPackageJson, _readRequirementsTxt, _readPyprojectToml, _readGemfile,
446
- _readGoMod, _readCargoToml, _readComposerJson, _readMavenLikeXml, _readPubspecYaml,
447
- _normalizeSeverity,
448
- };
449
-
450
-
451
- /***/ })
452
-
453
- };
@@ -1,152 +0,0 @@
1
- export const id = 9479;
2
- export const ids = [9479];
3
- export const modules = {
4
-
5
- /***/ 9479:
6
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7
-
8
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9
- /* harmony export */ sweepGitHistory: () => (/* binding */ sweepGitHistory)
10
- /* harmony export */ });
11
- /* unused harmony exports extractAddedLines, splitDiffByFile, scanHistoryDiff */
12
- /* harmony import */ var node_child_process__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(31421);
13
- /* harmony import */ var _util_git_hardening_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(12179);
14
- /* harmony import */ var _language_secrets_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(67855);
15
- // R15 (PRD §5) — git-history secret sweep.
16
- //
17
- // A secret removed from HEAD but present in any past commit is still
18
- // recoverable from `.git` and must be rotated — the most dangerous secret case,
19
- // and one a working-tree-only scan misses entirely. This sweeps recent history
20
- // (bounded), feeding the ADDED lines of each commit through the same credential
21
- // detector the file scan uses.
22
- //
23
- // The detector is INJECTED (detectFn) rather than imported, so this module has
24
- // no dependency back into engine.js (avoids a circular import) and the parsing
25
- // stays pure + unit-testable. Live-credential validation (is the key active?)
26
- // needs network and is deferred — see the rollup.
27
-
28
-
29
-
30
-
31
-
32
- // Pull the post-image (added) lines out of a unified diff: lines starting with
33
- // a single '+' (not the '+++' file header). Returns reconstructed text.
34
- function extractAddedLines(diffText) {
35
- const out = [];
36
- for (const line of String(diffText || '').split('\n')) {
37
- if (line.startsWith('+') && !line.startsWith('+++')) out.push(line.slice(1));
38
- }
39
- return out.join('\n');
40
- }
41
-
42
- // Split a unified diff into per-file sections with the POST-IMAGE line number of every added line, so a
43
- // finding can name the file and line it was committed at (the combined text alone loses both).
44
- function splitDiffByFile(diffText) {
45
- const files = [];
46
- let cur = null; let next = 0;
47
- for (const line of String(diffText || '').split('\n')) {
48
- const h = /^diff --git a\/(.+?) b\/(.+)$/.exec(line);
49
- if (h) { cur = { path: h[2], added: [] }; files.push(cur); next = 0; continue; }
50
- if (!cur) continue;
51
- const hh = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(line);
52
- if (hh) { next = parseInt(hh[1], 10); continue; }
53
- if (line.startsWith('+++') || line.startsWith('---')) continue;
54
- if (line.startsWith('+')) { cur.added.push({ text: line.slice(1), line: next }); next++; }
55
- else if (!line.startsWith('-') && !line.startsWith('\\')) next++;
56
- }
57
- return files;
58
- }
59
-
60
- // Pure: run the injected credential detector over a commit's added lines.
61
- // detectFn has the scanCredentials(fp, raw) shape and returns Finding[]. `extra` are additional detectors
62
- // ((path, text) => Finding[]) run against each file's added lines WITH the real path, so extension-gated
63
- // detectors (Haskell/Nix split-secret) apply to history too.
64
- function scanHistoryDiff(diffText, commit, detectFn, extra = []) {
65
- if (typeof detectFn !== 'function') return [];
66
- const sections = splitDiffByFile(diffText);
67
- const remediation = 'Rotate the credential now, then purge it from history (git filter-repo / BFG) and move it to a secrets manager. Removing it from HEAD alone is insufficient.';
68
- const wrap = (f, sec, addedLines) => {
69
- const hit = Number.isInteger(f.line) && f.line >= 1 ? addedLines[f.line - 1] : null;
70
- const prov = f.rotation ? {} : (0,_language_secrets_js__WEBPACK_IMPORTED_MODULE_2__/* .providerInfo */ .cf)(f._rawProviderValue || '');
71
- const out = {
72
- ...f, ...prov,
73
- id: `secret-history:${commit}:${f.id || f.vuln || 'secret'}`,
74
- file: `git-history@${commit}`, line: 0, commit, _historical: true,
75
- ...(sec ? { sourceFile: sec.path, sourceLine: hit ? hit.line : null } : {}),
76
- vuln: `${f.vuln || 'Hardcoded Secret'} (in git history)`,
77
- description: `${f.description || 'A credential was committed.'} Found in commit ${commit}${sec ? ` (${sec.path}${hit ? `:${hit.line}` : ''})` : ''}; even if removed from HEAD it remains recoverable from git and must be rotated.`,
78
- remediation,
79
- // report/index.js's _remediationOf checks `.fix` before `.remediation`
80
- // — the underlying detector already set `.fix` to a generic "remove
81
- // the line" string, which would otherwise silently shadow this
82
- // history-specific instruction ("removing it from HEAD alone is
83
- // insufficient") in every report format.
84
- fix: remediation,
85
- };
86
- delete out._rawProviderValue;
87
- return out;
88
- };
89
- const results = [];
90
- if (!sections.length) {
91
- const added = extractAddedLines(diffText);
92
- if (!added.trim()) return [];
93
- let findings = [];
94
- try { findings = detectFn(`git-history@${commit}`, added) || []; } catch { return []; }
95
- return findings.map((f) => wrap(f, null, []));
96
- }
97
- for (const sec of sections) {
98
- if (!sec.added.length) continue;
99
- const text = sec.added.map((a) => a.text).join('\n');
100
- if (!text.trim()) continue;
101
- let findings = [];
102
- try { findings = detectFn(`git-history@${commit}`, text) || []; } catch { findings = []; }
103
- for (const f of findings) results.push(wrap(f, sec, sec.added));
104
- for (const ex of extra || []) {
105
- let more = [];
106
- try { more = ex(sec.path, text) || []; } catch { more = []; }
107
- for (const f of more) results.push(wrap(f, sec, sec.added));
108
- }
109
- }
110
- return results;
111
- }
112
-
113
- const defaultExtra = [_language_secrets_js__WEBPACK_IMPORTED_MODULE_2__/* .scanLanguageSecretConcat */ ._d, _language_secrets_js__WEBPACK_IMPORTED_MODULE_2__/* .scanDependencyUrlCredentials */ .y6];
114
-
115
- /**
116
- * Sweep up to `maxCommits` of recent history for secrets. Best-effort: returns
117
- * [] when `scanRoot` is not a git repo or git is unavailable. Dedups a secret
118
- * that recurs across commits to its earliest sighting.
119
- */
120
- function sweepGitHistory(scanRoot, detectFn, { maxCommits = 50, timeoutMs = 20000, extraDetectors = null } = {}) {
121
- if (!scanRoot || typeof detectFn !== 'function') return [];
122
- let out;
123
- try {
124
- // Second independent Finding Provenance PRD audit (FR-PROV-024): this
125
- // scanRoot is a scanned repository, not this project's own trusted
126
- // checkout. `--no-textconv` alone (the pre-existing hardening here) closes
127
- // the .gitattributes textconv surface but NOT `core.fsmonitor` /
128
- // `core.hooksPath` — this `log -p` call renders every historical commit's
129
- // diff content, the same shape verified exploitable in
130
- // provenance/git-evidence.js, so it gets the full hardening too.
131
- out = (0,node_child_process__WEBPACK_IMPORTED_MODULE_0__.execFileSync)('git', (0,_util_git_hardening_js__WEBPACK_IMPORTED_MODULE_1__/* .hardenGitArgs */ .Ax)(['-C', scanRoot, 'log', '-p', '-n', String(maxCommits), '--no-color', '--no-merges', '--no-textconv']),
132
- { encoding: 'utf8', maxBuffer: 96 * 1024 * 1024, timeout: timeoutMs, stdio: ['ignore', 'pipe', 'ignore'], env: (0,_util_git_hardening_js__WEBPACK_IMPORTED_MODULE_1__/* .hardenGitEnv */ .Si)() });
133
- } catch { return []; }
134
- const parts = out.split(/^commit ([0-9a-f]{7,40})/m); // [pre, sha, body, sha, body, ...]
135
- const findings = [];
136
- const seen = new Set();
137
- for (let i = 1; i < parts.length; i += 2) {
138
- const sha = (parts[i] || '').slice(0, 12);
139
- for (const f of scanHistoryDiff(parts[i + 1] || '', sha, detectFn, extraDetectors || defaultExtra)) {
140
- const key = `${f.vuln}:${(f.snippet || f.match || '').slice(0, 40)}`;
141
- if (seen.has(key)) continue;
142
- seen.add(key);
143
- findings.push(f);
144
- }
145
- }
146
- return findings;
147
- }
148
-
149
-
150
- /***/ })
151
-
152
- };