@openai/codex-security 0.1.31 → 0.2.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.
- package/README.md +295 -32
- package/_bundled_plugin/.mcp.json +1 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/native/THIRD_PARTY_NOTICES.txt +4 -4
- package/_bundled_plugin/mcp/native/darwin-arm64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-musl/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-x64-musl/unix.node +0 -0
- package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
- package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
- package/_bundled_plugin/references/artifact-storage.md +4 -4
- package/_bundled_plugin/references/config-preflight.md +1 -1
- package/_bundled_plugin/references/core-scan.md +14 -2
- package/_bundled_plugin/references/final-report.md +4 -2
- package/_bundled_plugin/references/scan-artifacts.md +2 -2
- package/_bundled_plugin/references/scan-contract.md +2 -2
- package/_bundled_plugin/references/threat-model.md +2 -2
- package/_bundled_plugin/schemas/coverage.schema.json +22 -0
- package/_bundled_plugin/schemas/scan-manifest.schema.json +100 -85
- package/_bundled_plugin/schemas/tools/scan-draft.schema.json +116 -102
- package/_bundled_plugin/scripts/config_preflight.py +4 -8
- package/_bundled_plugin/scripts/deep_scan_workbench.py +83 -217
- package/_bundled_plugin/scripts/filesystem_identity.py +1 -5
- package/_bundled_plugin/scripts/finalize_scan_contract.py +441 -166
- package/_bundled_plugin/scripts/finding_preview.py +42 -82
- package/_bundled_plugin/scripts/generate_in_scope_files.py +30 -34
- package/_bundled_plugin/scripts/generate_rank_input.py +58 -99
- package/_bundled_plugin/scripts/launch_codex_security_mcp +5 -1
- package/_bundled_plugin/scripts/rank_preview.py +85 -68
- package/_bundled_plugin/scripts/report_projection.py +37 -58
- package/_bundled_plugin/scripts/threat_model_projection.py +164 -0
- package/_bundled_plugin/scripts/windows_scan_local_files.py +11 -6
- package/_bundled_plugin/scripts/workbench/storage.py +11 -0
- package/_bundled_plugin/scripts/workbench_cli.py +11 -17
- package/_bundled_plugin/scripts/workbench_constants.py +6 -14
- package/_bundled_plugin/scripts/workbench_db.py +116 -228
- package/_bundled_plugin/scripts/workbench_finding_index.py +1 -6
- package/_bundled_plugin/scripts/workbench_native_indexes.py +1 -4
- package/_bundled_plugin/scripts/workbench_progress.py +12 -34
- package/_bundled_plugin/scripts/workbench_publication.py +47 -62
- package/_bundled_plugin/scripts/workbench_remediation.py +2 -20
- package/_bundled_plugin/scripts/workbench_saved_results.py +1246 -230
- package/_bundled_plugin/scripts/workbench_scan_start.py +4 -11
- package/_bundled_plugin/scripts/workbench_scan_usage.py +7 -15
- package/_bundled_plugin/scripts/workbench_schema.py +86 -271
- package/_bundled_plugin/scripts/workbench_severity.py +3 -0
- package/_bundled_plugin/scripts/workbench_source_excerpt.py +5 -6
- package/_bundled_plugin/scripts/workbench_target.py +98 -10
- package/_bundled_plugin/scripts/workbench_target_state.py +1 -5
- package/_bundled_plugin/scripts/workbench_validation.py +6 -20
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +3 -3
- package/_bundled_plugin/skills/security-diff-scan/SKILL.md +3 -3
- package/_bundled_plugin/skills/security-scan/SKILL.md +2 -2
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +2 -2
- package/_bundled_plugin/skills/threat-model/SKILL.md +2 -2
- package/dist/api.d.ts +3 -5
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +201 -207
- package/dist/api.js.map +1 -1
- package/dist/artifact-export.d.ts +70 -0
- package/dist/artifact-export.d.ts.map +1 -0
- package/dist/artifact-export.js +277 -0
- package/dist/artifact-export.js.map +1 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +8 -3
- package/dist/auth.js.map +1 -1
- package/dist/bulk-scan-discovery.d.ts +1 -0
- package/dist/bulk-scan-discovery.d.ts.map +1 -1
- package/dist/bulk-scan-discovery.js +8 -9
- package/dist/bulk-scan-discovery.js.map +1 -1
- package/dist/classify-scan-severity.d.ts.map +1 -1
- package/dist/classify-scan-severity.js +2 -5
- package/dist/classify-scan-severity.js.map +1 -1
- package/dist/classify-severity.d.ts +2 -8
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js +3 -5
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli-help.d.ts +3 -0
- package/dist/cli-help.d.ts.map +1 -0
- package/dist/cli-help.js +281 -0
- package/dist/cli-help.js.map +1 -0
- package/dist/cli.d.ts +19 -22
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +631 -714
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.d.ts.map +1 -1
- package/dist/cloud-publish.js +1 -8
- package/dist/cloud-publish.js.map +1 -1
- package/dist/codex-prompt.d.ts.map +1 -1
- package/dist/codex-prompt.js +1 -2
- package/dist/codex-prompt.js.map +1 -1
- package/dist/codex-sdk-environment.d.ts +2 -0
- package/dist/codex-sdk-environment.d.ts.map +1 -0
- package/dist/codex-sdk-environment.js +30 -0
- package/dist/codex-sdk-environment.js.map +1 -0
- package/dist/component-plan.d.ts.map +1 -1
- package/dist/component-plan.js +2 -6
- package/dist/component-plan.js.map +1 -1
- package/dist/component-scan.d.ts +1 -0
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +31 -9
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +32 -33
- package/dist/config.js.map +1 -1
- package/dist/contract.d.ts +2 -1
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +63 -122
- package/dist/contract.js.map +1 -1
- package/dist/cost-model.d.ts.map +1 -1
- package/dist/cost-model.js +65 -34
- package/dist/cost-model.js.map +1 -1
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +15 -31
- package/dist/cost.js.map +1 -1
- package/dist/custom-validation-prompt.js +4 -4
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/custom-validation.d.ts.map +1 -1
- package/dist/custom-validation.js +17 -16
- package/dist/custom-validation.js.map +1 -1
- package/dist/deduplication/checkpointed-review.d.ts.map +1 -1
- package/dist/deduplication/checkpointed-review.js +10 -11
- package/dist/deduplication/checkpointed-review.js.map +1 -1
- package/dist/deduplication/codex-review.d.ts +2 -0
- package/dist/deduplication/codex-review.d.ts.map +1 -1
- package/dist/deduplication/codex-review.js +3 -3
- package/dist/deduplication/codex-review.js.map +1 -1
- package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
- package/dist/deduplication/deduplication-reviewer.js +2 -0
- package/dist/deduplication/deduplication-reviewer.js.map +1 -1
- package/dist/deduplication/deduplication.js +40 -62
- package/dist/deduplication/deduplication.js.map +1 -1
- package/dist/deduplication/records-protocol.d.ts.map +1 -1
- package/dist/deduplication/records-protocol.js +1 -4
- package/dist/deduplication/records-protocol.js.map +1 -1
- package/dist/deduplication/records.d.ts +2 -1
- package/dist/deduplication/records.d.ts.map +1 -1
- package/dist/deduplication/records.js +24 -6
- package/dist/deduplication/records.js.map +1 -1
- package/dist/deduplication/review.d.ts +7 -0
- package/dist/deduplication/review.d.ts.map +1 -1
- package/dist/deduplication/review.js.map +1 -1
- package/dist/deduplication/scan.js +3 -7
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/deep-config.d.ts.map +1 -1
- package/dist/deep-config.js +3 -19
- package/dist/deep-config.js.map +1 -1
- package/dist/deep-progress.d.ts +0 -1
- package/dist/deep-progress.d.ts.map +1 -1
- package/dist/deep-progress.js +22 -40
- package/dist/deep-progress.js.map +1 -1
- package/dist/errors.d.ts +3 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +5 -7
- package/dist/errors.js.map +1 -1
- package/dist/finding-catalogue.d.ts.map +1 -1
- package/dist/finding-catalogue.js +22 -22
- package/dist/finding-catalogue.js.map +1 -1
- package/dist/finding-workflow.d.ts.map +1 -1
- package/dist/finding-workflow.js +4 -7
- package/dist/finding-workflow.js.map +1 -1
- package/dist/findings-import.d.ts.map +1 -1
- package/dist/findings-import.js +7 -17
- package/dist/findings-import.js.map +1 -1
- package/dist/github.d.ts.map +1 -1
- package/dist/github.js +2 -3
- package/dist/github.js.map +1 -1
- package/dist/import-scan.js +2 -2
- package/dist/import-scan.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/knowledge-base.js +2 -2
- package/dist/knowledge-base.js.map +1 -1
- package/dist/linear.d.ts.map +1 -1
- package/dist/linear.js +2 -3
- package/dist/linear.js.map +1 -1
- package/dist/models.d.ts +24 -0
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js.map +1 -1
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +36 -31
- package/dist/multiscan.js.map +1 -1
- package/dist/owner-evidence.d.ts.map +1 -1
- package/dist/owner-evidence.js +2 -6
- package/dist/owner-evidence.js.map +1 -1
- package/dist/patch-tui.d.ts.map +1 -1
- package/dist/patch-tui.js +2 -4
- package/dist/patch-tui.js.map +1 -1
- package/dist/project-config-schema.d.ts +10 -0
- package/dist/project-config-schema.d.ts.map +1 -1
- package/dist/project-config-schema.js +1 -0
- package/dist/project-config-schema.js.map +1 -1
- package/dist/project-config.d.ts +1 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +2 -0
- package/dist/project-config.js.map +1 -1
- package/dist/prompt-files.d.ts +0 -1
- package/dist/prompt-files.d.ts.map +1 -1
- package/dist/prompt-files.js +2 -4
- package/dist/prompt-files.js.map +1 -1
- package/dist/publication-events.d.ts.map +1 -1
- package/dist/publication-events.js +15 -29
- package/dist/publication-events.js.map +1 -1
- package/dist/publication-store.d.ts.map +1 -1
- package/dist/publication-store.js +9 -13
- package/dist/publication-store.js.map +1 -1
- package/dist/publication.d.ts.map +1 -1
- package/dist/publication.js +11 -14
- package/dist/publication.js.map +1 -1
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +31 -41
- package/dist/publish.js.map +1 -1
- package/dist/record.d.ts +2 -0
- package/dist/record.d.ts.map +1 -0
- package/dist/record.js +4 -0
- package/dist/record.js.map +1 -0
- package/dist/result.d.ts +4 -1
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +7 -0
- package/dist/result.js.map +1 -1
- package/dist/runtime.d.ts +10 -13
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +203 -131
- package/dist/runtime.js.map +1 -1
- package/dist/saved-scan.d.ts.map +1 -1
- package/dist/saved-scan.js +10 -20
- package/dist/saved-scan.js.map +1 -1
- package/dist/scan-activity.d.ts.map +1 -1
- package/dist/scan-activity.js +8 -22
- package/dist/scan-activity.js.map +1 -1
- package/dist/scan-comparison.d.ts +3 -3
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +38 -73
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts +0 -1
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +10 -19
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +1 -2
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-logs.d.ts.map +1 -1
- package/dist/scan-logs.js +2 -6
- package/dist/scan-logs.js.map +1 -1
- package/dist/scan-sessions.d.ts.map +1 -1
- package/dist/scan-sessions.js +1 -3
- package/dist/scan-sessions.js.map +1 -1
- package/dist/scan-settings.d.ts +5 -0
- package/dist/scan-settings.d.ts.map +1 -1
- package/dist/scan-settings.js +4 -0
- package/dist/scan-settings.js.map +1 -1
- package/dist/security-policy-cli.d.ts.map +1 -1
- package/dist/security-policy-cli.js +8 -6
- package/dist/security-policy-cli.js.map +1 -1
- package/dist/security-policy.d.ts +8 -4
- package/dist/security-policy.d.ts.map +1 -1
- package/dist/security-policy.js +98 -84
- package/dist/security-policy.js.map +1 -1
- package/dist/server/dashboard/app.js +5 -5
- package/dist/server/embeddings.d.ts.map +1 -1
- package/dist/server/embeddings.js +1 -0
- package/dist/server/embeddings.js.map +1 -1
- package/dist/server/routes.d.ts +3 -2
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +19 -7
- package/dist/server/routes.js.map +1 -1
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +2 -3
- package/dist/server/server.js.map +1 -1
- package/dist/server/sqlite-store.d.ts.map +1 -1
- package/dist/server/sqlite-store.js +4 -14
- package/dist/server/sqlite-store.js.map +1 -1
- package/dist/severity-store.js +8 -15
- package/dist/severity-store.js.map +1 -1
- package/dist/suggest-owners.d.ts +2 -3
- package/dist/suggest-owners.d.ts.map +1 -1
- package/dist/suggest-owners.js +4 -5
- package/dist/suggest-owners.js.map +1 -1
- package/dist/targets.d.ts +1 -0
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +24 -21
- package/dist/targets.js.map +1 -1
- package/dist/trusted-executable.d.ts +5 -0
- package/dist/trusted-executable.d.ts.map +1 -1
- package/dist/trusted-executable.js +22 -5
- package/dist/trusted-executable.js.map +1 -1
- package/dist/value.d.ts +2 -0
- package/dist/value.d.ts.map +1 -0
- package/dist/value.js +20 -0
- package/dist/value.js.map +1 -0
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +3 -6
- package/dist/version.js.map +1 -1
- package/dist/windows-path.d.ts.map +1 -1
- package/dist/windows-path.js +1 -2
- package/dist/windows-path.js.map +1 -1
- package/dist/worker-progress.d.ts +1 -0
- package/dist/worker-progress.d.ts.map +1 -1
- package/dist/worker-progress.js +13 -34
- package/dist/worker-progress.js.map +1 -1
- package/docs/dedupe-records.md +24 -0
- package/package.json +11 -10
- package/schemas/project-config.schema.json +5 -0
- package/_bundled_plugin/scripts/normalize_candidates.py +0 -338
- package/dist/server/findings-service.d.ts +0 -20
- package/dist/server/findings-service.d.ts.map +0 -1
- package/dist/server/findings-service.js +0 -31
- package/dist/server/findings-service.js.map +0 -1
|
@@ -27,14 +27,18 @@ TEXT_CODE_EXTENSIONS = {
|
|
|
27
27
|
".cue",
|
|
28
28
|
".cxx",
|
|
29
29
|
".dart",
|
|
30
|
+
".ejs",
|
|
31
|
+
".erb",
|
|
30
32
|
".ex",
|
|
31
33
|
".exs",
|
|
32
34
|
".go",
|
|
33
35
|
".graphql",
|
|
34
36
|
".h",
|
|
37
|
+
".hh",
|
|
35
38
|
".hpp",
|
|
36
39
|
".hs",
|
|
37
40
|
".html",
|
|
41
|
+
".hxx",
|
|
38
42
|
".java",
|
|
39
43
|
".js",
|
|
40
44
|
".json",
|
|
@@ -47,6 +51,7 @@ TEXT_CODE_EXTENSIONS = {
|
|
|
47
51
|
".mm",
|
|
48
52
|
".mts",
|
|
49
53
|
".php",
|
|
54
|
+
".phtml",
|
|
50
55
|
".proto",
|
|
51
56
|
".ps1",
|
|
52
57
|
".psd1",
|
|
@@ -56,20 +61,35 @@ TEXT_CODE_EXTENSIONS = {
|
|
|
56
61
|
".rs",
|
|
57
62
|
".scala",
|
|
58
63
|
".sh",
|
|
64
|
+
".sol",
|
|
59
65
|
".sql",
|
|
66
|
+
".svelte",
|
|
60
67
|
".swift",
|
|
61
68
|
".tf",
|
|
62
69
|
".toml",
|
|
63
70
|
".ts",
|
|
64
71
|
".tsx",
|
|
65
72
|
".vue",
|
|
73
|
+
".vy",
|
|
66
74
|
".xml",
|
|
67
75
|
".yaml",
|
|
68
76
|
".yml",
|
|
69
77
|
}
|
|
70
78
|
|
|
71
79
|
JAVASCRIPT_EXTENSIONS = {".cjs", ".cts", ".js", ".jsx", ".mjs", ".mts", ".ts", ".tsx", ".vue"}
|
|
72
|
-
JAVA_LIKE_EXTENSIONS = {
|
|
80
|
+
JAVA_LIKE_EXTENSIONS = {
|
|
81
|
+
".c",
|
|
82
|
+
".cc",
|
|
83
|
+
".cpp",
|
|
84
|
+
".cs",
|
|
85
|
+
".cxx",
|
|
86
|
+
".h",
|
|
87
|
+
".hh",
|
|
88
|
+
".hpp",
|
|
89
|
+
".hxx",
|
|
90
|
+
".java",
|
|
91
|
+
".mm",
|
|
92
|
+
}
|
|
73
93
|
BRACE_LANGUAGE_EXTENSIONS = {
|
|
74
94
|
*JAVASCRIPT_EXTENSIONS,
|
|
75
95
|
*JAVA_LIKE_EXTENSIONS,
|
|
@@ -83,6 +103,7 @@ BRACE_LANGUAGE_EXTENSIONS = {
|
|
|
83
103
|
".swift",
|
|
84
104
|
}
|
|
85
105
|
NESTED_BLOCK_COMMENT_EXTENSIONS = {".kt", ".kts", ".rs", ".scala", ".swift"}
|
|
106
|
+
CPP_RAW_STRING_RE = re.compile(r'(?<![\w\x80-\U0010ffff])(?:u8|u|U|L)?R"([^\s()\\]{0,16})\(')
|
|
86
107
|
RUST_RAW_STRING_RE = re.compile(r'(?:br|r)(#{0,16})"')
|
|
87
108
|
RUST_LIFETIME_RE = re.compile(r"'[A-Za-z_][A-Za-z0-9_]*")
|
|
88
109
|
PHP_HEREDOC_RE = re.compile(r"<<<\s*['\"]?([A-Za-z_]\w*)['\"]?")
|
|
@@ -184,7 +205,7 @@ def python_arguments(node: ast.FunctionDef | ast.AsyncFunctionDef) -> str:
|
|
|
184
205
|
def python_outline(text: str) -> list[str]:
|
|
185
206
|
try:
|
|
186
207
|
tree = ast.parse(text)
|
|
187
|
-
except (SyntaxError, ValueError, TypeError, MemoryError):
|
|
208
|
+
except (SyntaxError, ValueError, TypeError, MemoryError, RecursionError):
|
|
188
209
|
return []
|
|
189
210
|
|
|
190
211
|
outline: list[str] = []
|
|
@@ -284,13 +305,13 @@ def mask_c_style_source(text: str, suffix: str) -> str:
|
|
|
284
305
|
continue
|
|
285
306
|
if heredoc_terminator:
|
|
286
307
|
if index == 0 or text[index - 1] == "\n":
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
if
|
|
292
|
-
masked.extend(" " * (
|
|
293
|
-
index =
|
|
308
|
+
# PHP identifiers allow every non-ASCII byte, including non-word characters.
|
|
309
|
+
terminator_match = re.compile(
|
|
310
|
+
rf"[ \t]*{heredoc_terminator}(?![A-Za-z0-9_\x80-\U0010ffff])"
|
|
311
|
+
).match(text, index)
|
|
312
|
+
if terminator_match:
|
|
313
|
+
masked.extend(" " * (terminator_match.end() - index))
|
|
314
|
+
index = terminator_match.end()
|
|
294
315
|
heredoc_terminator = ""
|
|
295
316
|
continue
|
|
296
317
|
masked.append(" ")
|
|
@@ -338,6 +359,14 @@ def mask_c_style_source(text: str, suffix: str) -> str:
|
|
|
338
359
|
quote = ""
|
|
339
360
|
index += 1
|
|
340
361
|
continue
|
|
362
|
+
if suffix in {".cc", ".cpp", ".cxx", ".h", ".hh", ".hpp", ".hxx", ".mm"}:
|
|
363
|
+
raw_match = CPP_RAW_STRING_RE.match(text, index)
|
|
364
|
+
if raw_match:
|
|
365
|
+
token = raw_match.group(0)
|
|
366
|
+
masked.extend(" " * len(token))
|
|
367
|
+
raw_terminator = f'){raw_match.group(1)}"'
|
|
368
|
+
index += len(token)
|
|
369
|
+
continue
|
|
341
370
|
if suffix == ".rs":
|
|
342
371
|
raw_match = RUST_RAW_STRING_RE.match(text, index)
|
|
343
372
|
if raw_match:
|
|
@@ -360,6 +389,11 @@ def mask_c_style_source(text: str, suffix: str) -> str:
|
|
|
360
389
|
quote = '@"'
|
|
361
390
|
index += 2
|
|
362
391
|
continue
|
|
392
|
+
if suffix == ".go" and char == "`":
|
|
393
|
+
masked.append(" ")
|
|
394
|
+
raw_terminator = "`"
|
|
395
|
+
index += 1
|
|
396
|
+
continue
|
|
363
397
|
triple_quote = text[index : index + 3]
|
|
364
398
|
if triple_quote in {'"""', "'''"}:
|
|
365
399
|
masked.extend((" ", " ", " "))
|
|
@@ -457,7 +491,7 @@ def match_type_declaration(line: str, suffix: str) -> tuple[str, str] | None:
|
|
|
457
491
|
match = re.search(r"\b(class|struct|enum|protocol|actor|extension)\s+([A-Za-z_]\w*)", line)
|
|
458
492
|
elif suffix == ".dart":
|
|
459
493
|
match = re.search(r"\b(class|mixin|enum|extension)\s+([A-Za-z_]\w*)", line)
|
|
460
|
-
elif suffix in {".c", ".cc", ".cpp", ".cxx", ".h", ".hpp", ".mm"}:
|
|
494
|
+
elif suffix in {".c", ".cc", ".cpp", ".cxx", ".h", ".hh", ".hpp", ".hxx", ".mm"}:
|
|
461
495
|
match = re.search(
|
|
462
496
|
r"\b(class|struct|union|enum(?:\s+class)?)\s+([A-Za-z_]\w*)",
|
|
463
497
|
line,
|
|
@@ -509,12 +543,20 @@ def match_java_like_function(
|
|
|
509
543
|
prefix = before[: name_match.start()].strip()
|
|
510
544
|
if not prefix and name != (type_name or ""):
|
|
511
545
|
return None
|
|
512
|
-
if suffix in {
|
|
513
|
-
|
|
514
|
-
|
|
546
|
+
if suffix in {
|
|
547
|
+
".c",
|
|
548
|
+
".cc",
|
|
549
|
+
".cpp",
|
|
550
|
+
".cxx",
|
|
551
|
+
".h",
|
|
552
|
+
".hh",
|
|
553
|
+
".hpp",
|
|
554
|
+
".hxx",
|
|
555
|
+
".mm",
|
|
556
|
+
} and prefix.startswith(("typedef", "using")):
|
|
515
557
|
return None
|
|
516
558
|
if (
|
|
517
|
-
suffix in {".c", ".cc", ".cpp", ".cxx", ".h", ".hpp", ".mm"}
|
|
559
|
+
suffix in {".c", ".cc", ".cpp", ".cxx", ".h", ".hh", ".hpp", ".hxx", ".mm"}
|
|
518
560
|
and type_name is None
|
|
519
561
|
and line.endswith(";")
|
|
520
562
|
and not re.search(
|
|
@@ -652,8 +694,7 @@ def strip_leading_annotations(original: str, masked: str) -> tuple[str, str, lis
|
|
|
652
694
|
def brace_language_outline(text: str, suffix: str) -> list[str]:
|
|
653
695
|
original_lines = text.splitlines()
|
|
654
696
|
masked_lines = mask_c_style_source(text, suffix).splitlines()
|
|
655
|
-
outline:
|
|
656
|
-
seen: set[str] = set()
|
|
697
|
+
outline: dict[str, None] = {}
|
|
657
698
|
type_stack: list[tuple[str, int]] = []
|
|
658
699
|
function_depths: list[int] = []
|
|
659
700
|
blocked_depths: list[int] = []
|
|
@@ -664,9 +705,7 @@ def brace_language_outline(text: str, suffix: str) -> list[str]:
|
|
|
664
705
|
|
|
665
706
|
def add(value: str) -> None:
|
|
666
707
|
decorated = f"{' '.join(pending_annotations[-2:])} {value}".strip()
|
|
667
|
-
|
|
668
|
-
seen.add(decorated)
|
|
669
|
-
outline.append(decorated)
|
|
708
|
+
outline[decorated] = None
|
|
670
709
|
|
|
671
710
|
def next_lines_open_body(line_index: int) -> bool:
|
|
672
711
|
inspected = 0
|
|
@@ -778,20 +817,14 @@ def brace_language_outline(text: str, suffix: str) -> list[str]:
|
|
|
778
817
|
type_stack.pop()
|
|
779
818
|
while blocked_depths and depth < blocked_depths[-1]:
|
|
780
819
|
blocked_depths.pop()
|
|
781
|
-
return outline
|
|
820
|
+
return list(outline)
|
|
782
821
|
|
|
783
822
|
|
|
784
823
|
def ruby_outline(text: str) -> list[str]:
|
|
785
|
-
outline:
|
|
786
|
-
seen: set[str] = set()
|
|
824
|
+
outline: dict[str, None] = {}
|
|
787
825
|
type_stack: list[tuple[int, str]] = []
|
|
788
826
|
function_indents: list[int] = []
|
|
789
827
|
|
|
790
|
-
def add(value: str) -> None:
|
|
791
|
-
if value not in seen:
|
|
792
|
-
seen.add(value)
|
|
793
|
-
outline.append(value)
|
|
794
|
-
|
|
795
828
|
for raw_line in text.splitlines():
|
|
796
829
|
stripped = raw_line.strip()
|
|
797
830
|
if not stripped or stripped.startswith("#"):
|
|
@@ -805,7 +838,7 @@ def ruby_outline(text: str) -> list[str]:
|
|
|
805
838
|
type_match = re.match(r"^(class|module)\s+([A-Z]\w*(?:::[A-Z]\w*)*)", stripped)
|
|
806
839
|
if type_match and not function_indents:
|
|
807
840
|
kind, name = type_match.groups()
|
|
808
|
-
|
|
841
|
+
outline[f"{kind} {name}"] = None
|
|
809
842
|
type_stack.append((indent, name))
|
|
810
843
|
continue
|
|
811
844
|
|
|
@@ -813,21 +846,15 @@ def ruby_outline(text: str) -> list[str]:
|
|
|
813
846
|
if function_match and not function_indents:
|
|
814
847
|
name = function_match.group(1)
|
|
815
848
|
if type_stack:
|
|
816
|
-
|
|
849
|
+
outline[f"method {type_stack[-1][1]}.{name}"] = None
|
|
817
850
|
else:
|
|
818
|
-
|
|
851
|
+
outline[f"function {name}"] = None
|
|
819
852
|
function_indents.append(indent)
|
|
820
|
-
return outline
|
|
853
|
+
return list(outline)
|
|
821
854
|
|
|
822
855
|
|
|
823
856
|
def simple_language_outline(text: str, suffix: str) -> list[str]:
|
|
824
|
-
outline:
|
|
825
|
-
seen: set[str] = set()
|
|
826
|
-
|
|
827
|
-
def add(value: str) -> None:
|
|
828
|
-
if value not in seen:
|
|
829
|
-
seen.add(value)
|
|
830
|
-
outline.append(value)
|
|
857
|
+
outline: dict[str, None] = {}
|
|
831
858
|
|
|
832
859
|
for raw_line in text.splitlines():
|
|
833
860
|
line = compact_preview_line(raw_line)
|
|
@@ -837,69 +864,63 @@ def simple_language_outline(text: str, suffix: str) -> list[str]:
|
|
|
837
864
|
if suffix == ".py":
|
|
838
865
|
match = re.match(r"^(async\s+)?def\s+([A-Za-z_]\w*)\s*\(", line)
|
|
839
866
|
if match:
|
|
840
|
-
|
|
867
|
+
outline[
|
|
868
|
+
f"{'async function' if match.group(1) else 'function'} {match.group(2)}"
|
|
869
|
+
] = None
|
|
841
870
|
continue
|
|
842
871
|
match = re.match(r"^class\s+([A-Za-z_]\w*)", line)
|
|
843
872
|
if match:
|
|
844
|
-
|
|
845
|
-
elif suffix == ".rb":
|
|
846
|
-
match = re.match(r"^(class|module)\s+([A-Z]\w*(?:::[A-Z]\w*)*)", line)
|
|
847
|
-
if match:
|
|
848
|
-
add(f"{match.group(1)} {match.group(2)}")
|
|
849
|
-
continue
|
|
850
|
-
match = re.match(r"^def\s+(?:self\.)?([^\s(]+)", line)
|
|
851
|
-
if match:
|
|
852
|
-
add(f"function {match.group(1)}")
|
|
873
|
+
outline[f"class {match.group(1)}"] = None
|
|
853
874
|
elif suffix in {".ex", ".exs"}:
|
|
854
875
|
match = re.match(r"^defmodule\s+([A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*)", line)
|
|
855
876
|
if match:
|
|
856
|
-
|
|
877
|
+
outline[f"module {match.group(1)}"] = None
|
|
857
878
|
continue
|
|
858
879
|
match = re.match(r"^(?:def|defp|defmacro)\s+([A-Za-z_]\w*[!?]?)", line)
|
|
859
880
|
if match:
|
|
860
|
-
|
|
881
|
+
outline[f"function {match.group(1)}"] = None
|
|
861
882
|
elif suffix == ".clj":
|
|
862
883
|
match = re.match(
|
|
863
884
|
r"^\((defn|defmacro|defprotocol|defrecord|deftype|defmulti|defmethod)\s+([^\s)]+)",
|
|
864
885
|
line,
|
|
865
886
|
)
|
|
866
887
|
if match:
|
|
867
|
-
|
|
888
|
+
outline[f"{match.group(1)} {match.group(2)}"] = None
|
|
868
889
|
elif suffix == ".lua":
|
|
869
890
|
match = re.match(r"^(?:local\s+)?function\s+([A-Za-z_]\w*(?:[.:][A-Za-z_]\w*)*)", line)
|
|
870
891
|
if match:
|
|
871
|
-
|
|
892
|
+
outline[f"function {match.group(1)}"] = None
|
|
872
893
|
elif suffix == ".sh":
|
|
873
894
|
match = re.match(r"^(?:function\s+)?([A-Za-z_]\w*)\s*\(\s*\)\s*\{?", line)
|
|
874
895
|
if match:
|
|
875
|
-
|
|
896
|
+
outline[f"function {match.group(1)}"] = None
|
|
876
897
|
elif suffix == ".hs":
|
|
877
898
|
match = re.match(r"^(data|newtype|type|class)\s+([A-Z]\w*)", line)
|
|
878
899
|
if match:
|
|
879
|
-
|
|
900
|
+
outline[f"{match.group(1)} {match.group(2)}"] = None
|
|
880
901
|
continue
|
|
881
902
|
match = re.match(r"^([a-z_]\w*)\s*::", line)
|
|
882
903
|
if match:
|
|
883
|
-
|
|
904
|
+
outline[f"function {match.group(1)}"] = None
|
|
884
905
|
elif suffix == ".proto":
|
|
885
906
|
match = re.match(r"^(message|service|enum)\s+([A-Za-z_]\w*)", line)
|
|
886
907
|
if match:
|
|
887
|
-
|
|
908
|
+
outline[f"{match.group(1)} {match.group(2)}"] = None
|
|
888
909
|
continue
|
|
889
910
|
match = re.match(r"^rpc\s+([A-Za-z_]\w*)\s*\(", line)
|
|
890
911
|
if match:
|
|
891
|
-
|
|
912
|
+
outline[f"rpc {match.group(1)}"] = None
|
|
892
913
|
elif suffix == ".graphql":
|
|
893
914
|
match = re.match(
|
|
894
915
|
r"^(type|interface|input|enum|union|scalar|directive)\s+([A-Za-z_]\w*)",
|
|
895
916
|
line,
|
|
896
917
|
)
|
|
897
918
|
if match:
|
|
898
|
-
|
|
919
|
+
outline[f"{match.group(1)} {match.group(2)}"] = None
|
|
899
920
|
continue
|
|
900
921
|
match = re.match(r"^(query|mutation|subscription)\s+([A-Za-z_]\w*)", line)
|
|
901
922
|
if match:
|
|
902
|
-
|
|
923
|
+
outline[f"{match.group(1)} {match.group(2)}"] = None
|
|
903
924
|
elif suffix == ".sql":
|
|
904
925
|
match = re.match(
|
|
905
926
|
r"^CREATE\s+(?:OR\s+REPLACE\s+)?(FUNCTION|PROCEDURE|TABLE|VIEW|TRIGGER)\s+"
|
|
@@ -908,16 +929,16 @@ def simple_language_outline(text: str, suffix: str) -> list[str]:
|
|
|
908
929
|
flags=re.IGNORECASE,
|
|
909
930
|
)
|
|
910
931
|
if match:
|
|
911
|
-
|
|
932
|
+
outline[f"{match.group(1).lower()} {match.group(2)}"] = None
|
|
912
933
|
elif suffix in {".yaml", ".yml"}:
|
|
913
934
|
match = re.match(r"^([A-Za-z0-9_.-]+):(?:\s|$)", raw_line)
|
|
914
935
|
if match:
|
|
915
|
-
|
|
936
|
+
outline[f"key {match.group(1)}"] = None
|
|
916
937
|
elif suffix in {".toml", ".cfg"}:
|
|
917
938
|
match = re.match(r"^\[([^]]+)]$", line)
|
|
918
939
|
if match:
|
|
919
|
-
|
|
920
|
-
return outline
|
|
940
|
+
outline[f"section {match.group(1)}"] = None
|
|
941
|
+
return list(outline)
|
|
921
942
|
|
|
922
943
|
|
|
923
944
|
def json_outline(text: str) -> list[str]:
|
|
@@ -977,12 +998,8 @@ def preview_for_bytes(path: Path, data: bytes, preview_bytes: int) -> tuple[str,
|
|
|
977
998
|
return fit_preview_lines(preview_lines, preview_bytes), False
|
|
978
999
|
|
|
979
1000
|
|
|
980
|
-
|
|
1001
|
+
if __name__ == "__main__":
|
|
981
1002
|
parser = argparse.ArgumentParser(
|
|
982
1003
|
description="Build structural or sampled previews for Codex Security rank inputs."
|
|
983
1004
|
)
|
|
984
1005
|
parser.parse_args()
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
if __name__ == "__main__":
|
|
988
|
-
main()
|
|
@@ -32,18 +32,10 @@ def _text(value: Any, fallback: str) -> str:
|
|
|
32
32
|
return ""
|
|
33
33
|
if re.match(r"^(?:#{1,6}\s|[-*+]\s|>\s|```|\d+\.\s|\|)", normalized):
|
|
34
34
|
normalized = f"Text: {normalized}"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
rendered.append(f"`{match.group(1)}`")
|
|
40
|
-
cursor = match.end()
|
|
41
|
-
rendered.append(_escape_markdown_text(normalized[cursor:]))
|
|
42
|
-
return "".join(rendered)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def _escape_markdown_text(value: str) -> str:
|
|
46
|
-
return re.sub(r"([\\`*\[\]<>])", r"\\\1", value)
|
|
35
|
+
return "".join(
|
|
36
|
+
part if index % 2 else re.sub(r"([\\`*\[\]<>])", r"\\\1", part)
|
|
37
|
+
for index, part in enumerate(re.split(r"((?<!`)`[^`\n]+`(?!`))", normalized))
|
|
38
|
+
)
|
|
47
39
|
|
|
48
40
|
|
|
49
41
|
def _strings(value: Any) -> list[str]:
|
|
@@ -63,10 +55,6 @@ def _cell(value: Any) -> str:
|
|
|
63
55
|
return _text(value, "none").replace("|", "\\|").replace("\n", "<br>")
|
|
64
56
|
|
|
65
57
|
|
|
66
|
-
def _link_label(value: Any, fallback: str) -> str:
|
|
67
|
-
return _cell(value) or _cell(fallback)
|
|
68
|
-
|
|
69
|
-
|
|
70
58
|
def _deep_report_id(finding: dict[str, Any]) -> str:
|
|
71
59
|
extensions = finding.get("extensions")
|
|
72
60
|
if isinstance(extensions, dict):
|
|
@@ -141,10 +129,6 @@ def _deep_title_parts(finding: dict[str, Any]) -> tuple[str, str | None]:
|
|
|
141
129
|
return normalized, None
|
|
142
130
|
|
|
143
131
|
|
|
144
|
-
def _deep_finding_title(finding: dict[str, Any]) -> str:
|
|
145
|
-
return _deep_title_parts(finding)[0]
|
|
146
|
-
|
|
147
|
-
|
|
148
132
|
def _deep_finding_groups(
|
|
149
133
|
findings: list[dict[str, Any]], writeup_paths: list[str | None]
|
|
150
134
|
) -> list[list[tuple[int, dict[str, Any], str | None]]]:
|
|
@@ -155,12 +139,9 @@ def _deep_finding_groups(
|
|
|
155
139
|
|
|
156
140
|
|
|
157
141
|
def _deep_group_titles(group: list[tuple[int, dict[str, Any], str | None]]) -> str:
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if title not in titles:
|
|
162
|
-
titles.append(title)
|
|
163
|
-
return "<br>".join(titles)
|
|
142
|
+
return "<br>".join(
|
|
143
|
+
dict.fromkeys(_cell(_deep_title_parts(finding)[0]) for _, finding, _ in group)
|
|
144
|
+
)
|
|
164
145
|
|
|
165
146
|
|
|
166
147
|
def _deep_group_levels(
|
|
@@ -197,7 +178,7 @@ def _deep_group_report_labels(
|
|
|
197
178
|
def _deep_group_report_links(group: list[tuple[int, dict[str, Any], str | None]]) -> str:
|
|
198
179
|
labels = _deep_group_report_labels(group)
|
|
199
180
|
return "<br>".join(
|
|
200
|
-
f"[{
|
|
181
|
+
f"[{_cell(label)}](#finding-{number})"
|
|
201
182
|
for label, (number, _, _) in zip(labels, group, strict=True)
|
|
202
183
|
)
|
|
203
184
|
|
|
@@ -206,7 +187,7 @@ def _deep_group_writeup_links(group: list[tuple[int, dict[str, Any], str | None]
|
|
|
206
187
|
labels = _deep_group_report_labels(group)
|
|
207
188
|
links: list[str] = []
|
|
208
189
|
for label, (_, _, report_path) in zip(labels, group, strict=True):
|
|
209
|
-
report_id =
|
|
190
|
+
report_id = _cell(label)
|
|
210
191
|
links.append(
|
|
211
192
|
f"[Open {report_id}]({report_path})" if report_path else f"{report_id}: inline below"
|
|
212
193
|
)
|
|
@@ -282,15 +263,11 @@ def _section_code_evidence(
|
|
|
282
263
|
and isinstance(item.get("code"), str)
|
|
283
264
|
and item["code"].strip()
|
|
284
265
|
)
|
|
285
|
-
unique:
|
|
286
|
-
seen: set[tuple[str, str]] = set()
|
|
266
|
+
unique: dict[tuple[str, str], dict[str, Any]] = {}
|
|
287
267
|
for item in resolved:
|
|
288
268
|
key = (str(item.get("id", "")), item["code"])
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
seen.add(key)
|
|
292
|
-
unique.append(item)
|
|
293
|
-
return unique
|
|
269
|
+
unique.setdefault(key, item)
|
|
270
|
+
return list(unique.values())
|
|
294
271
|
|
|
295
272
|
|
|
296
273
|
def merged_root_cause(value: dict[str, Any]) -> tuple[str | None, Any]:
|
|
@@ -867,26 +844,32 @@ def build_report_markdown(
|
|
|
867
844
|
"",
|
|
868
845
|
"## Threat Model",
|
|
869
846
|
"",
|
|
847
|
+
]
|
|
848
|
+
)
|
|
849
|
+
content = threat_model.get("content")
|
|
850
|
+
if threat_model.get("format") == "markdown" and isinstance(content, str) and content.strip():
|
|
851
|
+
lines.append(content)
|
|
852
|
+
else:
|
|
853
|
+
lines.append(
|
|
870
854
|
_text(
|
|
871
855
|
threat_model.get("summary"),
|
|
872
856
|
"No explicit canonical threat-model summary was recorded.",
|
|
857
|
+
)
|
|
858
|
+
)
|
|
859
|
+
for heading, key, fallback in (
|
|
860
|
+
("Assets", "assets", "No assets were recorded."),
|
|
861
|
+
("Trust Boundaries", "trustBoundaries", "No trust boundaries were recorded."),
|
|
862
|
+
(
|
|
863
|
+
"Attacker Capabilities",
|
|
864
|
+
"attackerCapabilities",
|
|
865
|
+
"No attacker capabilities were recorded.",
|
|
873
866
|
),
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
"Attacker Capabilities",
|
|
881
|
-
"attackerCapabilities",
|
|
882
|
-
"No attacker capabilities were recorded.",
|
|
883
|
-
),
|
|
884
|
-
("Security Objectives", "securityObjectives", "No security objectives were recorded."),
|
|
885
|
-
("Assumptions", "assumptions", "No assumptions were recorded."),
|
|
886
|
-
):
|
|
887
|
-
values = _strings(threat_model.get(key))
|
|
888
|
-
if values:
|
|
889
|
-
lines.extend(["", f"### {heading}", "", *_bullets(values, fallback)])
|
|
867
|
+
("Security Objectives", "securityObjectives", "No security objectives were recorded."),
|
|
868
|
+
("Assumptions", "assumptions", "No assumptions were recorded."),
|
|
869
|
+
):
|
|
870
|
+
values = _strings(threat_model.get(key))
|
|
871
|
+
if values:
|
|
872
|
+
lines.extend(["", f"### {heading}", "", *_bullets(values, fallback)])
|
|
890
873
|
lines.extend(["", "## Findings", ""])
|
|
891
874
|
if findings:
|
|
892
875
|
if deep_presentation:
|
|
@@ -913,7 +896,7 @@ def build_report_markdown(
|
|
|
913
896
|
for number, (finding, report_path) in enumerate(
|
|
914
897
|
zip(findings, writeup_paths, strict=True), 1
|
|
915
898
|
):
|
|
916
|
-
title =
|
|
899
|
+
title = _cell(finding["title"])
|
|
917
900
|
finding_link = f"[{title}](#finding-{number})"
|
|
918
901
|
writeup_link = f"[Open report]({report_path})" if report_path else "inline below"
|
|
919
902
|
lines.append(
|
|
@@ -1078,11 +1061,7 @@ def generate_report_markdown(
|
|
|
1078
1061
|
return build_report_markdown(manifest, findings, coverage).encode("utf-8")
|
|
1079
1062
|
|
|
1080
1063
|
|
|
1081
|
-
|
|
1064
|
+
if __name__ == "__main__":
|
|
1082
1065
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
1083
1066
|
parser.parse_args()
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
if __name__ == "__main__":
|
|
1088
|
-
raise SystemExit(main())
|
|
1067
|
+
raise SystemExit(0)
|