@openai/codex-security 0.1.26 → 0.1.28
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 +637 -74
- package/_bundled_plugin/.mcp.json +1 -0
- package/_bundled_plugin/mcp/helpers.mjs +24 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/native/COPYRIGHT-library.html +5556 -0
- package/_bundled_plugin/mcp/native/THIRD_PARTY_NOTICES.txt +5989 -0
- 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/licenses/Apache-2.0.txt +73 -0
- package/_bundled_plugin/mcp/native/licenses/BSD-2-Clause.txt +9 -0
- package/_bundled_plugin/mcp/native/licenses/MIT.txt +9 -0
- package/_bundled_plugin/mcp/native/licenses/Unicode-3.0.txt +39 -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 +56 -0
- package/_bundled_plugin/references/config-preflight.md +9 -1
- package/_bundled_plugin/references/core-scan.md +1 -1
- package/_bundled_plugin/references/final-report.md +2 -0
- package/_bundled_plugin/references/scan-artifacts.md +6 -14
- package/_bundled_plugin/references/scan-contract.md +35 -35
- package/_bundled_plugin/references/scan-prologue.md +2 -0
- package/_bundled_plugin/references/security-guidance.md +9 -1
- package/_bundled_plugin/scripts/deep_scan_config.py +10 -8
- package/_bundled_plugin/scripts/deep_scan_defaults.json +8 -0
- package/_bundled_plugin/scripts/generate_in_scope_files.py +2 -2
- package/_bundled_plugin/scripts/generate_rank_input.py +8 -1
- package/_bundled_plugin/scripts/launch_codex_security_mcp +6 -0
- package/_bundled_plugin/scripts/launch_codex_security_mcp.cmd +43 -9
- package/_bundled_plugin/scripts/rank_preview.py +4 -1
- package/_bundled_plugin/scripts/reserved_artifact_paths.json +6 -0
- package/_bundled_plugin/scripts/windows_scan_local_files.py +1 -3
- package/_bundled_plugin/scripts/workbench/storage.py +18 -0
- package/_bundled_plugin/scripts/workbench_cli.py +17 -0
- package/_bundled_plugin/scripts/workbench_db.py +46 -42
- package/_bundled_plugin/scripts/workbench_saved_results.py +72 -1
- package/_bundled_plugin/scripts/workbench_scan_history.py +117 -2
- package/_bundled_plugin/scripts/workbench_scan_usage.py +23 -10
- package/_bundled_plugin/scripts/workbench_validation.py +4 -0
- package/_bundled_plugin/skills/assess-patch-risk/SKILL.md +2 -0
- package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +2 -0
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +5 -1
- package/_bundled_plugin/skills/define-security-policy/SKILL.md +3 -3
- package/_bundled_plugin/skills/finding-discovery/SKILL.md +2 -0
- package/_bundled_plugin/skills/fix-finding/SKILL.md +3 -1
- package/_bundled_plugin/skills/fix-finding/agents/openai.yaml +1 -1
- package/_bundled_plugin/skills/propose-security-hardening/SKILL.md +2 -0
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +5 -1
- package/_bundled_plugin/skills/threat-model/SKILL.md +2 -0
- package/_bundled_plugin/skills/validation/SKILL.md +2 -0
- package/_bundled_plugin/skills/vulnerability-writeup/SKILL.md +2 -0
- package/dist/api.d.ts +14 -24
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +585 -168
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +10 -0
- package/dist/auth.js.map +1 -1
- package/dist/bulk-scan-discovery.d.ts +1 -1
- package/dist/bulk-scan-discovery.d.ts.map +1 -1
- package/dist/bulk-scan-discovery.js +2 -2
- package/dist/bulk-scan-discovery.js.map +1 -1
- package/dist/classify-scan-severity.js.map +1 -1
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli.d.ts +24 -4
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1577 -610
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.d.ts.map +1 -1
- package/dist/cloud-publish.js +2 -207
- package/dist/cloud-publish.js.map +1 -1
- package/dist/component-plan.d.ts.map +1 -1
- package/dist/component-plan.js +116 -32
- package/dist/component-plan.js.map +1 -1
- package/dist/component-scan.d.ts +4 -2
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +7 -1
- package/dist/component-scan.js.map +1 -1
- package/dist/config-path.d.ts +6 -0
- package/dist/config-path.d.ts.map +1 -0
- package/dist/config-path.js +6 -0
- package/dist/config-path.js.map +1 -0
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +30 -5
- package/dist/config.js.map +1 -1
- package/dist/contract.d.ts +5 -10
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js.map +1 -1
- package/dist/cost-model.d.ts +30 -0
- package/dist/cost-model.d.ts.map +1 -1
- package/dist/cost-model.js +123 -4
- package/dist/cost-model.js.map +1 -1
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +18 -3
- package/dist/cost.js.map +1 -1
- package/dist/custom-publish.js.map +1 -1
- package/dist/custom-validation-prompt.js +1 -1
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/deduplication/checkpointed-review.d.ts.map +1 -1
- package/dist/deduplication/checkpointed-review.js.map +1 -1
- package/dist/deduplication/codex-review.d.ts +6 -1
- package/dist/deduplication/codex-review.d.ts.map +1 -1
- package/dist/deduplication/codex-review.js +72 -17
- 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.map +1 -1
- package/dist/deduplication/deduplication.d.ts +2 -0
- package/dist/deduplication/deduplication.d.ts.map +1 -1
- package/dist/deduplication/deduplication.js +99 -26
- package/dist/deduplication/deduplication.js.map +1 -1
- package/dist/deduplication/retry.d.ts +3 -0
- package/dist/deduplication/retry.d.ts.map +1 -0
- package/dist/deduplication/retry.js +15 -0
- package/dist/deduplication/retry.js.map +1 -0
- package/dist/deduplication/scan.d.ts +2 -0
- package/dist/deduplication/scan.d.ts.map +1 -1
- package/dist/deduplication/scan.js +4 -2
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/deep-config.d.ts +17 -0
- package/dist/deep-config.d.ts.map +1 -0
- package/dist/deep-config.js +145 -0
- package/dist/deep-config.js.map +1 -0
- package/dist/deep-progress.d.ts.map +1 -1
- package/dist/deep-scan-defaults.d.ts +9 -0
- package/dist/deep-scan-defaults.d.ts.map +1 -0
- package/dist/deep-scan-defaults.js +10 -0
- package/dist/deep-scan-defaults.js.map +1 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +2 -2
- package/dist/errors.js.map +1 -1
- package/dist/feedback.d.ts +20 -0
- package/dist/feedback.d.ts.map +1 -0
- package/dist/feedback.js +135 -0
- package/dist/feedback.js.map +1 -0
- package/dist/finding-catalogue.js.map +1 -1
- package/dist/finding-workflow.d.ts.map +1 -1
- package/dist/finding-workflow.js.map +1 -1
- package/dist/findings-client.d.ts +7 -1
- package/dist/findings-client.d.ts.map +1 -1
- package/dist/findings-client.js +55 -10
- package/dist/findings-client.js.map +1 -1
- package/dist/findings-import.d.ts +44 -0
- package/dist/findings-import.d.ts.map +1 -0
- package/dist/findings-import.js +302 -0
- package/dist/findings-import.js.map +1 -0
- package/dist/github.d.ts +625 -7
- package/dist/github.d.ts.map +1 -1
- package/dist/github.js.map +1 -1
- package/dist/import-scan.d.ts +27 -0
- package/dist/import-scan.d.ts.map +1 -0
- package/dist/import-scan.js +236 -0
- package/dist/import-scan.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/knowledge-base.d.ts +1 -1
- package/dist/knowledge-base.d.ts.map +1 -1
- package/dist/knowledge-base.js +19 -8
- package/dist/knowledge-base.js.map +1 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js.map +1 -1
- package/dist/multiscan.d.ts +7 -5
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +212 -55
- package/dist/multiscan.js.map +1 -1
- package/dist/patch-tui.d.ts.map +1 -1
- package/dist/patch-tui.js.map +1 -1
- package/dist/project-config-schema.d.ts +191 -0
- package/dist/project-config-schema.d.ts.map +1 -0
- package/dist/project-config-schema.js +85 -0
- package/dist/project-config-schema.js.map +1 -0
- package/dist/project-config.d.ts +50 -0
- package/dist/project-config.d.ts.map +1 -0
- package/dist/project-config.js +220 -0
- package/dist/project-config.js.map +1 -0
- package/dist/prompt-files.d.ts +13 -0
- package/dist/prompt-files.d.ts.map +1 -0
- package/dist/prompt-files.js +74 -0
- package/dist/prompt-files.js.map +1 -0
- package/dist/publication-events.d.ts.map +1 -1
- package/dist/publication-events.js +7 -2
- package/dist/publication-events.js.map +1 -1
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +1 -1
- package/dist/publish.js.map +1 -1
- package/dist/result.d.ts +2 -1
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +5 -0
- package/dist/result.js.map +1 -1
- package/dist/runtime.d.ts +5 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +12 -6
- package/dist/runtime.js.map +1 -1
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts +1 -0
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +45 -20
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-logs.d.ts +39 -3
- package/dist/scan-logs.d.ts.map +1 -1
- package/dist/scan-logs.js +77 -15
- package/dist/scan-logs.js.map +1 -1
- package/dist/scan-modes.d.ts +3 -0
- package/dist/scan-modes.d.ts.map +1 -0
- package/dist/scan-modes.js +2 -0
- package/dist/scan-modes.js.map +1 -0
- package/dist/scan-settings.d.ts +81 -0
- package/dist/scan-settings.d.ts.map +1 -0
- package/dist/scan-settings.js +123 -0
- package/dist/scan-settings.js.map +1 -0
- package/dist/security-policy-cli.d.ts +39 -0
- package/dist/security-policy-cli.d.ts.map +1 -0
- package/dist/security-policy-cli.js +193 -0
- package/dist/security-policy-cli.js.map +1 -0
- package/dist/security-policy.d.ts +80 -0
- package/dist/security-policy.d.ts.map +1 -0
- package/dist/security-policy.js +672 -0
- package/dist/security-policy.js.map +1 -0
- package/dist/server/dashboard/THIRD_PARTY_NOTICES.txt +2 -2
- package/dist/server/dashboard/app.js +2 -2
- package/dist/server/dashboard.js.map +1 -1
- package/dist/server/embeddings.d.ts.map +1 -1
- package/dist/server/embeddings.js.map +1 -1
- package/dist/server/errors.d.ts.map +1 -1
- package/dist/server/errors.js.map +1 -1
- package/dist/server/findings-service.d.ts.map +1 -1
- package/dist/server/findings-service.js.map +1 -1
- package/dist/server/serve.js.map +1 -1
- package/dist/server/sqlite-store.d.ts.map +1 -1
- package/dist/server/sqlite-store.js.map +1 -1
- package/dist/severity-store.js.map +1 -1
- package/dist/targets.d.ts +10 -2
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +243 -14
- package/dist/targets.js.map +1 -1
- package/dist/thread-source.d.ts.map +1 -1
- package/dist/version.js.map +1 -1
- package/dist/worker-progress.d.ts.map +1 -1
- package/dist/worker-progress.js.map +1 -1
- package/package.json +36 -29
- package/schemas/project-config.schema.json +211 -0
- package/_bundled_plugin/scripts/resolve_security_md.py +0 -158
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"$schema": {
|
|
6
|
+
"description": "Editor schema URI or relative path. The CLI does not fetch or select a validator from this value.",
|
|
7
|
+
"type": "string",
|
|
8
|
+
"minLength": 1
|
|
9
|
+
},
|
|
10
|
+
"auth": {
|
|
11
|
+
"default": "auto",
|
|
12
|
+
"description": "Credential-source choice only; never a credential value.",
|
|
13
|
+
"type": "string",
|
|
14
|
+
"enum": ["auto", "chatgpt", "api-key"]
|
|
15
|
+
},
|
|
16
|
+
"scan": {
|
|
17
|
+
"type": "object",
|
|
18
|
+
"properties": {
|
|
19
|
+
"mode": {
|
|
20
|
+
"default": "standard",
|
|
21
|
+
"type": "string",
|
|
22
|
+
"enum": ["standard", "deep"]
|
|
23
|
+
},
|
|
24
|
+
"scope": {
|
|
25
|
+
"description": "One scope variant. Omit for the whole repository. Mode compatibility is checked after overrides.",
|
|
26
|
+
"anyOf": [
|
|
27
|
+
{
|
|
28
|
+
"type": "object",
|
|
29
|
+
"properties": {
|
|
30
|
+
"paths": {
|
|
31
|
+
"minItems": 1,
|
|
32
|
+
"type": "array",
|
|
33
|
+
"items": { "type": "string", "minLength": 1 },
|
|
34
|
+
"description": "Literal paths relative to the selected repository."
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"required": ["paths"],
|
|
38
|
+
"additionalProperties": false
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"type": "object",
|
|
42
|
+
"properties": {
|
|
43
|
+
"diff": {
|
|
44
|
+
"type": "object",
|
|
45
|
+
"properties": {
|
|
46
|
+
"base": { "type": "string", "minLength": 1 },
|
|
47
|
+
"head": {
|
|
48
|
+
"default": "HEAD",
|
|
49
|
+
"type": "string",
|
|
50
|
+
"minLength": 1
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"required": ["base"],
|
|
54
|
+
"additionalProperties": false
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"required": ["diff"],
|
|
58
|
+
"additionalProperties": false
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"type": "object",
|
|
62
|
+
"properties": {
|
|
63
|
+
"working_tree": {
|
|
64
|
+
"type": "object",
|
|
65
|
+
"properties": {
|
|
66
|
+
"base": {
|
|
67
|
+
"default": "HEAD",
|
|
68
|
+
"type": "string",
|
|
69
|
+
"minLength": 1
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"additionalProperties": false
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"required": ["working_tree"],
|
|
76
|
+
"additionalProperties": false
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
"knowledge_base": {
|
|
81
|
+
"description": "Context files or directories, relative to this file. An empty list selects no additional context.",
|
|
82
|
+
"type": "array",
|
|
83
|
+
"items": { "type": "string", "minLength": 1 }
|
|
84
|
+
},
|
|
85
|
+
"instructions_file": {
|
|
86
|
+
"description": "Additional scan instructions, relative to this file.",
|
|
87
|
+
"type": "string",
|
|
88
|
+
"minLength": 1
|
|
89
|
+
},
|
|
90
|
+
"validation_file": {
|
|
91
|
+
"description": "Custom validation instructions, relative to this file; not supported in active deep scans.",
|
|
92
|
+
"type": "string",
|
|
93
|
+
"minLength": 1
|
|
94
|
+
},
|
|
95
|
+
"deep": {
|
|
96
|
+
"description": "Deep defaults; a valid block may be retained while standard mode is selected.",
|
|
97
|
+
"type": "object",
|
|
98
|
+
"properties": {
|
|
99
|
+
"workers": {
|
|
100
|
+
"default": 4,
|
|
101
|
+
"description": "Maximum concurrent deep-scan discovery workers.",
|
|
102
|
+
"type": "integer",
|
|
103
|
+
"exclusiveMinimum": 0,
|
|
104
|
+
"maximum": 9007199254740991
|
|
105
|
+
},
|
|
106
|
+
"subagents_per_worker": {
|
|
107
|
+
"default": 3,
|
|
108
|
+
"description": "Subagents available to each deep-scan worker. Zero is valid.",
|
|
109
|
+
"type": "integer",
|
|
110
|
+
"minimum": 0,
|
|
111
|
+
"maximum": 9007199254740991
|
|
112
|
+
},
|
|
113
|
+
"stop_after_no_new": {
|
|
114
|
+
"default": 4,
|
|
115
|
+
"description": "Stop after this many runs find no new issues.",
|
|
116
|
+
"type": "integer",
|
|
117
|
+
"exclusiveMinimum": 0,
|
|
118
|
+
"maximum": 9007199254740991
|
|
119
|
+
},
|
|
120
|
+
"stop_after_consecutive_errors": {
|
|
121
|
+
"default": 3,
|
|
122
|
+
"description": "Stop after this many consecutive discovery errors.",
|
|
123
|
+
"type": "integer",
|
|
124
|
+
"exclusiveMinimum": 0,
|
|
125
|
+
"maximum": 9007199254740991
|
|
126
|
+
},
|
|
127
|
+
"max_discovery_runs": {
|
|
128
|
+
"default": 40,
|
|
129
|
+
"description": "Maximum deep-scan discovery runs.",
|
|
130
|
+
"type": "integer",
|
|
131
|
+
"exclusiveMinimum": 0,
|
|
132
|
+
"maximum": 9007199254740991
|
|
133
|
+
},
|
|
134
|
+
"max_time_hours": {
|
|
135
|
+
"default": 96,
|
|
136
|
+
"description": "Maximum deep-scan discovery hours (default: 96; maximum: 96).",
|
|
137
|
+
"type": "number",
|
|
138
|
+
"exclusiveMinimum": 0,
|
|
139
|
+
"maximum": 96
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
"additionalProperties": false
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
"additionalProperties": false
|
|
146
|
+
},
|
|
147
|
+
"codex": {
|
|
148
|
+
"description": "Native Codex overrides. Common key types are checked here; existing native and wrapper restrictions still apply.",
|
|
149
|
+
"type": "object",
|
|
150
|
+
"properties": {
|
|
151
|
+
"model": { "type": "string", "minLength": 1 },
|
|
152
|
+
"model_reasoning_effort": { "type": "string", "minLength": 1 },
|
|
153
|
+
"model_provider": { "type": "string", "minLength": 1 }
|
|
154
|
+
},
|
|
155
|
+
"additionalProperties": { "$ref": "#/definitions/__schema0" }
|
|
156
|
+
},
|
|
157
|
+
"limits": {
|
|
158
|
+
"type": "object",
|
|
159
|
+
"properties": {
|
|
160
|
+
"max_cost_usd_per_scan": {
|
|
161
|
+
"description": "Estimated USD limit per launched scan attempt, not a total batch budget. Omit for no limit.",
|
|
162
|
+
"type": "number",
|
|
163
|
+
"exclusiveMinimum": 0
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
"additionalProperties": false
|
|
167
|
+
},
|
|
168
|
+
"policy": {
|
|
169
|
+
"type": "object",
|
|
170
|
+
"properties": {
|
|
171
|
+
"fail_on_severity": {
|
|
172
|
+
"description": "Exit threshold; does not filter retained findings. Omit for report-only behavior.",
|
|
173
|
+
"type": "string",
|
|
174
|
+
"enum": ["critical", "high", "medium", "low"]
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
"additionalProperties": false
|
|
178
|
+
},
|
|
179
|
+
"output": {
|
|
180
|
+
"type": "object",
|
|
181
|
+
"properties": {
|
|
182
|
+
"directory": {
|
|
183
|
+
"description": "Artifact directory relative to this file; existing outside-worktree checks still apply.",
|
|
184
|
+
"type": "string",
|
|
185
|
+
"minLength": 1
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
"additionalProperties": false
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
"additionalProperties": false,
|
|
192
|
+
"definitions": {
|
|
193
|
+
"__schema0": {
|
|
194
|
+
"anyOf": [
|
|
195
|
+
{ "type": "string" },
|
|
196
|
+
{ "type": "number" },
|
|
197
|
+
{ "type": "boolean" },
|
|
198
|
+
{ "type": "null" },
|
|
199
|
+
{ "type": "array", "items": { "$ref": "#/definitions/__schema0" } },
|
|
200
|
+
{
|
|
201
|
+
"type": "object",
|
|
202
|
+
"propertyNames": { "type": "string" },
|
|
203
|
+
"additionalProperties": { "$ref": "#/definitions/__schema0" }
|
|
204
|
+
}
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
"title": "Codex Security project configuration",
|
|
209
|
+
"description": "Input schema for explicitly selected YAML or JSON project files. Filesystem, active scan combinations, native configuration, and runtime availability are checked separately.",
|
|
210
|
+
"$comment": "Generated from ProjectConfigInputSchema. Defaults are annotations; apply defaults only after merging input layers."
|
|
211
|
+
}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""Concatenate the SECURITY.md files that apply to a scan path."""
|
|
3
|
-
|
|
4
|
-
from __future__ import annotations
|
|
5
|
-
|
|
6
|
-
import argparse
|
|
7
|
-
import json
|
|
8
|
-
import os
|
|
9
|
-
import stat
|
|
10
|
-
import sys
|
|
11
|
-
from pathlib import Path
|
|
12
|
-
|
|
13
|
-
MAX_SECURITY_MD_BYTES = 1024 * 1024
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class ResolutionError(ValueError):
|
|
17
|
-
"""Raised when a SECURITY.md chain cannot be resolved."""
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def _inside(path: Path, root: Path, label: str) -> Path:
|
|
21
|
-
try:
|
|
22
|
-
return path.relative_to(root)
|
|
23
|
-
except ValueError as exc:
|
|
24
|
-
raise ResolutionError(f"{label} is outside the scan root: {path}") from exc
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def _resolve_root(repo: Path) -> Path:
|
|
28
|
-
try:
|
|
29
|
-
root = repo.expanduser().resolve(strict=True)
|
|
30
|
-
except OSError as exc:
|
|
31
|
-
raise ResolutionError(f"scan root does not exist: {repo}") from exc
|
|
32
|
-
if not root.is_dir():
|
|
33
|
-
raise ResolutionError(f"scan root is not a directory: {root}")
|
|
34
|
-
return root
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def list_security_md(repo: Path) -> list[str]:
|
|
38
|
-
"""Return a stable, safely framed inventory without traversing Git metadata."""
|
|
39
|
-
root = _resolve_root(repo)
|
|
40
|
-
|
|
41
|
-
def raise_walk_error(error: OSError) -> None:
|
|
42
|
-
raise error
|
|
43
|
-
|
|
44
|
-
policies: list[str] = []
|
|
45
|
-
for directory, subdirectories, filenames in os.walk(
|
|
46
|
-
root, onerror=raise_walk_error, followlinks=False
|
|
47
|
-
):
|
|
48
|
-
safe_subdirectories: list[str] = []
|
|
49
|
-
for name in sorted(subdirectories):
|
|
50
|
-
if name == ".git":
|
|
51
|
-
continue
|
|
52
|
-
directory_stat = (Path(directory) / name).stat(follow_symlinks=False)
|
|
53
|
-
if not stat.S_ISDIR(directory_stat.st_mode):
|
|
54
|
-
continue
|
|
55
|
-
reparse_point = getattr(stat, "FILE_ATTRIBUTE_REPARSE_POINT", 0)
|
|
56
|
-
if getattr(directory_stat, "st_file_attributes", 0) & reparse_point:
|
|
57
|
-
continue
|
|
58
|
-
safe_subdirectories.append(name)
|
|
59
|
-
subdirectories[:] = safe_subdirectories
|
|
60
|
-
if "SECURITY.md" not in filenames:
|
|
61
|
-
continue
|
|
62
|
-
policy = Path(directory) / "SECURITY.md"
|
|
63
|
-
if policy.is_file() or policy.is_symlink():
|
|
64
|
-
policies.append(policy.relative_to(root).as_posix())
|
|
65
|
-
return sorted(policies)
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
def resolve_security_md(repo: Path, scope: Path) -> str:
|
|
69
|
-
"""Return applicable SECURITY.md files, concatenated root to leaf."""
|
|
70
|
-
root = _resolve_root(repo)
|
|
71
|
-
|
|
72
|
-
requested_scope = scope.expanduser()
|
|
73
|
-
if not requested_scope.is_absolute():
|
|
74
|
-
requested_scope = root / requested_scope
|
|
75
|
-
try:
|
|
76
|
-
resolved_scope = requested_scope.resolve(strict=True)
|
|
77
|
-
except OSError as exc:
|
|
78
|
-
raise ResolutionError(f"scan scope does not exist: {requested_scope}") from exc
|
|
79
|
-
_inside(resolved_scope, root, "scan scope")
|
|
80
|
-
|
|
81
|
-
target_directory = resolved_scope if resolved_scope.is_dir() else resolved_scope.parent
|
|
82
|
-
relative_directory = _inside(target_directory, root, "scan scope")
|
|
83
|
-
directories = [root]
|
|
84
|
-
current = root
|
|
85
|
-
for part in relative_directory.parts:
|
|
86
|
-
current /= part
|
|
87
|
-
directories.append(current)
|
|
88
|
-
|
|
89
|
-
sections: list[str] = []
|
|
90
|
-
for directory in directories:
|
|
91
|
-
policy = directory / "SECURITY.md"
|
|
92
|
-
if not policy.is_file():
|
|
93
|
-
continue
|
|
94
|
-
resolved_policy = policy.resolve(strict=True)
|
|
95
|
-
_inside(resolved_policy, root, "SECURITY.md")
|
|
96
|
-
try:
|
|
97
|
-
with resolved_policy.open("rb") as policy_file:
|
|
98
|
-
policy_bytes = policy_file.read(MAX_SECURITY_MD_BYTES + 1)
|
|
99
|
-
if len(policy_bytes) > MAX_SECURITY_MD_BYTES:
|
|
100
|
-
raise ResolutionError(f"SECURITY.md exceeds 1 MiB: {policy}")
|
|
101
|
-
content = policy_bytes.decode("utf-8")
|
|
102
|
-
except UnicodeDecodeError as exc:
|
|
103
|
-
raise ResolutionError(f"SECURITY.md is not valid UTF-8: {policy}") from exc
|
|
104
|
-
if not content.strip():
|
|
105
|
-
continue
|
|
106
|
-
|
|
107
|
-
source = policy.relative_to(root).as_posix()
|
|
108
|
-
section = f"## SECURITY.md source: {json.dumps(source)}\n\n{content}"
|
|
109
|
-
if not section.endswith("\n"):
|
|
110
|
-
section += "\n"
|
|
111
|
-
sections.append(section)
|
|
112
|
-
|
|
113
|
-
return "\n".join(sections)
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
def parse_args() -> argparse.Namespace:
|
|
117
|
-
parser = argparse.ArgumentParser(description=__doc__)
|
|
118
|
-
parser.add_argument("--repo", required=True, type=Path, help="scan root directory")
|
|
119
|
-
parser.add_argument(
|
|
120
|
-
"--list",
|
|
121
|
-
action="store_true",
|
|
122
|
-
help="write a JSON inventory of repository policy paths",
|
|
123
|
-
)
|
|
124
|
-
parser.add_argument(
|
|
125
|
-
"--scope",
|
|
126
|
-
type=Path,
|
|
127
|
-
help="existing file or directory within the scan root",
|
|
128
|
-
)
|
|
129
|
-
parser.add_argument("--out", default=Path("-"), type=Path, help="output path, or - for stdout")
|
|
130
|
-
args = parser.parse_args()
|
|
131
|
-
if args.list and args.scope is not None:
|
|
132
|
-
parser.error("--list cannot be combined with --scope")
|
|
133
|
-
if not args.list and args.scope is None:
|
|
134
|
-
parser.error("--scope is required unless --list is specified")
|
|
135
|
-
return args
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
def main() -> int:
|
|
139
|
-
args = parse_args()
|
|
140
|
-
try:
|
|
141
|
-
guidance = (
|
|
142
|
-
json.dumps(list_security_md(args.repo), ensure_ascii=True) + "\n"
|
|
143
|
-
if args.list
|
|
144
|
-
else resolve_security_md(args.repo, args.scope)
|
|
145
|
-
)
|
|
146
|
-
if args.out == Path("-"):
|
|
147
|
-
sys.stdout.buffer.write(guidance.encode("utf-8"))
|
|
148
|
-
else:
|
|
149
|
-
args.out.parent.mkdir(parents=True, exist_ok=True)
|
|
150
|
-
args.out.write_text(guidance, encoding="utf-8")
|
|
151
|
-
except (OSError, ResolutionError) as exc:
|
|
152
|
-
print(f"resolve_security_md.py: error: {exc}", file=sys.stderr)
|
|
153
|
-
return 2
|
|
154
|
-
return 0
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
if __name__ == "__main__":
|
|
158
|
-
raise SystemExit(main())
|