@openai/codex-security 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +306 -0
  3. package/_bundled_plugin/.app.json +20 -0
  4. package/_bundled_plugin/.codex-plugin/plugin.json +41 -0
  5. package/_bundled_plugin/.mcp.json +20 -0
  6. package/_bundled_plugin/assets/logo.png +0 -0
  7. package/_bundled_plugin/examples/completed-scan/coverage.json +22 -0
  8. package/_bundled_plugin/examples/completed-scan/findings.json +51 -0
  9. package/_bundled_plugin/examples/completed-scan/scan-manifest.json +43 -0
  10. package/_bundled_plugin/mcp/mcp-app.html.br +0 -0
  11. package/_bundled_plugin/mcp/server.mjs +24 -0
  12. package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
  13. package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
  14. package/_bundled_plugin/preflight/capability-profiles.toml +179 -0
  15. package/_bundled_plugin/references/config-preflight.md +115 -0
  16. package/_bundled_plugin/references/final-report.md +205 -0
  17. package/_bundled_plugin/references/finding-detail-fields.md +162 -0
  18. package/_bundled_plugin/references/sarif-adapter.md +26 -0
  19. package/_bundled_plugin/references/scan-artifacts.md +116 -0
  20. package/_bundled_plugin/references/scan-contract.md +164 -0
  21. package/_bundled_plugin/references/security-guidance.md +15 -0
  22. package/_bundled_plugin/references/shared-hard-rules.md +15 -0
  23. package/_bundled_plugin/references/static-finding-assessment.md +75 -0
  24. package/_bundled_plugin/schemas/coverage.schema.json +228 -0
  25. package/_bundled_plugin/schemas/findings.schema.json +359 -0
  26. package/_bundled_plugin/schemas/scan-manifest.schema.json +332 -0
  27. package/_bundled_plugin/scripts/config_preflight.py +901 -0
  28. package/_bundled_plugin/scripts/deep_scan_config.py +108 -0
  29. package/_bundled_plugin/scripts/deep_scan_workbench.py +1547 -0
  30. package/_bundled_plugin/scripts/filesystem_identity.py +30 -0
  31. package/_bundled_plugin/scripts/finalize_scan_contract.py +2208 -0
  32. package/_bundled_plugin/scripts/finding_preview.py +270 -0
  33. package/_bundled_plugin/scripts/generate_rank_input.py +1013 -0
  34. package/_bundled_plugin/scripts/normalize_candidates.py +320 -0
  35. package/_bundled_plugin/scripts/rank_preview.py +968 -0
  36. package/_bundled_plugin/scripts/report_projection.py +844 -0
  37. package/_bundled_plugin/scripts/resolve_security_md.py +158 -0
  38. package/_bundled_plugin/scripts/snapshot_sqlite.py +26 -0
  39. package/_bundled_plugin/scripts/validate_report_format.py +138 -0
  40. package/_bundled_plugin/scripts/validate_scan_contract.py +108 -0
  41. package/_bundled_plugin/scripts/validate_tracking_source.py +92 -0
  42. package/_bundled_plugin/scripts/windows_scan_local_files.py +612 -0
  43. package/_bundled_plugin/scripts/workbench/__init__.py +1 -0
  44. package/_bundled_plugin/scripts/workbench/handoff.py +238 -0
  45. package/_bundled_plugin/scripts/workbench_cli.py +325 -0
  46. package/_bundled_plugin/scripts/workbench_constants.py +81 -0
  47. package/_bundled_plugin/scripts/workbench_db.py +3728 -0
  48. package/_bundled_plugin/scripts/workbench_native_indexes.py +242 -0
  49. package/_bundled_plugin/scripts/workbench_progress.py +226 -0
  50. package/_bundled_plugin/scripts/workbench_remediation.py +125 -0
  51. package/_bundled_plugin/scripts/workbench_scan_history.py +829 -0
  52. package/_bundled_plugin/scripts/workbench_scan_start.py +149 -0
  53. package/_bundled_plugin/scripts/workbench_schema.py +714 -0
  54. package/_bundled_plugin/scripts/workbench_source_excerpt.py +99 -0
  55. package/_bundled_plugin/scripts/workbench_target.py +469 -0
  56. package/_bundled_plugin/scripts/workbench_target_state.py +63 -0
  57. package/_bundled_plugin/scripts/workbench_validation.py +294 -0
  58. package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +117 -0
  59. package/_bundled_plugin/skills/attack-path-analysis/agents/openai.yaml +4 -0
  60. package/_bundled_plugin/skills/attack-path-analysis/references/attack-path-facts.md +76 -0
  61. package/_bundled_plugin/skills/attack-path-analysis/references/severity-policy.md +153 -0
  62. package/_bundled_plugin/skills/deep-security-scan/SKILL.md +166 -0
  63. package/_bundled_plugin/skills/deep-security-scan/agents/openai.yaml +4 -0
  64. package/_bundled_plugin/skills/define-security-policy/SKILL.md +93 -0
  65. package/_bundled_plugin/skills/define-security-policy/agents/openai.yaml +4 -0
  66. package/_bundled_plugin/skills/finding-discovery/SKILL.md +155 -0
  67. package/_bundled_plugin/skills/finding-discovery/agents/openai.yaml +4 -0
  68. package/_bundled_plugin/skills/fix-finding/SKILL.md +112 -0
  69. package/_bundled_plugin/skills/fix-finding/agents/openai.yaml +4 -0
  70. package/_bundled_plugin/skills/propose-security-hardening/SKILL.md +240 -0
  71. package/_bundled_plugin/skills/propose-security-hardening/agents/openai.yaml +4 -0
  72. package/_bundled_plugin/skills/propose-security-hardening/references/proposal-format.md +424 -0
  73. package/_bundled_plugin/skills/security-diff-scan/SKILL.md +167 -0
  74. package/_bundled_plugin/skills/security-diff-scan/agents/openai.yaml +4 -0
  75. package/_bundled_plugin/skills/security-scan/SKILL.md +42 -0
  76. package/_bundled_plugin/skills/security-scan/agents/openai.yaml +4 -0
  77. package/_bundled_plugin/skills/security-scan/references/repository-wide-scan.md +48 -0
  78. package/_bundled_plugin/skills/security-scan/references/scan-artifacts-and-ledger.md +85 -0
  79. package/_bundled_plugin/skills/threat-model/SKILL.md +59 -0
  80. package/_bundled_plugin/skills/threat-model/agents/openai.yaml +4 -0
  81. package/_bundled_plugin/skills/threat-model/references/threat-model-guidance.md +48 -0
  82. package/_bundled_plugin/skills/track-findings/SKILL.md +222 -0
  83. package/_bundled_plugin/skills/track-findings/agents/openai.yaml +6 -0
  84. package/_bundled_plugin/skills/track-findings/references/github-security-advisories.md +54 -0
  85. package/_bundled_plugin/skills/track-findings/references/jira.md +77 -0
  86. package/_bundled_plugin/skills/triage-finding/SKILL.md +342 -0
  87. package/_bundled_plugin/skills/triage-finding/agents/openai.yaml +4 -0
  88. package/_bundled_plugin/skills/triage-finding/references/github-rest-intake.md +168 -0
  89. package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +62 -0
  90. package/_bundled_plugin/skills/triage-finding/references/triage-result-contract.md +108 -0
  91. package/_bundled_plugin/skills/validation/SKILL.md +110 -0
  92. package/_bundled_plugin/skills/validation/agents/openai.yaml +4 -0
  93. package/_bundled_plugin/skills/validation/references/validation-guidance.md +122 -0
  94. package/_bundled_plugin/skills/vulnerability-writeup/SKILL.md +263 -0
  95. package/_bundled_plugin/skills/vulnerability-writeup/agents/openai.yaml +4 -0
  96. package/_bundled_plugin/skills/vulnerability-writeup/references/report-format.md +104 -0
  97. package/bin/codex-security.mjs +26 -0
  98. package/dist/api.d.ts +112 -0
  99. package/dist/api.d.ts.map +1 -0
  100. package/dist/api.js +1051 -0
  101. package/dist/api.js.map +1 -0
  102. package/dist/auth.d.ts +29 -0
  103. package/dist/auth.d.ts.map +1 -0
  104. package/dist/auth.js +246 -0
  105. package/dist/auth.js.map +1 -0
  106. package/dist/bulk-scan-discovery.d.ts +35 -0
  107. package/dist/bulk-scan-discovery.d.ts.map +1 -0
  108. package/dist/bulk-scan-discovery.js +217 -0
  109. package/dist/bulk-scan-discovery.js.map +1 -0
  110. package/dist/cli.d.ts +67 -0
  111. package/dist/cli.d.ts.map +1 -0
  112. package/dist/cli.js +2128 -0
  113. package/dist/cli.js.map +1 -0
  114. package/dist/config.d.ts +19 -0
  115. package/dist/config.d.ts.map +1 -0
  116. package/dist/config.js +199 -0
  117. package/dist/config.js.map +1 -0
  118. package/dist/contract.d.ts +21 -0
  119. package/dist/contract.d.ts.map +1 -0
  120. package/dist/contract.js +848 -0
  121. package/dist/contract.js.map +1 -0
  122. package/dist/cost.d.ts +30 -0
  123. package/dist/cost.d.ts.map +1 -0
  124. package/dist/cost.js +280 -0
  125. package/dist/cost.js.map +1 -0
  126. package/dist/errors.d.ts +38 -0
  127. package/dist/errors.d.ts.map +1 -0
  128. package/dist/errors.js +52 -0
  129. package/dist/errors.js.map +1 -0
  130. package/dist/index.d.ts +22 -0
  131. package/dist/index.d.ts.map +1 -0
  132. package/dist/index.js +11 -0
  133. package/dist/index.js.map +1 -0
  134. package/dist/knowledge-base.d.ts +7 -0
  135. package/dist/knowledge-base.d.ts.map +1 -0
  136. package/dist/knowledge-base.js +181 -0
  137. package/dist/knowledge-base.js.map +1 -0
  138. package/dist/models.d.ts +231 -0
  139. package/dist/models.d.ts.map +1 -0
  140. package/dist/models.js +3 -0
  141. package/dist/models.js.map +1 -0
  142. package/dist/multiscan.d.ts +30 -0
  143. package/dist/multiscan.d.ts.map +1 -0
  144. package/dist/multiscan.js +397 -0
  145. package/dist/multiscan.js.map +1 -0
  146. package/dist/result.d.ts +39 -0
  147. package/dist/result.d.ts.map +1 -0
  148. package/dist/result.js +71 -0
  149. package/dist/result.js.map +1 -0
  150. package/dist/runtime.d.ts +69 -0
  151. package/dist/runtime.d.ts.map +1 -0
  152. package/dist/runtime.js +997 -0
  153. package/dist/runtime.js.map +1 -0
  154. package/dist/scan-comparison.d.ts +42 -0
  155. package/dist/scan-comparison.d.ts.map +1 -0
  156. package/dist/scan-comparison.js +153 -0
  157. package/dist/scan-comparison.js.map +1 -0
  158. package/dist/scan-history-renderer.d.ts +13 -0
  159. package/dist/scan-history-renderer.d.ts.map +1 -0
  160. package/dist/scan-history-renderer.js +297 -0
  161. package/dist/scan-history-renderer.js.map +1 -0
  162. package/dist/targets.d.ts +39 -0
  163. package/dist/targets.d.ts.map +1 -0
  164. package/dist/targets.js +295 -0
  165. package/dist/targets.js.map +1 -0
  166. package/dist/trusted-executable.d.ts +6 -0
  167. package/dist/trusted-executable.d.ts.map +1 -0
  168. package/dist/trusted-executable.js +77 -0
  169. package/dist/trusted-executable.js.map +1 -0
  170. package/dist/version.d.ts +6 -0
  171. package/dist/version.d.ts.map +1 -0
  172. package/dist/version.js +42 -0
  173. package/dist/version.js.map +1 -0
  174. package/dist/worker-progress.d.ts +13 -0
  175. package/dist/worker-progress.d.ts.map +1 -0
  176. package/dist/worker-progress.js +113 -0
  177. package/dist/worker-progress.js.map +1 -0
  178. package/package.json +74 -0
@@ -0,0 +1,294 @@
1
+ """Shared validation helpers for Codex Security workbench commands."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import json
7
+ import math
8
+ import sqlite3
9
+ import uuid
10
+ from pathlib import Path
11
+ from typing import Any
12
+
13
+ from workbench_constants import (
14
+ MAX_CAPABILITY_PREFLIGHT_INPUT_JSON_BYTES,
15
+ MAX_CAPABILITY_PREFLIGHT_PERSISTED_JSON_BYTES,
16
+ )
17
+
18
+
19
+ def require_uuid(value: str, label: str) -> str:
20
+ try:
21
+ return str(uuid.UUID(value))
22
+ except ValueError as exc:
23
+ raise SystemExit(f"{label} must be a UUID.") from exc
24
+
25
+
26
+ def optional_text(value: str | None, *, maximum: int | None = None) -> str | None:
27
+ if value is None:
28
+ return None
29
+ normalized = value.strip()
30
+ if maximum is not None and len(normalized) > maximum:
31
+ raise SystemExit(f"Text value must be no longer than {maximum} characters.")
32
+ return normalized or None
33
+
34
+
35
+ def reject_nonstandard_json_number(value: str) -> None:
36
+ raise ValueError(f"invalid JSON number {value}")
37
+
38
+
39
+ def parse_scan_cost(value: str | None) -> str | None:
40
+ if value is None:
41
+ return None
42
+ if len(value.encode("utf-8")) > 8192:
43
+ raise SystemExit("Scan cost must be no larger than 8 KiB.")
44
+ try:
45
+ cost = json.loads(value, parse_constant=reject_nonstandard_json_number)
46
+ except (TypeError, UnicodeError, ValueError) as exc:
47
+ raise SystemExit("Scan cost must be a valid JSON object.") from exc
48
+ token_keys = ("inputTokens", "cachedInputTokens", "cacheWriteInputTokens", "outputTokens")
49
+ if (
50
+ not isinstance(cost, dict)
51
+ or not isinstance(cost.get("model"), str)
52
+ or not cost["model"]
53
+ or any(type(cost.get(key)) is not int or cost[key] < 0 for key in token_keys)
54
+ or cost["cachedInputTokens"] + cost["cacheWriteInputTokens"] > cost["inputTokens"]
55
+ or type(cost.get("estimatedUsd")) not in (int, float)
56
+ or not math.isfinite(cost["estimatedUsd"])
57
+ or cost["estimatedUsd"] < 0
58
+ ):
59
+ raise SystemExit(
60
+ "Scan cost must include a model, nonnegative token counts, and an estimated USD amount."
61
+ )
62
+ return json.dumps(cost, separators=(",", ":"), allow_nan=False)
63
+
64
+
65
+ def capability_preflight_json(
66
+ value: str | None,
67
+ *,
68
+ checked_target_path: str | None,
69
+ checked_mode: str,
70
+ ) -> str | None:
71
+ normalized = optional_text(value)
72
+ if normalized is None:
73
+ return None
74
+ if len(normalized.encode("utf-8")) > MAX_CAPABILITY_PREFLIGHT_INPUT_JSON_BYTES:
75
+ raise SystemExit(
76
+ "Capability preflight must be no larger than "
77
+ f"{MAX_CAPABILITY_PREFLIGHT_INPUT_JSON_BYTES} bytes."
78
+ )
79
+ try:
80
+ payload = json.loads(normalized, parse_constant=reject_nonstandard_json_number)
81
+ except (json.JSONDecodeError, ValueError) as exc:
82
+ raise SystemExit("Capability preflight must be valid JSON.") from exc
83
+ if not isinstance(payload, dict):
84
+ raise SystemExit("Capability preflight must be a JSON object.")
85
+ _require_object_keys(
86
+ payload,
87
+ required={"issues", "profile", "status"},
88
+ optional={"remediation"},
89
+ label="Capability preflight",
90
+ )
91
+ profile = _bounded_preflight_text(payload.get("profile"), 128, "profile")
92
+ status = payload.get("status")
93
+ if status not in {"ready", "blocked", "incomplete"}:
94
+ raise SystemExit("Capability preflight status is invalid.")
95
+ issues = payload.get("issues")
96
+ if not isinstance(issues, list) or len(issues) > 32:
97
+ raise SystemExit("Capability preflight issues must be an array of at most 32 objects.")
98
+ normalized_issues: list[dict[str, str]] = []
99
+ for index, issue in enumerate(issues):
100
+ if not isinstance(issue, dict):
101
+ raise SystemExit("Capability preflight issues must be an array of at most 32 objects.")
102
+ label = f"Capability preflight issue {index + 1}"
103
+ _require_object_keys(
104
+ issue,
105
+ required={"capability", "reason", "severity", "status"},
106
+ optional=set(),
107
+ label=label,
108
+ )
109
+ severity = issue.get("severity")
110
+ issue_status = issue.get("status")
111
+ if severity not in {"block", "warn", "suggest"} or issue_status not in {
112
+ "fail",
113
+ "unknown",
114
+ }:
115
+ raise SystemExit(f"{label} has an invalid severity or status.")
116
+ normalized_issues.append(
117
+ {
118
+ "capability": _bounded_preflight_text(
119
+ issue.get("capability"), 128, f"issue {index + 1} capability"
120
+ ),
121
+ "reason": _bounded_preflight_text(
122
+ issue.get("reason"), 1200, f"issue {index + 1} reason"
123
+ ),
124
+ "severity": severity,
125
+ "status": issue_status,
126
+ }
127
+ )
128
+ remediation = payload.get("remediation")
129
+ normalized_remediation: dict[str, Any] | None = None
130
+ if remediation is not None:
131
+ if not isinstance(remediation, dict):
132
+ raise SystemExit("Capability preflight remediation must be a JSON object.")
133
+ _require_object_keys(
134
+ remediation,
135
+ required=set(),
136
+ optional={"note", "patches", "summary"},
137
+ label="Capability preflight remediation",
138
+ )
139
+ normalized_remediation = {}
140
+ for key, maximum in (("note", 2400), ("summary", 1200)):
141
+ if key in remediation:
142
+ normalized_remediation[key] = _bounded_preflight_text(
143
+ remediation.get(key), maximum, f"remediation {key}"
144
+ )
145
+ if "patches" in remediation:
146
+ patches = remediation.get("patches")
147
+ if not isinstance(patches, list) or len(patches) > 32:
148
+ raise SystemExit(
149
+ "Capability preflight remediation patches must be an array of at most 32 objects."
150
+ )
151
+ normalized_remediation["patches"] = [
152
+ _normalize_preflight_patch(patch, index) for index, patch in enumerate(patches)
153
+ ]
154
+ has_unknown = any(issue.get("status") == "unknown" for issue in issues)
155
+ has_blocking_failure = any(
156
+ issue.get("severity") == "block" and issue.get("status") == "fail" for issue in issues
157
+ )
158
+ expected_status = (
159
+ "blocked" if has_blocking_failure else "incomplete" if has_unknown else "ready"
160
+ )
161
+ if status != expected_status:
162
+ raise SystemExit(
163
+ f"Capability preflight status must be {expected_status} for the supplied issues."
164
+ )
165
+ normalized_payload: dict[str, Any] = {
166
+ "profile": profile,
167
+ "status": status,
168
+ "issues": normalized_issues,
169
+ "checkedTargetPath": checked_target_path,
170
+ "checkedMode": checked_mode,
171
+ }
172
+ if normalized_remediation is not None:
173
+ normalized_payload["remediation"] = normalized_remediation
174
+ serialized = json.dumps(
175
+ normalized_payload,
176
+ ensure_ascii=False,
177
+ separators=(",", ":"),
178
+ sort_keys=True,
179
+ )
180
+ serialized = _escape_json_surrogates(serialized)
181
+ if len(serialized.encode("utf-8")) > MAX_CAPABILITY_PREFLIGHT_PERSISTED_JSON_BYTES:
182
+ raise SystemExit(
183
+ "Persisted capability preflight must be no larger than "
184
+ f"{MAX_CAPABILITY_PREFLIGHT_PERSISTED_JSON_BYTES} bytes."
185
+ )
186
+ return serialized
187
+
188
+
189
+ def capability_preflight_input(value: str | None, path: Path | None) -> str | None:
190
+ if path is None:
191
+ return value
192
+ try:
193
+ if path.stat().st_size > MAX_CAPABILITY_PREFLIGHT_INPUT_JSON_BYTES:
194
+ raise SystemExit(
195
+ "Capability preflight must be no larger than "
196
+ f"{MAX_CAPABILITY_PREFLIGHT_INPUT_JSON_BYTES} bytes."
197
+ )
198
+ return path.read_text(encoding="utf-8")
199
+ except (OSError, UnicodeError) as exc:
200
+ raise SystemExit("Capability preflight JSON file could not be read as UTF-8.") from exc
201
+
202
+
203
+ def _require_object_keys(
204
+ value: dict[str, Any], *, required: set[str], optional: set[str], label: str
205
+ ) -> None:
206
+ keys = set(value)
207
+ missing = required - keys
208
+ extra = keys - required - optional
209
+ if missing:
210
+ raise SystemExit(f"{label} is missing required fields: {', '.join(sorted(missing))}.")
211
+ if extra:
212
+ raise SystemExit(f"{label} has unsupported fields: {', '.join(sorted(extra))}.")
213
+
214
+
215
+ def _bounded_preflight_text(value: Any, maximum: int, label: str) -> str:
216
+ if not isinstance(value, str):
217
+ raise SystemExit(f"Capability preflight {label} must be text.")
218
+ normalized = value.strip()
219
+ if not normalized or _javascript_string_length(normalized) > maximum:
220
+ raise SystemExit(f"Capability preflight {label} must contain 1 to {maximum} characters.")
221
+ return normalized
222
+
223
+
224
+ def _javascript_string_length(value: str) -> int:
225
+ return len(value.encode("utf-16-le", errors="surrogatepass")) // 2
226
+
227
+
228
+ def _escape_json_surrogates(value: str) -> str:
229
+ return "".join(
230
+ f"\\u{ord(character):04x}" if 0xD800 <= ord(character) <= 0xDFFF else character
231
+ for character in value
232
+ )
233
+
234
+
235
+ def _normalize_preflight_patch(value: Any, index: int) -> dict[str, Any]:
236
+ label = f"Capability preflight remediation patch {index + 1}"
237
+ if not isinstance(value, dict):
238
+ raise SystemExit(f"{label} must be a JSON object.")
239
+ _require_object_keys(
240
+ value,
241
+ required={"path", "value"},
242
+ optional={"kind"},
243
+ label=label,
244
+ )
245
+ normalized: dict[str, Any] = {
246
+ "path": _bounded_preflight_text(value.get("path"), 256, f"patch {index + 1} path")
247
+ }
248
+ if "kind" in value:
249
+ kind = value.get("kind")
250
+ if kind not in {"config", "host_setting"}:
251
+ raise SystemExit(f"{label} has an invalid kind.")
252
+ normalized["kind"] = kind
253
+ patch_value = value.get("value")
254
+ if isinstance(patch_value, str):
255
+ if _javascript_string_length(patch_value) > 2048:
256
+ raise SystemExit(f"{label} value must be no longer than 2048 characters.")
257
+ elif isinstance(patch_value, bool):
258
+ pass
259
+ elif isinstance(patch_value, (int, float)):
260
+ try:
261
+ finite = math.isfinite(float(patch_value))
262
+ except OverflowError:
263
+ finite = False
264
+ if not finite:
265
+ raise SystemExit(f"{label} value must be a finite number.")
266
+ else:
267
+ raise SystemExit(f"{label} value must be text, a number, or a boolean.")
268
+ normalized["value"] = patch_value
269
+ return normalized
270
+
271
+
272
+ def bounded_output_text(value: Any, maximum_bytes: int) -> str:
273
+ encoded = str(value).encode("utf-8")[:maximum_bytes]
274
+ return encoded.decode("utf-8", errors="ignore")
275
+
276
+
277
+ def require_occurrence(connection: sqlite3.Connection, occurrence_id: str) -> sqlite3.Row:
278
+ occurrence_id = optional_text(occurrence_id, maximum=256)
279
+ if occurrence_id is None:
280
+ raise SystemExit("occurrence-id is required.")
281
+ row = connection.execute(
282
+ "SELECT * FROM finding_occurrences WHERE id = ?", (occurrence_id,)
283
+ ).fetchone()
284
+ if row is None:
285
+ raise SystemExit("Codex Security finding occurrence not found.")
286
+ return row
287
+
288
+
289
+ def main() -> None:
290
+ argparse.ArgumentParser(description=__doc__).parse_args()
291
+
292
+
293
+ if __name__ == "__main__":
294
+ main()
@@ -0,0 +1,117 @@
1
+ ---
2
+ name: attack-path-analysis
3
+ description: Use when Codex is already in the attack-path-analysis phase of a security scan or the user explicitly asks to trace a security finding from source to sink and calibrate severity. Do not use as the primary trigger for full PR, commit, branch, patch, or repository scans.
4
+ ---
5
+
6
+ # Security Attack Path Analysis
7
+
8
+ ## Objective
9
+
10
+ Turn validated or still-plausible findings into explicit attacker stories, structured attack-path analysis facts, severity calibration, and a final reportability decision grounded in the threat model.
11
+
12
+ ## Artifact Resolution
13
+
14
+ The path references in this skill are the default locations for this phase.
15
+ If the user explicitly provides a different path for a required input or output, use the user-provided path instead of the corresponding default path referenced in this skill.
16
+ If a required input is still missing, stop and ask the user for it before continuing.
17
+ Use the shared scan artifact path conventions in `../../references/scan-artifacts.md`.
18
+
19
+ ### Compact Standard-Scan Mode
20
+
21
+ When `$security-scan` explicitly invokes this skill in compact standard-scan mode, load the per-scan threat model and the enriched `<discovery_dir>/candidate_ledger.jsonl`. Analyze, in one invocation, every row whose validation disposition is `reportable` or `deferred`. Add one nested `attack_path` record to each row that enters the phase, using the compact record shape in `../../references/scan-artifacts.md`, while preserving every discovery and validation field and the original row order.
22
+
23
+ In this mode, the nested record replaces the per-finding attack-path report and receipt. Rewrite the ledger atomically. Keep attack-path facts, counterevidence, severity calibration, and policy adjustment as separate reasoning steps even though their output is compact. All reachability, instance-preservation, and evidence requirements still apply; only the artifact packaging changes.
24
+
25
+ ## Workflow
26
+
27
+ 1. Load the per-scan threat model path from `../../references/scan-artifacts.md` as the repo-specific threat-model source of truth. Start from this along with the potential findings. Both inputs are required for this workflow.
28
+ - For repository-wide and scoped-path scans, include validation closure rows marked `reportable` or `survives: yes` even if they were not assigned polished candidate numbers during discovery.
29
+ 2. Determine whether the affected code is in scope for the repository threat model and whether it belongs to a product surface or production workflow.
30
+ 3. Build a factual attack path using repository evidence only:
31
+ - service mapping
32
+ - exposure and entry points
33
+ - identity, privilege, and trust boundaries
34
+ - secrets handling and sensitive-data flow
35
+ - reachability
36
+ - existing controls and mitigations
37
+ 4. Before finalizing scope or reportability-driving facts, identify the strongest repository counterevidence against the key scoping fields and explain why it is or is not dispositive.
38
+ 5. Calibrate impact and likelihood from the repository evidence.
39
+ 6. Apply a separate final policy-adjustment pass mechanically using those facts and the calibrated severity.
40
+ 7. Record final policy decision `ignore` explicitly. Outside compact standard-scan mode, drop it from the surviving finding set; in compact mode, retain the ledger row for coverage mapping.
41
+ 8. In compact standard-scan mode, add the nested `attack_path` record to every candidate that entered the phase and atomically replace the ledger.
42
+ 9. Outside compact standard-scan mode, save that finding's visible attack-path report and append one attack-path receipt per candidate id at the default paths from `../../references/scan-artifacts.md`. The receipt must record the candidate id, attack-path reportability decision, attack-path facts or exact proof gap, and attack-path artifact/report reference for that candidate finding.
43
+
44
+ ## Scope and Attack Path Checklist
45
+
46
+ Use this checklist before finalizing the attack-path facts or policy decision:
47
+
48
+ - Determine whether the finding is actually a real security vulnerability rather than a correctness bug or false positive.
49
+ - Determine whether the affected code belongs to a product surface or production workflow.
50
+ - Map the relevant service, component, or workflow context from repository evidence.
51
+ - Establish exposure and entry points from repository evidence such as listeners, ingress, load balancers, service ports, manifests, routing, or network policy.
52
+ - Establish identities, privileges, and trust boundaries that matter for the path.
53
+ - Establish whether sensitive data, secrets references, or privileged control paths are involved.
54
+ - Determine whether a realistic attacker can actually reach and use the issue from an in-scope attack surface.
55
+ - Identify the strongest repository counterevidence against the scoping and reportability-driving fields before finalizing them.
56
+ - Lower confidence or keep fields unknown when repository evidence is incomplete; do not automatically suppress a finding solely because deployment evidence is missing.
57
+
58
+ ## Counterevidence Checklist
59
+
60
+ For the most interpretive fields, explicitly ask what repository evidence suggests the opposite and why it does or does not defeat the finding:
61
+
62
+ - In-Scope Status According to the Threat Model
63
+ - Vector
64
+ - Auth Scope
65
+ - Exposure
66
+ - Cross-Boundary Behavior
67
+ - Preconditions
68
+ - Impact Surface
69
+
70
+ Look specifically for repository evidence that the path is:
71
+
72
+ - out of scope
73
+ - internal-only
74
+ - admin-only
75
+ - not cross-boundary
76
+ - not attacker-reachable
77
+ - not meaningfully reportable
78
+
79
+ ## Severity and Policy Checklist
80
+
81
+ Apply severity and policy calibration using `references/severity-policy.md`.
82
+
83
+ ## Output Contract
84
+
85
+ In compact standard-scan mode, use the nested record defined in `../../references/scan-artifacts.md`. Every validation row with disposition `reportable` or `deferred` must receive exactly one attack-path decision. The record is the phase closure for this mode; do not also create a narrative report or receipt.
86
+
87
+ Outside compact standard-scan mode, use the following report contract.
88
+
89
+ For each surviving finding include:
90
+
91
+ - title
92
+ - candidate id, instance key, and ledger row id when provided
93
+ - affected lines from validation, preserving labeled entrypoint/wrapper, root_control, sink, and concrete_implementation locations
94
+ - attack path steps
95
+ - rendered attack-path facts
96
+ - counterevidence summary and challenges
97
+ - severity calibration
98
+ - final policy decision
99
+ - enough reasoning that a later reader can understand why the finding survived or was suppressed
100
+
101
+ Render attack-path facts using `references/attack-path-facts.md`.
102
+
103
+ ## Hard Rules
104
+
105
+ - Prefer repository evidence first, but use network connectivity when it materially helps confirm deployment context, reachable surfaces, or other reportability-relevant facts.
106
+ - Do not invent attack chains that the code does not support.
107
+ - Do not leave candidate coverage implicit. In compact standard-scan mode, every candidate that reaches attack-path analysis must receive a nested `attack_path` record, even when the final policy decision is `ignore` or `deferred`. In other modes, every such candidate must leave an attack-path receipt in its candidate-ledger path from `../../references/scan-artifacts.md`.
108
+ - Do not drop exact affected locations while converting validated findings into attack paths. Repository-wide seeded/root-control rows that survive validation must keep their root-control file:line even when a wrapper, route, or transport is easier to explain.
109
+ - Do not skip a reportable validation row because a neighboring same-family finding has a cleaner story. Either produce attack-path facts for that exact row or make an explicit final policy decision with repository counterevidence.
110
+ - Missing public-ingress evidence is not by itself dispositive counterevidence.
111
+ - Keep attack-path analysis, severity calibration, and final policy suppression as separate sub-stages.
112
+ - Use the final policy-adjustment matrix mechanically rather than re-arguing severity from scratch after the facts are set.
113
+ - Outside compact standard-scan mode, save a final visible report for each candidate finding using that finding's attack-path analysis report path from `../../references/scan-artifacts.md`. Compact standard scans use the nested phase record instead.
114
+
115
+ -- Considerations for attack path --
116
+ - A bug matters if evidence shows an attacker could exploit it.
117
+ - The attack surface should generally be one that is plausibly exposed to end users / external actors (or another actor explicitly in scope in the threat model).
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Attack Path Analysis"
3
+ short_description: "Perform attack-path analysis for a security finding"
4
+ default_prompt: "Use $attack-path-analysis to trace a given security finding from source to sink and calibrate severity accordingly."
@@ -0,0 +1,76 @@
1
+ # Attack Path Facts Guidance
2
+
3
+ Use this guidance during attack-path analysis before severity calibration.
4
+
5
+ ## Attack Path Facts
6
+
7
+ The attack-path facts should be gathered in structured form during analysis, but the final report should render them as markdown under a section such as `### Attack Path Facts` or a similarly clear heading.
8
+
9
+ That rendered facts section should explicitly cover:
10
+
11
+ - Assumptions
12
+ - Context:
13
+ - whether the impact is self-only or crosses a meaningful boundary
14
+ - the repository evidence for that conclusion
15
+ - In-Scope Status According to the Threat Model:
16
+ - whether the component is in scope
17
+ - the reasoning
18
+ - Exposure:
19
+ - whether the surface is public
20
+ - ports, ingress, and load-balancer type when repository evidence exists
21
+ - the evidence
22
+ - Identity:
23
+ - service account or managed identity if present
24
+ - effective privileges
25
+ - Cross-Boundary Behavior:
26
+ - whether a boundary crossing is actually verified
27
+ - the evidence chain
28
+ - Vector:
29
+ - `remote`, `local_network`, `localhost`, `none`, or `unknown`
30
+ - the evidence
31
+ - Preconditions:
32
+ - what the attacker needs
33
+ - whether those preconditions are plausible, unlikely, unachievable, or unknown
34
+ - the evidence
35
+ - Attacker Input Control:
36
+ - whether attacker control is yes, plausible, no, or unknown
37
+ - the evidence
38
+ - Category
39
+ - Mitigations Already Present
40
+ - Auth Scope:
41
+ - whether the path is public, internal-only, admin-only, or unknown
42
+ - the evidence
43
+ - Impact Surface:
44
+ - build, runtime, data, identity, network, or other
45
+ - the evidence
46
+ - Target Reach:
47
+ - single service, base image, fleet, or unknown
48
+ - the evidence
49
+ - Secrets References:
50
+ - the secret type and reference chain when present
51
+ - Counterevidence:
52
+ - the strongest conflicting repository evidence for the reportability-driving facts
53
+ - why that evidence is or is not dispositive
54
+ - Blindspots
55
+ - Controls
56
+ - Confidence
57
+
58
+ Prefer turning those facts into readable bullets or short labeled paragraphs instead of exposing a raw schema dump. The final report should make the scoping and reportability facts easy to inspect, including:
59
+
60
+ - whether the finding is in scope according to the threat model
61
+ - whether the surface is public, internal, admin-only, localhost-only, or unknown
62
+ - what attacker-controlled input exists
63
+ - what preconditions the attacker needs and whether they are achievable
64
+ - whether a real trust boundary is crossed
65
+ - what identities, privileges, or secrets are involved
66
+ - what mitigations and controls already exist
67
+ - what the strongest repository counterevidence is
68
+ - what blindspots or residual uncertainty remain
69
+
70
+ Also make sure the rendered report carries forward:
71
+
72
+ - the factual attack path as numbered attacker steps
73
+ - the reachability and scoping logic
74
+ - the strongest conflicting repository evidence
75
+ - the final policy decision after suppression
76
+ - the reasoning behind impact and likelihood
@@ -0,0 +1,153 @@
1
+ # Severity and Policy Guidance
2
+
3
+ Use this guidance after attack-path facts, reachability, and counterevidence are established.
4
+
5
+ -- Considerations for severity / criticality re-rating --
6
+ - For `high` and above, the impact must be materially security-relevant (for example: account takeover, auth bypass, meaningful privilege escalation, significant sensitive data exposure/exfiltration, credible RCE, or similarly severe compromise), not simply a bug or strange behavior
7
+ - For a finding to remain `high` or `critical`, the exploitation path and impact should be clear enough that a professional security reviewer would not need a long speculative argument to justify it.
8
+ - Do **not** treat ordinary code bugs as high/critical security issues just because they are bugs or because the scanner labeled them that way.
9
+ - Do **not** keep `critical` based on contrived, highly speculative, or edge-case-only exploit stories unless the threat model explicitly supports those conditions. Critical DEMANDS attention implying an immediate likely threat.
10
+ - Do **not** keep `high`/`critical` for strange configurations or odd codebase behaviors unless there is clear evidence that an in-scope attacker can realistically exploit them for major impact.
11
+ - Do **not** rely on unusual operator mistakes, internal-only access, or non-attacker-reachable code paths to justify severe external impact unless the repository threat model says those actors/paths are in scope.
12
+ - If the issue is a real bug but not actually a security vulnerability, classify it as `ignore` (or, if you have to, `low`) for criticality purposes.
13
+ - If it is actually provable that there is no bug at all (the description is entirely wrong or made up and you actually got that real proof that it is so), then label it as `ignore` for criticality to mark a false-positive.
14
+
15
+ Non-exhaustive examples of vulnerabilities that often support `critical` when evidenced in code and context:
16
+ - Credible RCE or arbitrary code execution (command injection, LFI exec, trivial memory corruption exploits, etc.). Requires actual proof that attacker input causes this from an in-scope attack surface.
17
+ - Real XSS with meaningful proven impact (for example session/token theft, account compromise, privileged action execution, etc)
18
+ - Account takeover or strong authentication bypass, especially if it is 0-click
19
+ - Missing authorization checks / authorization bypass / tenant-boundary break (trivial IDOR, easy to swap out org or use ids with no authz, etc)
20
+ - Severe sensitive data leak (LFI, path traversal, bad scoping of file downloads, access to data without authorization, trivial side-channels) with realistic attacker access (proof the attacker can read secrets, PII, signing keys, credential stores, private keys, classified or highly confidential information (model weights etc))
21
+ - Trivial memory corruption exploits with known exploit patterns which require little effort to exploit
22
+ - SQL or other Database or query injection with clear proof of path from attacker input from in-scope attack surface and impact of the injection (leaks sensitive data, inserts dangerous records)
23
+ - Sandbox, container, VM, browser, or interpreter escape that breaks an intended isolation boundary
24
+ - Server-side template injection when it leads to RCE or leaking of secrets, with actual proof that the templating library can be exploited to do this (RCE escape or secrets/credentials in scope) and that this can be reached from an in-scope attack surface
25
+ - Arbitrary file write in executable, startup, config, or firmware paths with a realistic path to persistence or code execution. Requires proof that an attacker can actually trigger this from in-scope attack surface.
26
+ - Logic flaws that allow irreversible or broad compromise of integrity at scale, such as unauthenticated deletion of other users' data, cross-tenant tampering with sensitive records, or unauthorized modification of security-critical configuration, when the impact is clearly demonstrated and severe enough to be compromise-equivalent; when there is actual proof that this logic can be exercised from in-scope attack-surface.
27
+ - etc, other bugs not listed which follow this level of critical severity and impact; with actual proof that these bugs are reachable from in-scope attack-surface.
28
+
29
+ Non-exhaustive examples of vulnerabilities that often support `high` when evidenced in code and context:
30
+ - Server Side Request Forgery where there is actual proof that (1) an attacker can control the url being requested (bypassing protections around that) from in-scope attack-surface and (2) there are likely other local/lan/cloud services which can be reached to show actual impact. Be careful with reporting webhooks unless there is clear proof that it is dangerous, but do not treat a product-intended webhook/download/callback feature or optional operator allow/deny list as suppression evidence when attacker-controlled destinations can still reach internal, metadata, file-backed, redirect, or side-effecting targets.
31
+ - Exploitable memory corruption with clear, major impact or ease of exploitation
32
+ - Arbitrary file read that exposes less-sensitive user data or source code (if you have actual proof it reveals env secrets, then it is critical)
33
+ - Arbitrary file write in executable, startup, config, or firmware paths with a realistic path to persistence or code execution
34
+ - CSRF when it enables important state-changing actions such as credential changes, permission changes, payment / billing changes, or security-setting changes with realistic victim interaction. Evaluate actual browser request behavior, credential attachment, cookie policy, preflight requirements, server parsing, and effective anti-CSRF controls; an HTTP method or JSON content type alone is not a categorical defense.
35
+ - Hardcoded or default credentials that are valid, reachable, and provide meaningful access warranting `high`, even when that access is not broad or privileged enough for `critical`.
36
+ - Cryptographic failures that allow signature forgery, token forgery, trusted artifact forgery, secure-channel bypass, or decryption of highly sensitive data in a way that directly enables compromise, with actual proof that these attacks are practical and can be carried out from an in-scope attack surface.
37
+ - Supply-chain or update-channel compromise that allows malicious code or malicious trusted artifacts to be delivered to users, servers, agents, or endpoints, including signing bypass or package source substitution with real impact. This should focus on actual supply-chain risk and risk around CI actions, not just "does npm report outdated packages"
38
+ - Authorization bypass, IDOR, or privilege escalation that exposes or modifies meaningful sensitive data or privileged functionality, but is narrower in scope, limited to a smaller set of objects, limited to same-tenant boundaries, or otherwise less catastrophic than the critical cases above.
39
+ - XXE with clear proof that an attacker can control the XML document through in-scope attack-surface and that the XML engine is vulnerable to XXE
40
+ - etc, other bugs not listed which follow this level of high severity and impact; with actual proof that these bugs are reachable from in-scope attack-surface.
41
+ - Dangerous upload / file handling issues that enable stored active content, trusted-origin script execution, or meaningful content-type confusion with real security impact; with actual proof that both the upload and access are reachable through in-scope attack-surface.
42
+ - Deserialization, SSTI, plugin abuse, macro / template abuse, or interpreter abuse where dangerous primitives are clearly reachable and impactful, but code execution or compromise is not fully proven to the standard needed for critical.
43
+
44
+ Strong factors that often push a plausible `high` up to `critical`:
45
+ - Unauthenticated or near-unauthenticated reachability from the internet or other broad in-scope surfaces.
46
+ - 0-click or extremely low-friction exploitation.
47
+ - Cross-tenant / cross-boundary impact rather than same-user or same-tenant impact.
48
+ - Direct compromise of signing, identity, control-plane, or cloud credentials.
49
+ - Realistic persistence, mass exploitation, wormability, or compromise of many victims at once.
50
+ - Clear proof of code execution, full account takeover, or crown-jewel secret access rather than only a plausible path.
51
+
52
+ Examples that usually should not remain `high`/`critical` without very strong proof of it leading to the class of vulnerabilities above:
53
+ - Generic correctness/reliability bugs
54
+ - Strange edge cases with unclear attacker value
55
+ - Low-impact information leaks
56
+ - Internal-only defects without attacker reachability
57
+ - The report shows a bug class in isolation, but not a realistic exploit path.
58
+ - The issue requires the attacker to already have privileged, admin, root, console, shell, or code-execution access.
59
+ - "Could maybe matter if chained with many assumptions" arguments
60
+ - Self-XSS without a victim or meaningful boundary crossing, or XSS whose actual origin, browser reachability, and impact do not justify `high`/`critical`. An `alert` proof demonstrates JavaScript execution and is not evidence against reflected XSS.
61
+ - SQLi or other injection claims with no demonstrated attacker control, no shown sink reachability, or only speculative impact.
62
+ - CSRF on low-impact actions, cosmetic actions, logout, preferences, or actions requiring unrealistic victim behavior.
63
+ - Open redirect, clickjacking, user enumeration, rate-limit weakness, banner leakage, version disclosure, directory listing, stack traces, internal hostnames, or basic error-message leakage, unless they are shown as part of a serious exploit chain.
64
+ - Memory corruption that is theoretical, non-triggerable from in-scope input, or not plausibly exploitable in the target environment.
65
+ - Missing headers, cookie flags, CSP weaknesses, TLS observations, or crypto hygiene issues without a concrete exploit path and meaningful demonstrated impact.
66
+ - Reports that effectively say "this could be dangerous if combined with something else" but do not show the something else.
67
+ - Denial of service that is transient, single-user, self-targeting, easy to mitigate, requires disproportionate attacker resources, or does not create severe and realistic business / safety impact.
68
+ - Authz findings that require already having the same privilege as the victim, or only expose trivial metadata.
69
+ - Bugs that already require admin/root/shell access unless the privilege-escalation delta itself is the issue being reported.
70
+ - Arbitrary file read limited to public files, low-sensitivity files, or source fragments with no realistic security consequence.
71
+
72
+ High/Critical acceptance checklist (all should be true, unless the threat model strongly justifies an exception):
73
+ - In-scope component
74
+ - Realistic attacker
75
+ - Reasonable in-scope attack surface
76
+ - Credible exploitation path (not simply speculation)
77
+ - Major security impact
78
+ - Would likely be accepted as `high`/`critical` (not informational/low) in serious audit or bug bounty triage by a major auditing firm who puts their reputation on the line.
79
+
80
+ ## Severity and Policy Checklist
81
+
82
+ Apply severity adjustment only after scope, reachability, and counterevidence are established. Do not reopen discovery here.
83
+
84
+ Start from the candidate's original severity hypothesis, then adjust it using the repository-evidenced facts from this phase.
85
+
86
+ Severity adjustment guidance:
87
+
88
+ - Keep `critical` only when the attack path, reachability, and impact are all clear enough that the finding would demand immediate attention.
89
+ - Keep `high` only when there is a realistic in-scope attacker path and major security impact without a long speculative chain.
90
+ - Downgrade when the path is real but constrained to narrower objects, same-tenant impact, internal-only surfaces, or other materially limiting conditions.
91
+ - Reduce severity when the path is localhost-only, self-only, highly constrained, dependent on unrealistic preconditions, or already requires privileged access unless the privilege-escalation delta is the issue.
92
+ - Dangerous sink, scary bug class, or sensitive code area alone is not enough to preserve high severity.
93
+ - If the issue is a real bug but not meaningfully reportable as a security problem in context, set the final policy decision to `ignore`.
94
+ - Do not discard an otherwise reportable finding solely because its impact or likelihood is `low`; downgrade its severity instead.
95
+
96
+ Final policy-adjustment guidance:
97
+
98
+ - Apply hard suppression first:
99
+ - self-only impact -> `ignore`
100
+ - unachievable or highly unrealistic preconditions -> `ignore`
101
+ - privileged-only, operator-only, developer-only, physical-access-only, or protected-write-path preconditions -> `ignore`, unless the privilege-escalation delta itself is the issue
102
+ - Then weight likelihood using the established network scope:
103
+ - `remote` usually supports high likelihood when the attacker position is realistic and in scope
104
+ - `local_network` usually supports medium likelihood unless the evidence is stronger or weaker
105
+ - `localhost` usually supports low likelihood unless a lower-privileged attacker can realistically reach that listener
106
+ - `none` does not increase likelihood based on exposure
107
+ - Then decide reportability using the existing facts:
108
+ - if repository evidence does not establish a realistic lower-privileged in-scope attacker path, set `ignore`
109
+ - if the path is internal-only, developer-only, operator-only, localhost-only, privileged-local, or otherwise not meaningfully reportable in context, set `ignore`
110
+
111
+ Do not suppress solely because the surface is private or internal when repository evidence still shows a meaningful authorization, trust-boundary, identity, or security-control regression in a real product or production-service workflow. In those cases, internal exposure should usually reduce likelihood or confidence rather than force `ignore`.
112
+
113
+ Use missing deployment or ingress evidence to lower confidence or keep fields unknown when appropriate; do not automatically defeat an otherwise well-evidenced finding on that basis alone.
114
+
115
+ Severity calibration and final policy-adjustment matrix:
116
+
117
+ - `impact=high`:
118
+ - `likelihood=high` -> `critical` only when the critical criteria above are satisfied; otherwise `high`
119
+ - `likelihood=medium` -> `medium`
120
+ - `likelihood=low` -> `low`
121
+ - `likelihood=ignore` -> `ignore`
122
+ - `likelihood=unknown` -> `medium`
123
+ - `impact=medium`:
124
+ - `likelihood=high` -> `medium`
125
+ - `likelihood=medium` -> `low`
126
+ - `likelihood=low` -> `low`
127
+ - `likelihood=ignore` -> `ignore`
128
+ - `likelihood=unknown` -> `low`
129
+ - `impact=low`:
130
+ - `likelihood=high` -> `low`
131
+ - `likelihood=medium` -> `low`
132
+ - `likelihood=low` -> `low`
133
+ - `likelihood=ignore` -> `ignore`
134
+ - `likelihood=unknown` -> `low`
135
+ - `impact=ignore`:
136
+ - all likelihoods -> `ignore`
137
+ - `impact=unknown`:
138
+ - `likelihood=high` -> `medium`
139
+ - `likelihood=medium` -> `low`
140
+ - `likelihood=low` -> `low`
141
+ - `likelihood=ignore` -> `ignore`
142
+ - `likelihood=unknown` -> `low`
143
+
144
+ Priority mapping after final severity:
145
+
146
+ - `critical` -> `P0`
147
+ - `high` -> `P1`
148
+ - `medium` -> `P2`
149
+ - `low` -> `P3`
150
+
151
+ Use this mapping after the final policy-adjustment pass determines the final reportable severity. Do not assign a priority to findings whose final policy decision is `ignore`.
152
+
153
+ Once the facts are set, use the severity calibration and final policy-adjustment matrix mechanically. Do not re-argue severity from scratch afterward.