@openai/codex-security 0.1.30 → 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 +386 -37
- 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/deep-reducer.schema.json +19 -4
- 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 +86 -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 +9 -4
- 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 +21 -22
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +673 -701
- 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 +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/knowledge-base.js +7 -3
- 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 +29 -0
- package/dist/owner-evidence.d.ts.map +1 -0
- package/dist/owner-evidence.js +192 -0
- package/dist/owner-evidence.js.map +1 -0
- 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 +230 -145
- 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 +4 -4
- 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 +37 -0
- package/dist/suggest-owners.d.ts.map +1 -0
- package/dist/suggest-owners.js +111 -0
- package/dist/suggest-owners.js.map +1 -0
- package/dist/targets.d.ts +7 -2
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +29 -25
- package/dist/targets.js.map +1 -1
- package/dist/thread-source.d.ts +1 -0
- package/dist/thread-source.d.ts.map +1 -1
- package/dist/thread-source.js +1 -0
- package/dist/thread-source.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 +15 -13
- 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",
|
|
@@ -42,10 +46,12 @@ TEXT_CODE_EXTENSIONS = {
|
|
|
42
46
|
".kt",
|
|
43
47
|
".kts",
|
|
44
48
|
".lua",
|
|
49
|
+
".m",
|
|
45
50
|
".mjs",
|
|
46
51
|
".mm",
|
|
47
52
|
".mts",
|
|
48
53
|
".php",
|
|
54
|
+
".phtml",
|
|
49
55
|
".proto",
|
|
50
56
|
".ps1",
|
|
51
57
|
".psd1",
|
|
@@ -55,20 +61,35 @@ TEXT_CODE_EXTENSIONS = {
|
|
|
55
61
|
".rs",
|
|
56
62
|
".scala",
|
|
57
63
|
".sh",
|
|
64
|
+
".sol",
|
|
58
65
|
".sql",
|
|
66
|
+
".svelte",
|
|
59
67
|
".swift",
|
|
60
68
|
".tf",
|
|
61
69
|
".toml",
|
|
62
70
|
".ts",
|
|
63
71
|
".tsx",
|
|
64
72
|
".vue",
|
|
73
|
+
".vy",
|
|
65
74
|
".xml",
|
|
66
75
|
".yaml",
|
|
67
76
|
".yml",
|
|
68
77
|
}
|
|
69
78
|
|
|
70
79
|
JAVASCRIPT_EXTENSIONS = {".cjs", ".cts", ".js", ".jsx", ".mjs", ".mts", ".ts", ".tsx", ".vue"}
|
|
71
|
-
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
|
+
}
|
|
72
93
|
BRACE_LANGUAGE_EXTENSIONS = {
|
|
73
94
|
*JAVASCRIPT_EXTENSIONS,
|
|
74
95
|
*JAVA_LIKE_EXTENSIONS,
|
|
@@ -82,6 +103,7 @@ BRACE_LANGUAGE_EXTENSIONS = {
|
|
|
82
103
|
".swift",
|
|
83
104
|
}
|
|
84
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})\(')
|
|
85
107
|
RUST_RAW_STRING_RE = re.compile(r'(?:br|r)(#{0,16})"')
|
|
86
108
|
RUST_LIFETIME_RE = re.compile(r"'[A-Za-z_][A-Za-z0-9_]*")
|
|
87
109
|
PHP_HEREDOC_RE = re.compile(r"<<<\s*['\"]?([A-Za-z_]\w*)['\"]?")
|
|
@@ -183,7 +205,7 @@ def python_arguments(node: ast.FunctionDef | ast.AsyncFunctionDef) -> str:
|
|
|
183
205
|
def python_outline(text: str) -> list[str]:
|
|
184
206
|
try:
|
|
185
207
|
tree = ast.parse(text)
|
|
186
|
-
except (SyntaxError, ValueError, TypeError, MemoryError):
|
|
208
|
+
except (SyntaxError, ValueError, TypeError, MemoryError, RecursionError):
|
|
187
209
|
return []
|
|
188
210
|
|
|
189
211
|
outline: list[str] = []
|
|
@@ -283,13 +305,13 @@ def mask_c_style_source(text: str, suffix: str) -> str:
|
|
|
283
305
|
continue
|
|
284
306
|
if heredoc_terminator:
|
|
285
307
|
if index == 0 or text[index - 1] == "\n":
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
if
|
|
291
|
-
masked.extend(" " * (
|
|
292
|
-
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()
|
|
293
315
|
heredoc_terminator = ""
|
|
294
316
|
continue
|
|
295
317
|
masked.append(" ")
|
|
@@ -337,6 +359,14 @@ def mask_c_style_source(text: str, suffix: str) -> str:
|
|
|
337
359
|
quote = ""
|
|
338
360
|
index += 1
|
|
339
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
|
|
340
370
|
if suffix == ".rs":
|
|
341
371
|
raw_match = RUST_RAW_STRING_RE.match(text, index)
|
|
342
372
|
if raw_match:
|
|
@@ -359,6 +389,11 @@ def mask_c_style_source(text: str, suffix: str) -> str:
|
|
|
359
389
|
quote = '@"'
|
|
360
390
|
index += 2
|
|
361
391
|
continue
|
|
392
|
+
if suffix == ".go" and char == "`":
|
|
393
|
+
masked.append(" ")
|
|
394
|
+
raw_terminator = "`"
|
|
395
|
+
index += 1
|
|
396
|
+
continue
|
|
362
397
|
triple_quote = text[index : index + 3]
|
|
363
398
|
if triple_quote in {'"""', "'''"}:
|
|
364
399
|
masked.extend((" ", " ", " "))
|
|
@@ -456,7 +491,7 @@ def match_type_declaration(line: str, suffix: str) -> tuple[str, str] | None:
|
|
|
456
491
|
match = re.search(r"\b(class|struct|enum|protocol|actor|extension)\s+([A-Za-z_]\w*)", line)
|
|
457
492
|
elif suffix == ".dart":
|
|
458
493
|
match = re.search(r"\b(class|mixin|enum|extension)\s+([A-Za-z_]\w*)", line)
|
|
459
|
-
elif suffix in {".c", ".cc", ".cpp", ".cxx", ".h", ".hpp", ".mm"}:
|
|
494
|
+
elif suffix in {".c", ".cc", ".cpp", ".cxx", ".h", ".hh", ".hpp", ".hxx", ".mm"}:
|
|
460
495
|
match = re.search(
|
|
461
496
|
r"\b(class|struct|union|enum(?:\s+class)?)\s+([A-Za-z_]\w*)",
|
|
462
497
|
line,
|
|
@@ -508,12 +543,20 @@ def match_java_like_function(
|
|
|
508
543
|
prefix = before[: name_match.start()].strip()
|
|
509
544
|
if not prefix and name != (type_name or ""):
|
|
510
545
|
return None
|
|
511
|
-
if suffix in {
|
|
512
|
-
|
|
513
|
-
|
|
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")):
|
|
514
557
|
return None
|
|
515
558
|
if (
|
|
516
|
-
suffix in {".c", ".cc", ".cpp", ".cxx", ".h", ".hpp", ".mm"}
|
|
559
|
+
suffix in {".c", ".cc", ".cpp", ".cxx", ".h", ".hh", ".hpp", ".hxx", ".mm"}
|
|
517
560
|
and type_name is None
|
|
518
561
|
and line.endswith(";")
|
|
519
562
|
and not re.search(
|
|
@@ -651,8 +694,7 @@ def strip_leading_annotations(original: str, masked: str) -> tuple[str, str, lis
|
|
|
651
694
|
def brace_language_outline(text: str, suffix: str) -> list[str]:
|
|
652
695
|
original_lines = text.splitlines()
|
|
653
696
|
masked_lines = mask_c_style_source(text, suffix).splitlines()
|
|
654
|
-
outline:
|
|
655
|
-
seen: set[str] = set()
|
|
697
|
+
outline: dict[str, None] = {}
|
|
656
698
|
type_stack: list[tuple[str, int]] = []
|
|
657
699
|
function_depths: list[int] = []
|
|
658
700
|
blocked_depths: list[int] = []
|
|
@@ -663,9 +705,7 @@ def brace_language_outline(text: str, suffix: str) -> list[str]:
|
|
|
663
705
|
|
|
664
706
|
def add(value: str) -> None:
|
|
665
707
|
decorated = f"{' '.join(pending_annotations[-2:])} {value}".strip()
|
|
666
|
-
|
|
667
|
-
seen.add(decorated)
|
|
668
|
-
outline.append(decorated)
|
|
708
|
+
outline[decorated] = None
|
|
669
709
|
|
|
670
710
|
def next_lines_open_body(line_index: int) -> bool:
|
|
671
711
|
inspected = 0
|
|
@@ -777,20 +817,14 @@ def brace_language_outline(text: str, suffix: str) -> list[str]:
|
|
|
777
817
|
type_stack.pop()
|
|
778
818
|
while blocked_depths and depth < blocked_depths[-1]:
|
|
779
819
|
blocked_depths.pop()
|
|
780
|
-
return outline
|
|
820
|
+
return list(outline)
|
|
781
821
|
|
|
782
822
|
|
|
783
823
|
def ruby_outline(text: str) -> list[str]:
|
|
784
|
-
outline:
|
|
785
|
-
seen: set[str] = set()
|
|
824
|
+
outline: dict[str, None] = {}
|
|
786
825
|
type_stack: list[tuple[int, str]] = []
|
|
787
826
|
function_indents: list[int] = []
|
|
788
827
|
|
|
789
|
-
def add(value: str) -> None:
|
|
790
|
-
if value not in seen:
|
|
791
|
-
seen.add(value)
|
|
792
|
-
outline.append(value)
|
|
793
|
-
|
|
794
828
|
for raw_line in text.splitlines():
|
|
795
829
|
stripped = raw_line.strip()
|
|
796
830
|
if not stripped or stripped.startswith("#"):
|
|
@@ -804,7 +838,7 @@ def ruby_outline(text: str) -> list[str]:
|
|
|
804
838
|
type_match = re.match(r"^(class|module)\s+([A-Z]\w*(?:::[A-Z]\w*)*)", stripped)
|
|
805
839
|
if type_match and not function_indents:
|
|
806
840
|
kind, name = type_match.groups()
|
|
807
|
-
|
|
841
|
+
outline[f"{kind} {name}"] = None
|
|
808
842
|
type_stack.append((indent, name))
|
|
809
843
|
continue
|
|
810
844
|
|
|
@@ -812,21 +846,15 @@ def ruby_outline(text: str) -> list[str]:
|
|
|
812
846
|
if function_match and not function_indents:
|
|
813
847
|
name = function_match.group(1)
|
|
814
848
|
if type_stack:
|
|
815
|
-
|
|
849
|
+
outline[f"method {type_stack[-1][1]}.{name}"] = None
|
|
816
850
|
else:
|
|
817
|
-
|
|
851
|
+
outline[f"function {name}"] = None
|
|
818
852
|
function_indents.append(indent)
|
|
819
|
-
return outline
|
|
853
|
+
return list(outline)
|
|
820
854
|
|
|
821
855
|
|
|
822
856
|
def simple_language_outline(text: str, suffix: str) -> list[str]:
|
|
823
|
-
outline:
|
|
824
|
-
seen: set[str] = set()
|
|
825
|
-
|
|
826
|
-
def add(value: str) -> None:
|
|
827
|
-
if value not in seen:
|
|
828
|
-
seen.add(value)
|
|
829
|
-
outline.append(value)
|
|
857
|
+
outline: dict[str, None] = {}
|
|
830
858
|
|
|
831
859
|
for raw_line in text.splitlines():
|
|
832
860
|
line = compact_preview_line(raw_line)
|
|
@@ -836,69 +864,63 @@ def simple_language_outline(text: str, suffix: str) -> list[str]:
|
|
|
836
864
|
if suffix == ".py":
|
|
837
865
|
match = re.match(r"^(async\s+)?def\s+([A-Za-z_]\w*)\s*\(", line)
|
|
838
866
|
if match:
|
|
839
|
-
|
|
867
|
+
outline[
|
|
868
|
+
f"{'async function' if match.group(1) else 'function'} {match.group(2)}"
|
|
869
|
+
] = None
|
|
840
870
|
continue
|
|
841
871
|
match = re.match(r"^class\s+([A-Za-z_]\w*)", line)
|
|
842
872
|
if match:
|
|
843
|
-
|
|
844
|
-
elif suffix == ".rb":
|
|
845
|
-
match = re.match(r"^(class|module)\s+([A-Z]\w*(?:::[A-Z]\w*)*)", line)
|
|
846
|
-
if match:
|
|
847
|
-
add(f"{match.group(1)} {match.group(2)}")
|
|
848
|
-
continue
|
|
849
|
-
match = re.match(r"^def\s+(?:self\.)?([^\s(]+)", line)
|
|
850
|
-
if match:
|
|
851
|
-
add(f"function {match.group(1)}")
|
|
873
|
+
outline[f"class {match.group(1)}"] = None
|
|
852
874
|
elif suffix in {".ex", ".exs"}:
|
|
853
875
|
match = re.match(r"^defmodule\s+([A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*)", line)
|
|
854
876
|
if match:
|
|
855
|
-
|
|
877
|
+
outline[f"module {match.group(1)}"] = None
|
|
856
878
|
continue
|
|
857
879
|
match = re.match(r"^(?:def|defp|defmacro)\s+([A-Za-z_]\w*[!?]?)", line)
|
|
858
880
|
if match:
|
|
859
|
-
|
|
881
|
+
outline[f"function {match.group(1)}"] = None
|
|
860
882
|
elif suffix == ".clj":
|
|
861
883
|
match = re.match(
|
|
862
884
|
r"^\((defn|defmacro|defprotocol|defrecord|deftype|defmulti|defmethod)\s+([^\s)]+)",
|
|
863
885
|
line,
|
|
864
886
|
)
|
|
865
887
|
if match:
|
|
866
|
-
|
|
888
|
+
outline[f"{match.group(1)} {match.group(2)}"] = None
|
|
867
889
|
elif suffix == ".lua":
|
|
868
890
|
match = re.match(r"^(?:local\s+)?function\s+([A-Za-z_]\w*(?:[.:][A-Za-z_]\w*)*)", line)
|
|
869
891
|
if match:
|
|
870
|
-
|
|
892
|
+
outline[f"function {match.group(1)}"] = None
|
|
871
893
|
elif suffix == ".sh":
|
|
872
894
|
match = re.match(r"^(?:function\s+)?([A-Za-z_]\w*)\s*\(\s*\)\s*\{?", line)
|
|
873
895
|
if match:
|
|
874
|
-
|
|
896
|
+
outline[f"function {match.group(1)}"] = None
|
|
875
897
|
elif suffix == ".hs":
|
|
876
898
|
match = re.match(r"^(data|newtype|type|class)\s+([A-Z]\w*)", line)
|
|
877
899
|
if match:
|
|
878
|
-
|
|
900
|
+
outline[f"{match.group(1)} {match.group(2)}"] = None
|
|
879
901
|
continue
|
|
880
902
|
match = re.match(r"^([a-z_]\w*)\s*::", line)
|
|
881
903
|
if match:
|
|
882
|
-
|
|
904
|
+
outline[f"function {match.group(1)}"] = None
|
|
883
905
|
elif suffix == ".proto":
|
|
884
906
|
match = re.match(r"^(message|service|enum)\s+([A-Za-z_]\w*)", line)
|
|
885
907
|
if match:
|
|
886
|
-
|
|
908
|
+
outline[f"{match.group(1)} {match.group(2)}"] = None
|
|
887
909
|
continue
|
|
888
910
|
match = re.match(r"^rpc\s+([A-Za-z_]\w*)\s*\(", line)
|
|
889
911
|
if match:
|
|
890
|
-
|
|
912
|
+
outline[f"rpc {match.group(1)}"] = None
|
|
891
913
|
elif suffix == ".graphql":
|
|
892
914
|
match = re.match(
|
|
893
915
|
r"^(type|interface|input|enum|union|scalar|directive)\s+([A-Za-z_]\w*)",
|
|
894
916
|
line,
|
|
895
917
|
)
|
|
896
918
|
if match:
|
|
897
|
-
|
|
919
|
+
outline[f"{match.group(1)} {match.group(2)}"] = None
|
|
898
920
|
continue
|
|
899
921
|
match = re.match(r"^(query|mutation|subscription)\s+([A-Za-z_]\w*)", line)
|
|
900
922
|
if match:
|
|
901
|
-
|
|
923
|
+
outline[f"{match.group(1)} {match.group(2)}"] = None
|
|
902
924
|
elif suffix == ".sql":
|
|
903
925
|
match = re.match(
|
|
904
926
|
r"^CREATE\s+(?:OR\s+REPLACE\s+)?(FUNCTION|PROCEDURE|TABLE|VIEW|TRIGGER)\s+"
|
|
@@ -907,16 +929,16 @@ def simple_language_outline(text: str, suffix: str) -> list[str]:
|
|
|
907
929
|
flags=re.IGNORECASE,
|
|
908
930
|
)
|
|
909
931
|
if match:
|
|
910
|
-
|
|
932
|
+
outline[f"{match.group(1).lower()} {match.group(2)}"] = None
|
|
911
933
|
elif suffix in {".yaml", ".yml"}:
|
|
912
934
|
match = re.match(r"^([A-Za-z0-9_.-]+):(?:\s|$)", raw_line)
|
|
913
935
|
if match:
|
|
914
|
-
|
|
936
|
+
outline[f"key {match.group(1)}"] = None
|
|
915
937
|
elif suffix in {".toml", ".cfg"}:
|
|
916
938
|
match = re.match(r"^\[([^]]+)]$", line)
|
|
917
939
|
if match:
|
|
918
|
-
|
|
919
|
-
return outline
|
|
940
|
+
outline[f"section {match.group(1)}"] = None
|
|
941
|
+
return list(outline)
|
|
920
942
|
|
|
921
943
|
|
|
922
944
|
def json_outline(text: str) -> list[str]:
|
|
@@ -976,12 +998,8 @@ def preview_for_bytes(path: Path, data: bytes, preview_bytes: int) -> tuple[str,
|
|
|
976
998
|
return fit_preview_lines(preview_lines, preview_bytes), False
|
|
977
999
|
|
|
978
1000
|
|
|
979
|
-
|
|
1001
|
+
if __name__ == "__main__":
|
|
980
1002
|
parser = argparse.ArgumentParser(
|
|
981
1003
|
description="Build structural or sampled previews for Codex Security rank inputs."
|
|
982
1004
|
)
|
|
983
1005
|
parser.parse_args()
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
if __name__ == "__main__":
|
|
987
|
-
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)
|