@clear-capabilities/agentic-security-scanner 0.185.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 (167) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/bin/agentic-security.js +24 -1
  3. package/dist/1128.index.js +25 -21
  4. package/dist/2584.index.js +1 -1
  5. package/dist/4171.index.js +2 -2
  6. package/dist/5752.index.js +466 -0
  7. package/dist/7405.index.js +1 -1
  8. package/dist/8158.index.js +1713 -0
  9. package/dist/8798.index.js +1 -1
  10. package/dist/9382.index.js +2 -2
  11. package/dist/9579.index.js +1 -1
  12. package/dist/agentic-security.mjs +29 -29
  13. package/dist/agentic-security.mjs.sha256 +1 -1
  14. package/dist/{0b301d45b231f144a1b4.json → ca62ee93079be4c24eee.json} +7 -7
  15. package/package.json +7 -7
  16. package/src/dataflow/CLAUDE.md +6 -3
  17. package/src/dataflow/access-paths.js +12 -2
  18. package/src/dataflow/demand-query.js +279 -40
  19. package/src/dataflow/dep-fingerprint.js +1 -1
  20. package/src/dataflow/exploit-prover.js +6 -2
  21. package/src/dataflow/ir-cache.js +268 -0
  22. package/src/dataflow/privacy-taint.js +7 -0
  23. package/src/engine.js +62 -5
  24. package/src/ir/CLAUDE.md +4 -0
  25. package/src/ir/callgraph.js +36 -8
  26. package/src/ir/index.js +18 -4
  27. package/src/ir/parser-js.js +10 -0
  28. package/src/language/CLAUDE.md +13 -0
  29. package/src/language/nix-option-types.js +170 -0
  30. package/src/language/nix-script-taint.js +46 -3
  31. package/src/language/nix-secrets.js +20 -2
  32. package/src/lineage/CLAUDE.md +2 -1
  33. package/src/lineage/smt-orchestrator.js +47 -11
  34. package/src/lineage/smt-z3-backend.js +294 -0
  35. package/src/posture/CLAUDE.md +5 -1
  36. package/src/posture/business-logic.js +16 -7
  37. package/src/posture/dag-commands.js +442 -0
  38. package/src/posture/finding-defaults.js +19 -0
  39. package/src/posture/git-history.js +91 -1
  40. package/src/sast/CLAUDE.md +2 -0
  41. package/src/sast/_call-args.js +70 -0
  42. package/src/sast/init-scope.js +87 -0
  43. package/src/sast/listen-bind-address.js +49 -0
  44. package/src/sast/redirect-target.js +106 -0
  45. package/src/sast/reflected-input.js +76 -0
  46. package/src/sast/send-file-root.js +27 -0
  47. package/src/sast/sensitive-data-logging.js +38 -1
  48. package/dist/119.index.js +0 -197
  49. package/dist/128.index.js +0 -129
  50. package/dist/1293.index.js +0 -5689
  51. package/dist/1336.index.js +0 -16331
  52. package/dist/1351.index.js +0 -133
  53. package/dist/1387.index.js +0 -271
  54. package/dist/1437.index.js +0 -23
  55. package/dist/1445.index.js +0 -110
  56. package/dist/1505.index.js +0 -151
  57. package/dist/1557.index.js +0 -293
  58. package/dist/1621.index.js +0 -311
  59. package/dist/1751.index.js +0 -160
  60. package/dist/1765.index.js +0 -727
  61. package/dist/1861.index.js +0 -690
  62. package/dist/1906.index.js +0 -433
  63. package/dist/208.index.js +0 -1631
  64. package/dist/2223.index.js +0 -159
  65. package/dist/2238.index.js +0 -295
  66. package/dist/2530.index.js +0 -152
  67. package/dist/2565.index.js +0 -116
  68. package/dist/2574.index.js +0 -127
  69. package/dist/2620.index.js +0 -345
  70. package/dist/2773.index.js +0 -98
  71. package/dist/2775.index.js +0 -32
  72. package/dist/2966.index.js +0 -171
  73. package/dist/2972.index.js +0 -87
  74. package/dist/2991.index.js +0 -131
  75. package/dist/3063.index.js +0 -833
  76. package/dist/3075.index.js +0 -227
  77. package/dist/3121.index.js +0 -297
  78. package/dist/3314.index.js +0 -263
  79. package/dist/3480.index.js +0 -1822
  80. package/dist/3481.index.js +0 -24
  81. package/dist/3506.index.js +0 -268
  82. package/dist/3533.index.js +0 -591
  83. package/dist/3653.index.js +0 -450
  84. package/dist/3740.index.js +0 -722
  85. package/dist/3822.index.js +0 -131
  86. package/dist/3868.index.js +0 -292
  87. package/dist/3918.index.js +0 -192
  88. package/dist/4090.index.js +0 -288
  89. package/dist/4113.index.js +0 -1286
  90. package/dist/4121.index.js +0 -1190
  91. package/dist/4142.index.js +0 -690
  92. package/dist/4168.index.js +0 -509
  93. package/dist/4281.index.js +0 -993
  94. package/dist/4336.index.js +0 -436
  95. package/dist/4387.index.js +0 -532
  96. package/dist/4413.index.js +0 -302
  97. package/dist/4476.index.js +0 -4510
  98. package/dist/4491.index.js +0 -133
  99. package/dist/4538.index.js +0 -185
  100. package/dist/4684.index.js +0 -319
  101. package/dist/4740.index.js +0 -165
  102. package/dist/4780.index.js +0 -209
  103. package/dist/4802.index.js +0 -225
  104. package/dist/4812.index.js +0 -379
  105. package/dist/4835.index.js +0 -126
  106. package/dist/494.index.js +0 -226
  107. package/dist/4991.index.js +0 -549
  108. package/dist/5199.index.js +0 -305
  109. package/dist/5216.index.js +0 -109
  110. package/dist/5439.index.js +0 -301
  111. package/dist/5443.index.js +0 -97
  112. package/dist/5496.index.js +0 -377
  113. package/dist/5738.index.js +0 -240
  114. package/dist/5801.index.js +0 -588
  115. package/dist/5817.index.js +0 -714
  116. package/dist/5858.index.js +0 -223
  117. package/dist/5933.index.js +0 -143
  118. package/dist/601.index.js +0 -23
  119. package/dist/6173.index.js +0 -273
  120. package/dist/6291.index.js +0 -1871
  121. package/dist/6312.index.js +0 -666
  122. package/dist/634.index.js +0 -16182
  123. package/dist/644.index.js +0 -87
  124. package/dist/6508.index.js +0 -283
  125. package/dist/6560.index.js +0 -645
  126. package/dist/6576.index.js +0 -422
  127. package/dist/6579.index.js +0 -271
  128. package/dist/6655.index.js +0 -3221
  129. package/dist/6745.index.js +0 -305
  130. package/dist/6818.index.js +0 -21642
  131. package/dist/6932.index.js +0 -1190
  132. package/dist/6972.index.js +0 -167
  133. package/dist/6995.index.js +0 -163
  134. package/dist/7249.index.js +0 -191
  135. package/dist/7372.index.js +0 -1197
  136. package/dist/7546.index.js +0 -541
  137. package/dist/76.index.js +0 -448
  138. package/dist/7879.index.js +0 -163
  139. package/dist/8025.index.js +0 -130
  140. package/dist/8054.index.js +0 -248
  141. package/dist/808.index.js +0 -1330
  142. package/dist/8097.index.js +0 -201
  143. package/dist/8126.index.js +0 -191
  144. package/dist/8178.index.js +0 -78
  145. package/dist/8382.index.js +0 -93
  146. package/dist/8408.index.js +0 -261
  147. package/dist/8540.index.js +0 -174
  148. package/dist/8635.index.js +0 -802
  149. package/dist/8688.index.js +0 -410
  150. package/dist/8699.index.js +0 -779
  151. package/dist/8891.index.js +0 -457
  152. package/dist/8916.index.js +0 -885
  153. package/dist/9146.index.js +0 -170
  154. package/dist/9168.index.js +0 -841
  155. package/dist/9292.index.js +0 -369
  156. package/dist/9422.index.js +0 -866
  157. package/dist/9440.index.js +0 -453
  158. package/dist/9479.index.js +0 -152
  159. package/dist/9481.index.js +0 -220
  160. package/dist/9539.index.js +0 -100
  161. package/dist/9547.index.js +0 -103
  162. package/dist/9692.index.js +0 -90
  163. package/dist/9800.index.js +0 -462
  164. package/dist/9899.index.js +0 -138
  165. package/dist/9981.index.js +0 -206
  166. package/dist/999.index.js +0 -117
  167. package/dist/9999.index.js +0 -1698
@@ -1,167 +0,0 @@
1
- export const id = 6972;
2
- export const ids = [6972];
3
- export const modules = {
4
-
5
- /***/ 16972:
6
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7
-
8
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9
- /* harmony export */ describeTarget: () => (/* binding */ describeTarget),
10
- /* harmony export */ loadTargetManifest: () => (/* binding */ loadTargetManifest),
11
- /* harmony export */ validateTarget: () => (/* binding */ validateTarget)
12
- /* harmony export */ });
13
- /* unused harmony export _internals */
14
- /* harmony import */ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73024);
15
- /* harmony import */ var node_path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(76760);
16
- // Verifier target harness (FR-LIVE-HARNESS).
17
- //
18
- // Customer projects describe how to bring up the app they want the verifier
19
- // to execute PoCs against. The manifest lives at
20
- // `.agentic-security/verifier-target.yaml` and the verifier reads it before
21
- // running `--live` mode. v1 supports two manifest shapes:
22
- //
23
- // shape: docker-compose
24
- // compose: docker-compose.yml
25
- // service: web
26
- // port: 3000
27
- // wait-for: http://localhost:3000/healthz
28
- //
29
- // ─── or ───
30
- //
31
- // shape: command
32
- // start: npm run dev
33
- // port: 3000
34
- // wait-for: http://localhost:3000/healthz
35
- // stop: pkill -f "npm run dev"
36
- //
37
- // We DO NOT execute the manifest in this module — that's the verifier
38
- // sandbox's job (and the customer's explicit opt-in via --live). This
39
- // module parses, validates, and surfaces a structured object the verifier
40
- // can act on (or refuse to act on).
41
-
42
-
43
-
44
-
45
- const MANIFEST_PATH = node_path__WEBPACK_IMPORTED_MODULE_1__.join('.agentic-security', 'verifier-target.yaml');
46
-
47
- // Minimal YAML subset parser — keep parity with the polyglot bench parser,
48
- // scoped to the small set of keys this manifest uses. Standalone here to
49
- // avoid a runtime dep.
50
- function _parse(text) {
51
- const out = {};
52
- for (const raw of String(text || '').split(/\r?\n/)) {
53
- const line = raw.replace(/#.*$/, '').trim();
54
- if (!line) continue;
55
- const m = line.match(/^([\w-]+)\s*:\s*(.*)$/);
56
- if (!m) continue;
57
- const [, key, val] = m;
58
- out[key] = _coerce(val);
59
- }
60
- return out;
61
- }
62
-
63
- function _coerce(v) {
64
- if (v === undefined || v === null) return null;
65
- v = String(v).trim();
66
- if (/^".*"$/.test(v)) return v.slice(1, -1);
67
- if (/^'.*'$/.test(v)) return v.slice(1, -1);
68
- if (/^-?\d+$/.test(v)) return parseInt(v, 10);
69
- return v;
70
- }
71
-
72
- /**
73
- * Read the verifier-target manifest from scanRoot. Returns:
74
- * { ok: true, target } — successfully parsed and validated
75
- * { ok: false, reason } — manifest missing or invalid
76
- *
77
- * Never throws.
78
- */
79
- function loadTargetManifest(scanRoot) {
80
- const fp = node_path__WEBPACK_IMPORTED_MODULE_1__.join(scanRoot || process.cwd(), MANIFEST_PATH);
81
- if (!node_fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(fp)) return { ok: false, reason: 'no-manifest' };
82
- let raw;
83
- try { raw = node_fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(fp, 'utf8'); }
84
- catch (e) { return { ok: false, reason: `read-error:${e.message}` }; }
85
- const parsed = _parse(raw);
86
- const shape = parsed.shape;
87
- if (shape !== 'docker-compose' && shape !== 'command') {
88
- return { ok: false, reason: `unknown-shape:${shape || 'missing'}` };
89
- }
90
- if (shape === 'docker-compose') {
91
- if (!parsed.compose || !parsed.service) {
92
- return { ok: false, reason: 'docker-compose-shape-needs-compose-and-service' };
93
- }
94
- }
95
- if (shape === 'command') {
96
- if (!parsed.start) {
97
- return { ok: false, reason: 'command-shape-needs-start' };
98
- }
99
- }
100
- const target = {
101
- shape,
102
- compose: parsed.compose || null,
103
- service: parsed.service || null,
104
- start: parsed.start || null,
105
- stop: parsed.stop || null,
106
- port: parsed.port || null,
107
- waitFor: parsed['wait-for'] || parsed.waitFor || null,
108
- url: parsed.url || (parsed.port ? `http://localhost:${parsed.port}` : null),
109
- };
110
- return { ok: true, target };
111
- }
112
-
113
- /**
114
- * Render a quick summary for human consumption (CLI output, logs).
115
- */
116
- function describeTarget(target) {
117
- if (!target) return '(none)';
118
- if (target.shape === 'docker-compose') {
119
- return `docker-compose service ${target.service} from ${target.compose} on ${target.url || `:${target.port}`}`;
120
- }
121
- if (target.shape === 'command') {
122
- return `command "${target.start}" on ${target.url || `:${target.port}`}`;
123
- }
124
- return `unknown-shape ${target.shape}`;
125
- }
126
-
127
- /**
128
- * Pre-flight safety check: refuse to bring up a target whose start command
129
- * looks dangerous. Curated allowlist of common shapes; everything else
130
- * requires AGENTIC_SECURITY_VERIFY_TARGET_OK=1 to opt in explicitly.
131
- */
132
- function validateTarget(target) {
133
- if (!target) return { ok: false, reason: 'no-target' };
134
- if (target.shape === 'docker-compose') {
135
- // docker-compose is safe-ish by design.
136
- return { ok: true };
137
- }
138
- if (target.shape === 'command') {
139
- const SAFE_HINTS = [
140
- /^npm\s+(?:run\s+)?(?:dev|start|serve)/,
141
- /^yarn\s+(?:dev|start|serve)/,
142
- /^pnpm\s+(?:run\s+)?(?:dev|start|serve)/,
143
- /^node\s+/,
144
- /^python(?:\d?)\s+-m\s+/,
145
- /^python(?:\d?)\s+\S+\.py/,
146
- /^uvicorn\s+/,
147
- /^gunicorn\s+/,
148
- /^flask\s+run/,
149
- /^go\s+run\s+/,
150
- /^java\s+-jar\s+/,
151
- /^cargo\s+run/,
152
- ];
153
- if (process.env.AGENTIC_SECURITY_VERIFY_TARGET_OK === '1') return { ok: true, escaped: true };
154
- if (!SAFE_HINTS.some(re => re.test(target.start))) {
155
- return { ok: false, reason: `start-command-not-in-safe-allowlist (set AGENTIC_SECURITY_VERIFY_TARGET_OK=1 to override)` };
156
- }
157
- return { ok: true };
158
- }
159
- return { ok: false, reason: `unknown-shape:${target.shape}` };
160
- }
161
-
162
- const _internals = { MANIFEST_PATH };
163
-
164
-
165
- /***/ })
166
-
167
- };
@@ -1,163 +0,0 @@
1
- export const id = 6995;
2
- export const ids = [6995];
3
- export const modules = {
4
-
5
- /***/ 66995:
6
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7
-
8
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9
- /* harmony export */ addLegalHold: () => (/* binding */ addLegalHold),
10
- /* harmony export */ isUnderHold: () => (/* binding */ isUnderHold),
11
- /* harmony export */ listLegalHolds: () => (/* binding */ listLegalHolds),
12
- /* harmony export */ loadLegalHolds: () => (/* binding */ loadLegalHolds),
13
- /* harmony export */ removeLegalHold: () => (/* binding */ removeLegalHold)
14
- /* harmony export */ });
15
- /* unused harmony export LEGAL_HOLD_FILE */
16
- /* harmony import */ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73024);
17
- /* harmony import */ var _state_dir_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(69259);
18
- /* harmony import */ var _artifact_registry_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(81734);
19
- // FR-707 (assurance-hardening PRD): "Support legal hold and policy-
20
- // authorized retention exceptions | Legal hold is identity-bound, reasoned,
21
- // time-bounded where applicable, and auditable."
22
- //
23
- // A third instance of the recurring {owner, reason, expires_at} exception
24
- // shape this codebase already uses twice — `posture/suppressions.js`'s
25
- // pro-tier exception (scoped to a FINDING) and `posture/compliance-policy.js`'s
26
- // structured `not-applicable` (scoped to a COMPLIANCE CONTROL). Per D-0025,
27
- // these are deliberately distinct mechanisms serving different subjects, not
28
- // one shared module — this file is the third subject: a STATE ARTIFACT.
29
- //
30
- // Field naming matches the existing two schemas' snake_case convention
31
- // (`owner`, `reason`, `expires_at`) rather than inventing a fourth style.
32
- //
33
- // identity-bound -> `owner` (required, who placed the hold and is
34
- // accountable for lifting it)
35
- // reasoned -> `reason` (required — "we might need this later" is
36
- // not a reason; same discipline suppressions.js
37
- // already enforces for its own exceptions)
38
- // time-bounded
39
- // where applicable -> `expires_at` is OPTIONAL: a null/absent value is
40
- // an INDEFINITE hold, which the acceptance
41
- // criterion's own "where applicable" phrase
42
- // explicitly allows (a genuine legal matter may have
43
- // no known end date) — an ISO date value behaves
44
- // exactly like FR-506/FR-1004's own expiring
45
- // exceptions: once past, the hold is no longer
46
- // active and the artifact is exposed to its normal
47
- // retention TTL again.
48
- // auditable -> persisted as a single JSON array under
49
- // `.agentic-security/legal-holds.json` (itself
50
- // registered as operator-config — an operator/legal
51
- // team's own input, never scanner-written from scan
52
- // results), readable via `listLegalHolds`.
53
- //
54
- // Consulted from TWO places, not one: `retention-policy.js#findExpiredArtifacts`
55
- // (defense in depth for any caller reaching it directly) AND `cmdReset`
56
- // itself for its PLAIN (non-`--expired`) path, which deletes every
57
- // registered 'generated' artifact unconditionally and would otherwise blow
58
- // through a hold that only gated TTL expiry.
59
-
60
-
61
-
62
-
63
-
64
- const LEGAL_HOLD_FILE = 'legal-holds.json';
65
-
66
- function _loadRaw(scanRoot) {
67
- let fp;
68
- try { fp = (0,_state_dir_js__WEBPACK_IMPORTED_MODULE_1__.statePath)(scanRoot, LEGAL_HOLD_FILE); } catch { return []; }
69
- let raw;
70
- try { raw = node_fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(fp, 'utf8'); } catch { return []; }
71
- try {
72
- const doc = JSON.parse(raw);
73
- return Array.isArray(doc) ? doc : [];
74
- } catch { return []; }
75
- }
76
-
77
- /**
78
- * All legal holds ever recorded for this project, malformed entries
79
- * dropped rather than throwing. Never filters by expiry — see
80
- * `isUnderHold`/`listLegalHolds` for that.
81
- */
82
- function loadLegalHolds(scanRoot) {
83
- return _loadRaw(scanRoot).filter(h => h && typeof h === 'object' && typeof h.artifact === 'string' && typeof h.owner === 'string' && typeof h.reason === 'string');
84
- }
85
-
86
- /**
87
- * Is `artifactName` currently protected by an active (non-expired) hold?
88
- * Returns the matching hold record, or null. Multiple holds on the same
89
- * artifact are permitted (e.g. two independent legal matters); the first
90
- * still-active one found is returned.
91
- */
92
- function isUnderHold(artifactName, holds, now = Date.now()) {
93
- for (const h of holds) {
94
- if (h.artifact !== artifactName) continue;
95
- if (!h.expires_at) return h; // indefinite hold — always active
96
- const t = Date.parse(h.expires_at);
97
- if (!Number.isFinite(t) || t >= now) return h;
98
- }
99
- return null;
100
- }
101
-
102
- /**
103
- * Active (non-expired) holds only, unless `includeExpired`. For
104
- * `legal-hold list` / auditing.
105
- */
106
- function listLegalHolds(scanRoot, { includeExpired = false, now = Date.now() } = {}) {
107
- const holds = loadLegalHolds(scanRoot);
108
- if (includeExpired) return holds;
109
- return holds.filter(h => {
110
- if (!h.expires_at) return true;
111
- const t = Date.parse(h.expires_at);
112
- return !Number.isFinite(t) || t >= now;
113
- });
114
- }
115
-
116
- /**
117
- * Add a legal hold. Validates identity-bound + reasoned up front (both
118
- * required, non-empty) and that `expires_at`, if given, is a parseable
119
- * date in the future — an already-expired hold would be a hold that
120
- * protects nothing, which is never a legitimate request. `artifact` must
121
- * name a real registered artifact (artifact-registry.js) — a hold on an
122
- * unrecognised name can never protect anything and almost always means a
123
- * typo. Returns `{ok:true, hold}` or `{ok:false, reason}`; never throws.
124
- */
125
- function addLegalHold(scanRoot, { artifact, owner, reason, expires_at } = {}) {
126
- if (!artifact || typeof artifact !== 'string') return { ok: false, reason: '--artifact is required' };
127
- if (!(0,_artifact_registry_js__WEBPACK_IMPORTED_MODULE_2__/* .isRegisteredArtifact */ .Jl)(artifact)) return { ok: false, reason: `"${artifact}" is not a registered state artifact` };
128
- if (!owner || typeof owner !== 'string') return { ok: false, reason: '--owner is required (identity-bound)' };
129
- if (!reason || typeof reason !== 'string') return { ok: false, reason: '--reason is required (reasoned)' };
130
- if (expires_at) {
131
- const t = Date.parse(expires_at);
132
- if (!Number.isFinite(t)) return { ok: false, reason: 'expires_at must be a parseable date' };
133
- if (t < Date.now()) return { ok: false, reason: 'expires_at is in the past — a hold that already expired protects nothing' };
134
- }
135
- const hold = { artifact, owner, reason, expires_at: expires_at || null, created_at: new Date().toISOString() };
136
- const holds = _loadRaw(scanRoot);
137
- holds.push(hold);
138
- const fp = (0,_state_dir_js__WEBPACK_IMPORTED_MODULE_1__.statePath)(scanRoot, LEGAL_HOLD_FILE);
139
- if (!(0,_state_dir_js__WEBPACK_IMPORTED_MODULE_1__.safeWriteState)(fp, JSON.stringify(holds, null, 2) + '\n')) {
140
- return { ok: false, reason: 'state writes are disabled (--no-state) or this is not a safe state directory' };
141
- }
142
- return { ok: true, hold };
143
- }
144
-
145
- /**
146
- * Remove every hold on `artifact` (lifting a hold, not letting it expire).
147
- * Returns the number removed. A no-op (0) if none existed — never an error.
148
- */
149
- function removeLegalHold(scanRoot, artifact) {
150
- const holds = _loadRaw(scanRoot);
151
- const remaining = holds.filter(h => !(h && h.artifact === artifact));
152
- const removedCount = holds.length - remaining.length;
153
- if (removedCount > 0) {
154
- const fp = (0,_state_dir_js__WEBPACK_IMPORTED_MODULE_1__.statePath)(scanRoot, LEGAL_HOLD_FILE);
155
- (0,_state_dir_js__WEBPACK_IMPORTED_MODULE_1__.safeWriteState)(fp, JSON.stringify(remaining, null, 2) + '\n');
156
- }
157
- return removedCount;
158
- }
159
-
160
-
161
- /***/ })
162
-
163
- };
@@ -1,191 +0,0 @@
1
- export const id = 7249;
2
- export const ids = [7249];
3
- export const modules = {
4
-
5
- /***/ 27249:
6
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7
-
8
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9
- /* harmony export */ renderPrComment: () => (/* binding */ renderPrComment)
10
- /* harmony export */ });
11
- /* unused harmony export _internal */
12
- /* harmony import */ var _util_untrusted_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(11274);
13
- // Advisor-tone PR comment renderer (v0.72).
14
- //
15
- // Replaces the typical "12 findings detected, see SARIF" wall of text
16
- // with a single security-advisor's note:
17
- //
18
- // "I noticed you added /api/admin/users in this PR. I checked 4 things:
19
- // ✓ auth (route is behind requireAdmin)
20
- // ⚠ rate-limit (no rateLimit() middleware found)
21
- // ✓ input validation (express-validator chain present)
22
- // ✓ audit log (logger.security() called on success path)
23
- //
24
- // The rate-limit gap matters because /admin endpoints are common
25
- // credential-stuffing targets. A 5-line fix:
26
- //
27
- // ```js
28
- // import rateLimit from 'express-rate-limit';
29
- // app.use('/api/admin', rateLimit({ windowMs: 15*60_000, max: 30 }));
30
- // ```"
31
- //
32
- // The pure-narrative format optimizes for SCREENSHOTABILITY — engineers
33
- // share security-tool comments that read like a person, not a table.
34
- //
35
- // Generation is deterministic (no LLM) for the v1: we render from the
36
- // delta + a per-CWE narrative template. A future v2 could optionally
37
- // route through an LLM for richer prose when AGENTIC_SECURITY_LLM_ENDPOINT
38
- // is configured.
39
-
40
-
41
-
42
- const SEVERITY_GLYPH = {
43
- critical: '🟥',
44
- high: '🟧',
45
- medium: '🟨',
46
- low: '🟦',
47
- info: '⬜',
48
- };
49
-
50
- const CWE_NARRATIVE = {
51
- 'CWE-89': { name: 'SQL injection', why: 'A malicious payload like `1\' OR 1=1--` would dump every row.' },
52
- 'CWE-79': { name: 'XSS', why: 'An attacker who controls this string can execute JavaScript in another user\'s browser.' },
53
- 'CWE-78': { name: 'Command injection', why: 'A `;rm -rf /` style payload would run with the privileges of your service account.' },
54
- 'CWE-22': { name: 'path traversal', why: 'A `../../etc/passwd` style payload would read files outside the intended directory.' },
55
- 'CWE-918': { name: 'SSRF', why: 'An attacker can pivot to the cloud metadata endpoint (`169.254.169.254`) or internal services.' },
56
- 'CWE-502': { name: 'insecure deserialization', why: 'A crafted payload triggers gadget chains — typically remote code execution.' },
57
- 'CWE-611': { name: 'XXE', why: 'A malicious DOCTYPE can exfiltrate local files or trigger SSRF via entity expansion.' },
58
- 'CWE-94': { name: 'template injection', why: 'A `{{7*7}}` style payload escapes to the template engine\'s expression evaluator (often RCE).' },
59
- 'CWE-1321': { name: 'prototype pollution', why: 'A `__proto__` injection can alter the behavior of every downstream object check.' },
60
- 'CWE-352': { name: 'CSRF', why: 'A cross-origin form can trigger authenticated state changes without the user\'s knowledge.' },
61
- 'CWE-601': { name: 'open redirect', why: 'Trusted-domain bouncer for phishing — credentials get harvested on the second hop.' },
62
- 'CWE-113': { name: 'HTTP response splitting', why: 'CR/LF injection lets an attacker forge an entire response, including cache poisoning.' },
63
- 'CWE-798': { name: 'hardcoded secret', why: 'Committed credentials are scraped by automated scanners minutes after a push.' },
64
- 'CWE-327': { name: 'weak crypto', why: 'Modern adversaries can crack MD5/SHA-1/RC4/3DES at practical cost.' },
65
- 'CWE-1333': { name: 'regex DoS', why: 'A pathological input freezes the worker for seconds — DoS without much effort.' },
66
- 'CWE-90': { name: 'LDAP injection', why: 'An attacker can extend the filter to enumerate users or bypass auth.' },
67
- 'CWE-643': { name: 'XPath injection', why: 'A `\' or \'1\'=\'1` payload can return data the query never intended to expose.' },
68
- 'CWE-1336': { name: 'prompt injection', why: 'Untrusted text in the LLM context can override your system prompt.' },
69
- 'CWE-269': { name: 'privilege escalation', why: 'A low-privilege actor can reach a higher-privilege capability through this surface.' },
70
- };
71
-
72
- function _topCwes(findings, n = 3) {
73
- const counts = new Map();
74
- for (const f of findings) {
75
- const k = f.cwe || 'unknown';
76
- counts.set(k, (counts.get(k) || 0) + 1);
77
- }
78
- return [...counts.entries()].sort((a, b) => b[1] - a[1]).slice(0, n);
79
- }
80
-
81
- function _route(f) {
82
- // Best-effort: pull a route-ish string from the file path / vuln text.
83
- // Many SAST findings carry the route via `f.route` or in the vuln name.
84
- if (f.route) return f.route;
85
- const m = (f.vuln || '').match(/\b(GET|POST|PUT|DELETE|PATCH)\s+([\/\w:-]+)/i);
86
- if (m) return `${m[1].toUpperCase()} ${m[2]}`;
87
- return null;
88
- }
89
-
90
- /**
91
- * Top-level renderer. Takes a delta produced by `computePrDelta` and
92
- * emits a Markdown string suitable for posting as a single PR comment.
93
- *
94
- * Mode is chosen automatically:
95
- * - "clean": no introduced + (resolved > 0 || persistent > 0)
96
- * - "trivial": no introduced + nothing resolved
97
- * - "needs-work": one or more introduced findings
98
- */
99
- function renderPrComment(delta, { repoName, prNumber, prTitle } = {}) {
100
- if (!delta) return '_no security delta available_';
101
- const intro = delta.introduced || [];
102
- const resolved = delta.resolved || [];
103
- const shifted = delta.shifted || [];
104
- const heading = repoName && prNumber
105
- ? `### 🛡 agentic-security on ${repoName}#${prNumber}`
106
- : `### 🛡 agentic-security`;
107
- if (intro.length === 0 && resolved.length === 0 && shifted.length === 0) {
108
- return [
109
- heading,
110
- ``,
111
- `No security delta from \`${delta.baseRef}\` → \`${delta.headRef}\`. ` +
112
- `${delta.changedFiles.length} file${delta.changedFiles.length === 1 ? '' : 's'} touched; ` +
113
- `nothing in those changes introduced or resolved a finding. **Safe to merge.**`,
114
- ``,
115
- `<sub>Scanned ${delta.head?.summary?.total ?? 0} pre-existing findings on the head ref ` +
116
- `(${delta.base?.summary?.total ?? 0} on base) — none of them moved in this PR.</sub>`,
117
- ].join('\n');
118
- }
119
- if (intro.length === 0 && (resolved.length || shifted.length)) {
120
- const r = delta.summary?.resolved || {};
121
- return [
122
- heading,
123
- ``,
124
- `This PR **resolves** ${resolved.length} finding${resolved.length === 1 ? '' : 's'}` +
125
- (r.critical || r.high ? ` (including ${r.critical} critical + ${r.high} high)` : '') +
126
- ` and introduces **none**. Nice cleanup work — safe to merge. ✨`,
127
- ``,
128
- `<sub>${delta.changedFiles.length} file${delta.changedFiles.length === 1 ? '' : 's'} ` +
129
- `touched between \`${delta.baseRef}\` and \`${delta.headRef}\`.</sub>`,
130
- ].join('\n');
131
- }
132
- // needs-work mode: narrative + per-finding paragraphs.
133
- const lines = [];
134
- lines.push(heading);
135
- lines.push('');
136
- const topCwes = _topCwes(intro);
137
- const cweSummary = topCwes.map(([cwe, n]) => {
138
- const meta = CWE_NARRATIVE[cwe];
139
- return meta ? `${n} ${meta.name}` : `${n} ${cwe}`;
140
- }).join(', ');
141
- const hint = prTitle ? ` in "${prTitle}"` : '';
142
- lines.push(`I looked at the ${delta.changedFiles.length} file${delta.changedFiles.length === 1 ? '' : 's'} ` +
143
- `you changed${hint} and noticed **${intro.length} new finding${intro.length === 1 ? '' : 's'}** ` +
144
- `that wasn't on \`${delta.baseRef}\`. Top concerns: ${cweSummary}.`);
145
- lines.push('');
146
- // Per-introduced-finding paragraph (cap at 5 for readability).
147
- const SHOW = intro.slice(0, 5);
148
- for (const f of SHOW) {
149
- const meta = CWE_NARRATIVE[f.cwe];
150
- const sev = SEVERITY_GLYPH[f.severity] || '⬜';
151
- const route = _route(f);
152
- const where = route ? `\`${route}\` (\`${f.file}:${f.line}\`)` : `\`${f.file}:${f.line}\``;
153
- lines.push(`${sev} **${meta?.name || (0,_util_untrusted_js__WEBPACK_IMPORTED_MODULE_0__/* .escapeMarkdown */ .FV)(f.vuln)}** — ${where}`);
154
- if (meta) lines.push(` > ${meta.why}`);
155
- if (f.remediation) {
156
- const onelineFix = String(f.remediation).split('\n')[0].slice(0, 240);
157
- lines.push(` Suggested fix: ${onelineFix}`);
158
- }
159
- if (f.confidence != null && f.confidence < 0.7) {
160
- lines.push(` <sub>Lower confidence (${(f.confidence * 100).toFixed(0)}%) — may be a false positive worth a quick look.</sub>`);
161
- }
162
- lines.push('');
163
- }
164
- if (intro.length > SHOW.length) {
165
- lines.push(`<sub>+${intro.length - SHOW.length} more new finding${intro.length - SHOW.length === 1 ? '' : 's'} — see the scan output for the full list.</sub>`);
166
- lines.push('');
167
- }
168
- if (resolved.length) {
169
- lines.push(`On the bright side: this PR **resolved ${resolved.length} pre-existing finding${resolved.length === 1 ? '' : 's'}**. 👏`);
170
- lines.push('');
171
- }
172
- const i = delta.summary?.introduced || {};
173
- const blockMerge = (i.critical || 0) + (i.high || 0) > 0;
174
- if (blockMerge) {
175
- lines.push(`---`);
176
- lines.push(`**Blocking merge:** ${i.critical || 0} critical + ${i.high || 0} high severity ` +
177
- `finding${(i.critical || 0) + (i.high || 0) === 1 ? '' : 's'} introduced. ` +
178
- `Fix or suppress with \`// agentic-security-ignore: <rule-id>\` before merging.`);
179
- } else {
180
- lines.push(`---`);
181
- lines.push(`Non-blocking: no critical/high severity findings introduced — but consider addressing the items above before this becomes harder to revisit.`);
182
- }
183
- return lines.join('\n');
184
- }
185
-
186
- const _internal = { CWE_NARRATIVE, SEVERITY_GLYPH, _topCwes };
187
-
188
-
189
- /***/ })
190
-
191
- };