@openai/codex-security 0.3.0 → 0.4.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/_bundled_plugin/.codex-plugin/plugin.json +5 -5
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +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/permission-profile-preflight.mjs +13 -20
- 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/final-report.md +1 -1
- package/_bundled_plugin/schemas/coverage.schema.json +45 -126
- package/_bundled_plugin/schemas/findings.schema.json +140 -427
- package/_bundled_plugin/schemas/patch-risk-assessment.schema.json +106 -119
- package/_bundled_plugin/schemas/scan-manifest.schema.json +73 -188
- package/_bundled_plugin/scripts/finalize_scan_contract.py +7 -6
- package/_bundled_plugin/scripts/generate_rank_input.py +25 -106
- package/_bundled_plugin/scripts/report_projection.py +35 -13
- package/_bundled_plugin/scripts/workbench_cli.py +9 -6
- package/_bundled_plugin/scripts/workbench_db.py +51 -16
- package/_bundled_plugin/scripts/workbench_publication.py +216 -247
- package/_bundled_plugin/scripts/workbench_scan_usage.py +173 -10
- package/_bundled_plugin/scripts/workbench_validation.py +15 -1
- package/_bundled_plugin/shared/workbench-migrations.json +17 -0
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +1 -1
- package/_bundled_plugin/skills/deep-security-scan/agents/openai.yaml +1 -1
- package/_bundled_plugin/skills/security-diff-scan/agents/openai.yaml +1 -1
- package/_bundled_plugin/skills/security-scan/SKILL.md +1 -1
- package/_bundled_plugin/skills/security-scan/agents/openai.yaml +1 -1
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +1 -1
- package/_bundled_plugin/skills/security-scan/references/scan-artifacts-and-ledger.md +2 -0
- package/_bundled_plugin/skills/track-findings/SKILL.md +8 -4
- package/_bundled_plugin/skills/track-findings/agents/openai.yaml +1 -1
- package/_bundled_plugin/skills/track-findings/references/github-security-advisories.md +1 -1
- package/dist/api.d.ts +3 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +212 -3
- package/dist/api.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +15 -5
- package/dist/cli.js.map +1 -1
- package/dist/component-plan.js +1 -1
- package/dist/component-plan.js.map +1 -1
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +5 -4
- package/dist/component-scan.js.map +1 -1
- package/dist/contract.d.ts +1 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +4 -3
- package/dist/contract.js.map +1 -1
- package/dist/custom-validation-prompt.js +1 -1
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/deduplication/codex-review.d.ts +1 -5
- package/dist/deduplication/codex-review.d.ts.map +1 -1
- package/dist/deduplication/codex-review.js +2 -2
- package/dist/deduplication/codex-review.js.map +1 -1
- package/dist/deduplication/deduplication-reviewer.d.ts +1 -1
- package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
- package/dist/deduplication/deduplication-reviewer.js +1 -1
- package/dist/deduplication/deduplication-reviewer.js.map +1 -1
- package/dist/deduplication/records-protocol.d.ts +3 -8
- package/dist/deduplication/records-protocol.d.ts.map +1 -1
- package/dist/deduplication/records-protocol.js +11 -171
- package/dist/deduplication/records-protocol.js.map +1 -1
- package/dist/deep-progress.d.ts +15 -1
- package/dist/deep-progress.d.ts.map +1 -1
- package/dist/deep-progress.js +15 -16
- package/dist/deep-progress.js.map +1 -1
- package/dist/executable-path.d.ts +2 -0
- package/dist/executable-path.d.ts.map +1 -0
- package/dist/executable-path.js +12 -0
- package/dist/executable-path.js.map +1 -0
- package/dist/feedback.d.ts +1 -4
- package/dist/feedback.d.ts.map +1 -1
- package/dist/feedback.js +1 -1
- package/dist/feedback.js.map +1 -1
- package/dist/host-protocol.d.ts +19 -0
- package/dist/host-protocol.d.ts.map +1 -0
- package/dist/host-protocol.js +270 -0
- package/dist/host-protocol.js.map +1 -0
- package/dist/hosted-scan-protocol.d.ts +4 -0
- package/dist/hosted-scan-protocol.d.ts.map +1 -0
- package/dist/hosted-scan-protocol.js +25 -0
- package/dist/hosted-scan-protocol.js.map +1 -0
- package/dist/hosted-scan.d.ts +117 -0
- package/dist/hosted-scan.d.ts.map +1 -0
- package/dist/hosted-scan.js +260 -0
- package/dist/hosted-scan.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +47 -9
- package/dist/multiscan.js.map +1 -1
- package/dist/publication-store.d.ts.map +1 -1
- package/dist/publication-store.js +73 -63
- package/dist/publication-store.js.map +1 -1
- package/dist/publication.d.ts +0 -2
- package/dist/publication.d.ts.map +1 -1
- package/dist/publication.js +0 -5
- package/dist/publication.js.map +1 -1
- package/dist/runtime.d.ts +5 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +5 -38
- package/dist/runtime.js.map +1 -1
- package/dist/scan-executor.d.ts +104 -0
- package/dist/scan-executor.d.ts.map +1 -0
- package/dist/scan-executor.js +62 -0
- package/dist/scan-executor.js.map +1 -0
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +17 -25
- package/dist/targets.js.map +1 -1
- package/dist/worker-progress.d.ts +43 -11
- package/dist/worker-progress.d.ts.map +1 -1
- package/dist/worker-progress.js +21 -37
- package/dist/worker-progress.js.map +1 -1
- package/docs/cli.md +12 -2
- package/docs/hosted-scans.md +242 -0
- package/package.json +9 -7
- package/schemas/hosted-scan-v2.fixture.json +145 -0
|
@@ -1,68 +1,31 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
2
|
"$id": "https://openai.com/codex-security/schemas/scan-manifest.schema.json",
|
|
4
3
|
"title": "Codex Security sealed scan manifest",
|
|
4
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
5
5
|
"type": "object",
|
|
6
|
-
"required": ["documentType", "schemaVersion", "scan"],
|
|
7
6
|
"properties": {
|
|
8
|
-
"documentType": {
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
"schemaVersion": {
|
|
12
|
-
"const": "1.0"
|
|
13
|
-
},
|
|
7
|
+
"documentType": { "const": "codex-security.scan-manifest" },
|
|
8
|
+
"schemaVersion": { "const": "1.0" },
|
|
14
9
|
"scan": {
|
|
15
10
|
"type": "object",
|
|
16
|
-
"required": [
|
|
17
|
-
"id",
|
|
18
|
-
"producer",
|
|
19
|
-
"status",
|
|
20
|
-
"startedAt",
|
|
21
|
-
"completedAt",
|
|
22
|
-
"sealedAt",
|
|
23
|
-
"target",
|
|
24
|
-
"scope",
|
|
25
|
-
"coverageRef",
|
|
26
|
-
"findingsRef",
|
|
27
|
-
"artifacts"
|
|
28
|
-
],
|
|
29
11
|
"properties": {
|
|
30
|
-
"id": {
|
|
31
|
-
"type": "string",
|
|
32
|
-
"minLength": 1
|
|
33
|
-
},
|
|
12
|
+
"id": { "type": "string", "minLength": 1 },
|
|
34
13
|
"producer": {
|
|
35
14
|
"type": "object",
|
|
36
|
-
"required": ["name", "version"],
|
|
37
15
|
"properties": {
|
|
38
|
-
"name": {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"version": {
|
|
43
|
-
"type": "string",
|
|
44
|
-
"minLength": 1
|
|
45
|
-
}
|
|
46
|
-
}
|
|
16
|
+
"name": { "type": "string", "minLength": 1 },
|
|
17
|
+
"version": { "type": "string", "minLength": 1 }
|
|
18
|
+
},
|
|
19
|
+
"required": ["name", "version"]
|
|
47
20
|
},
|
|
48
21
|
"status": {
|
|
49
22
|
"enum": ["completed", "failed", "canceled", "interrupted"]
|
|
50
23
|
},
|
|
51
|
-
"startedAt": {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
},
|
|
55
|
-
"completedAt": {
|
|
56
|
-
"type": "string",
|
|
57
|
-
"format": "date-time"
|
|
58
|
-
},
|
|
59
|
-
"sealedAt": {
|
|
60
|
-
"type": "string",
|
|
61
|
-
"format": "date-time"
|
|
62
|
-
},
|
|
24
|
+
"startedAt": { "type": "string", "format": "date-time" },
|
|
25
|
+
"completedAt": { "type": "string", "format": "date-time" },
|
|
26
|
+
"sealedAt": { "type": "string", "format": "date-time" },
|
|
63
27
|
"target": {
|
|
64
28
|
"type": "object",
|
|
65
|
-
"required": ["kind", "targetId", "displayName"],
|
|
66
29
|
"properties": {
|
|
67
30
|
"kind": {
|
|
68
31
|
"enum": [
|
|
@@ -72,44 +35,25 @@
|
|
|
72
35
|
"directory_snapshot"
|
|
73
36
|
]
|
|
74
37
|
},
|
|
75
|
-
"targetId": {
|
|
76
|
-
|
|
77
|
-
"minLength": 1
|
|
78
|
-
},
|
|
79
|
-
"displayName": {
|
|
80
|
-
"type": "string",
|
|
81
|
-
"minLength": 1
|
|
82
|
-
},
|
|
38
|
+
"targetId": { "type": "string", "minLength": 1 },
|
|
39
|
+
"displayName": { "type": "string", "minLength": 1 },
|
|
83
40
|
"remote": {
|
|
84
41
|
"type": "string",
|
|
85
42
|
"pattern": "^(?![^:/?#]+://[^/?#]*@)[^?#]+$"
|
|
86
43
|
},
|
|
87
|
-
"revision": {
|
|
88
|
-
|
|
89
|
-
},
|
|
90
|
-
"baseRevision": {
|
|
91
|
-
"type": "string"
|
|
92
|
-
},
|
|
93
|
-
"headRevision": {
|
|
94
|
-
"type": "string"
|
|
95
|
-
},
|
|
44
|
+
"revision": { "type": "string" },
|
|
45
|
+
"baseRevision": { "type": "string" },
|
|
46
|
+
"headRevision": { "type": "string" },
|
|
96
47
|
"snapshotDigest": {
|
|
97
48
|
"type": "string",
|
|
98
49
|
"pattern": "^codex-security-snapshot/v1:sha256:[a-f0-9]{64}$"
|
|
99
50
|
}
|
|
100
51
|
},
|
|
52
|
+
"required": ["kind", "targetId", "displayName"],
|
|
101
53
|
"allOf": [
|
|
102
54
|
{
|
|
103
|
-
"if": {
|
|
104
|
-
|
|
105
|
-
"kind": {
|
|
106
|
-
"const": "git_revision"
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
"then": {
|
|
111
|
-
"required": ["revision"]
|
|
112
|
-
}
|
|
55
|
+
"if": { "properties": { "kind": { "const": "git_revision" } } },
|
|
56
|
+
"then": { "required": ["revision"] }
|
|
113
57
|
},
|
|
114
58
|
{
|
|
115
59
|
"if": {
|
|
@@ -119,86 +63,42 @@
|
|
|
119
63
|
}
|
|
120
64
|
}
|
|
121
65
|
},
|
|
122
|
-
"then": {
|
|
123
|
-
"required": ["snapshotDigest"]
|
|
124
|
-
}
|
|
66
|
+
"then": { "required": ["snapshotDigest"] }
|
|
125
67
|
}
|
|
126
68
|
]
|
|
127
69
|
},
|
|
128
70
|
"scope": {
|
|
129
71
|
"type": "object",
|
|
130
|
-
"required": ["includePaths", "excludePaths"],
|
|
131
72
|
"properties": {
|
|
132
|
-
"includePaths": {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
},
|
|
138
|
-
"
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
"summary": {
|
|
145
|
-
"type": "string",
|
|
146
|
-
"minLength": 1
|
|
147
|
-
},
|
|
148
|
-
"artifactsReviewed": {
|
|
149
|
-
"$ref": "#/$defs/stringList"
|
|
150
|
-
},
|
|
151
|
-
"runtimeStatus": {
|
|
152
|
-
"type": "string",
|
|
153
|
-
"minLength": 1
|
|
154
|
-
},
|
|
155
|
-
"validationMode": {
|
|
156
|
-
"type": "string",
|
|
157
|
-
"minLength": 1
|
|
158
|
-
},
|
|
159
|
-
"context": {
|
|
160
|
-
"type": "string",
|
|
161
|
-
"minLength": 1
|
|
162
|
-
},
|
|
163
|
-
"limitations": {
|
|
164
|
-
"$ref": "#/$defs/stringList"
|
|
165
|
-
}
|
|
166
|
-
}
|
|
73
|
+
"includePaths": { "type": "array", "items": { "type": "string" } },
|
|
74
|
+
"excludePaths": { "type": "array", "items": { "type": "string" } },
|
|
75
|
+
"summary": { "type": "string", "minLength": 1 },
|
|
76
|
+
"artifactsReviewed": { "$ref": "#/$defs/stringList" },
|
|
77
|
+
"runtimeStatus": { "type": "string", "minLength": 1 },
|
|
78
|
+
"validationMode": { "type": "string", "minLength": 1 },
|
|
79
|
+
"context": { "type": "string", "minLength": 1 },
|
|
80
|
+
"limitations": { "$ref": "#/$defs/stringList" }
|
|
81
|
+
},
|
|
82
|
+
"required": ["includePaths", "excludePaths"]
|
|
167
83
|
},
|
|
168
84
|
"threatModel": {
|
|
169
|
-
"description": "Retained threat-model content. Existing structured models remain supported; Markdown documents preserve their complete original body.",
|
|
170
85
|
"anyOf": [
|
|
171
86
|
{
|
|
172
87
|
"type": "object",
|
|
173
|
-
"required": ["summary"],
|
|
174
88
|
"properties": {
|
|
175
|
-
"summary": {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
},
|
|
179
|
-
"
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
"$ref": "#/$defs/stringList"
|
|
184
|
-
},
|
|
185
|
-
"attackerCapabilities": {
|
|
186
|
-
"$ref": "#/$defs/stringList"
|
|
187
|
-
},
|
|
188
|
-
"securityObjectives": {
|
|
189
|
-
"$ref": "#/$defs/stringList"
|
|
190
|
-
},
|
|
191
|
-
"assumptions": {
|
|
192
|
-
"$ref": "#/$defs/stringList"
|
|
193
|
-
}
|
|
194
|
-
}
|
|
89
|
+
"summary": { "type": "string", "minLength": 1 },
|
|
90
|
+
"assets": { "$ref": "#/$defs/stringList" },
|
|
91
|
+
"trustBoundaries": { "$ref": "#/$defs/stringList" },
|
|
92
|
+
"attackerCapabilities": { "$ref": "#/$defs/stringList" },
|
|
93
|
+
"securityObjectives": { "$ref": "#/$defs/stringList" },
|
|
94
|
+
"assumptions": { "$ref": "#/$defs/stringList" }
|
|
95
|
+
},
|
|
96
|
+
"required": ["summary"]
|
|
195
97
|
},
|
|
196
98
|
{
|
|
197
99
|
"type": "object",
|
|
198
100
|
"properties": {
|
|
199
|
-
"format": {
|
|
200
|
-
"const": "markdown"
|
|
201
|
-
},
|
|
101
|
+
"format": { "const": "markdown" },
|
|
202
102
|
"content": {
|
|
203
103
|
"type": "string",
|
|
204
104
|
"minLength": 1,
|
|
@@ -206,21 +106,14 @@
|
|
|
206
106
|
},
|
|
207
107
|
"scope": {
|
|
208
108
|
"type": "object",
|
|
209
|
-
"description": "The modeled source scope, which may differ from the scan scope. Omit when unknown.",
|
|
210
109
|
"properties": {
|
|
211
|
-
"includePaths": {
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
"excludePaths": {
|
|
215
|
-
"$ref": "#/$defs/stringList"
|
|
216
|
-
},
|
|
217
|
-
"summary": {
|
|
218
|
-
"type": "string",
|
|
219
|
-
"minLength": 1
|
|
220
|
-
}
|
|
110
|
+
"includePaths": { "$ref": "#/$defs/stringList" },
|
|
111
|
+
"excludePaths": { "$ref": "#/$defs/stringList" },
|
|
112
|
+
"summary": { "type": "string", "minLength": 1 }
|
|
221
113
|
},
|
|
222
114
|
"required": ["includePaths"],
|
|
223
|
-
"additionalProperties": true
|
|
115
|
+
"additionalProperties": true,
|
|
116
|
+
"description": "The modeled source scope, which may differ from the scan scope. Omit when unknown."
|
|
224
117
|
},
|
|
225
118
|
"origin": {
|
|
226
119
|
"enum": ["generated", "provided", "reconciled", "recovered"]
|
|
@@ -229,47 +122,49 @@
|
|
|
229
122
|
"required": ["format", "content"],
|
|
230
123
|
"additionalProperties": true
|
|
231
124
|
}
|
|
232
|
-
]
|
|
125
|
+
],
|
|
126
|
+
"description": "Retained threat-model content. Existing structured models remain supported; Markdown documents preserve their complete original body."
|
|
233
127
|
},
|
|
234
128
|
"hardening": {
|
|
235
129
|
"type": "object",
|
|
236
|
-
"required": ["portfolioPath"],
|
|
237
130
|
"properties": {
|
|
238
|
-
"portfolioPath": {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
242
|
-
},
|
|
243
|
-
"coverageRef": {
|
|
244
|
-
"const": "coverage.json"
|
|
245
|
-
},
|
|
246
|
-
"findingsRef": {
|
|
247
|
-
"const": "findings.json"
|
|
131
|
+
"portfolioPath": { "const": "hardening/hardening.md" }
|
|
132
|
+
},
|
|
133
|
+
"required": ["portfolioPath"]
|
|
248
134
|
},
|
|
135
|
+
"coverageRef": { "const": "coverage.json" },
|
|
136
|
+
"findingsRef": { "const": "findings.json" },
|
|
249
137
|
"artifacts": {
|
|
250
|
-
"type": "array",
|
|
251
138
|
"minItems": 1,
|
|
139
|
+
"type": "array",
|
|
252
140
|
"items": {
|
|
253
141
|
"type": "object",
|
|
254
|
-
"required": ["path", "sha256", "mediaType"],
|
|
255
142
|
"properties": {
|
|
256
143
|
"path": {
|
|
257
144
|
"type": "string",
|
|
258
145
|
"minLength": 1,
|
|
259
146
|
"pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\).+$"
|
|
260
147
|
},
|
|
261
|
-
"sha256": {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
"mediaType": {
|
|
266
|
-
"type": "string",
|
|
267
|
-
"minLength": 1
|
|
268
|
-
}
|
|
269
|
-
}
|
|
148
|
+
"sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
|
|
149
|
+
"mediaType": { "type": "string", "minLength": 1 }
|
|
150
|
+
},
|
|
151
|
+
"required": ["path", "sha256", "mediaType"]
|
|
270
152
|
}
|
|
271
153
|
}
|
|
272
154
|
},
|
|
155
|
+
"required": [
|
|
156
|
+
"id",
|
|
157
|
+
"producer",
|
|
158
|
+
"status",
|
|
159
|
+
"startedAt",
|
|
160
|
+
"completedAt",
|
|
161
|
+
"sealedAt",
|
|
162
|
+
"target",
|
|
163
|
+
"scope",
|
|
164
|
+
"coverageRef",
|
|
165
|
+
"findingsRef",
|
|
166
|
+
"artifacts"
|
|
167
|
+
],
|
|
273
168
|
"allOf": [
|
|
274
169
|
{
|
|
275
170
|
"properties": {
|
|
@@ -277,11 +172,7 @@
|
|
|
277
172
|
"contains": {
|
|
278
173
|
"type": "object",
|
|
279
174
|
"required": ["path"],
|
|
280
|
-
"properties": {
|
|
281
|
-
"path": {
|
|
282
|
-
"const": "findings.json"
|
|
283
|
-
}
|
|
284
|
-
}
|
|
175
|
+
"properties": { "path": { "const": "findings.json" } }
|
|
285
176
|
},
|
|
286
177
|
"minContains": 1,
|
|
287
178
|
"maxContains": 1
|
|
@@ -294,11 +185,7 @@
|
|
|
294
185
|
"contains": {
|
|
295
186
|
"type": "object",
|
|
296
187
|
"required": ["path"],
|
|
297
|
-
"properties": {
|
|
298
|
-
"path": {
|
|
299
|
-
"const": "coverage.json"
|
|
300
|
-
}
|
|
301
|
-
}
|
|
188
|
+
"properties": { "path": { "const": "coverage.json" } }
|
|
302
189
|
},
|
|
303
190
|
"minContains": 1,
|
|
304
191
|
"maxContains": 1
|
|
@@ -308,13 +195,11 @@
|
|
|
308
195
|
]
|
|
309
196
|
}
|
|
310
197
|
},
|
|
198
|
+
"required": ["documentType", "schemaVersion", "scan"],
|
|
311
199
|
"$defs": {
|
|
312
200
|
"stringList": {
|
|
313
201
|
"type": "array",
|
|
314
|
-
"items": {
|
|
315
|
-
"type": "string",
|
|
316
|
-
"minLength": 1
|
|
317
|
-
}
|
|
202
|
+
"items": { "type": "string", "minLength": 1 }
|
|
318
203
|
}
|
|
319
204
|
}
|
|
320
205
|
}
|
|
@@ -415,7 +415,9 @@ def _require_str(payload: dict[str, Any], key: str, context: str) -> str:
|
|
|
415
415
|
return value
|
|
416
416
|
|
|
417
417
|
|
|
418
|
-
def _require_safe_relative_path(value:
|
|
418
|
+
def _require_safe_relative_path(value: object, context: str, *, allow_dot: bool = False) -> str:
|
|
419
|
+
if not isinstance(value, str) or not value:
|
|
420
|
+
raise ContractError(f"{context}: expected a safe repository-relative POSIX path")
|
|
419
421
|
try:
|
|
420
422
|
value.encode("utf-8")
|
|
421
423
|
except UnicodeEncodeError as exc:
|
|
@@ -423,8 +425,7 @@ def _require_safe_relative_path(value: str, context: str, *, allow_dot: bool = F
|
|
|
423
425
|
path = PurePosixPath(value)
|
|
424
426
|
normalized = path.as_posix()
|
|
425
427
|
if (
|
|
426
|
-
not
|
|
427
|
-
or (normalized == "." and not allow_dot)
|
|
428
|
+
(normalized == "." and not allow_dot)
|
|
428
429
|
or (len(value) >= 2 and value[0].isalpha() and value[1] == ":")
|
|
429
430
|
or "\\" in value
|
|
430
431
|
or "\0" in value
|
|
@@ -438,7 +439,7 @@ def _require_safe_relative_path(value: str, context: str, *, allow_dot: bool = F
|
|
|
438
439
|
|
|
439
440
|
def _require_portable_relative_path(value: str, context: str, *, allow_dot: bool = False) -> str:
|
|
440
441
|
normalized = _require_safe_relative_path(value, context, allow_dot=allow_dot)
|
|
441
|
-
if any(_windows_unsafe_path_component(part) for part in value.split("/")):
|
|
442
|
+
if not value.strip() or any(_windows_unsafe_path_component(part) for part in value.split("/")):
|
|
442
443
|
raise ContractError(f"{context}: expected a safe scan-relative POSIX path")
|
|
443
444
|
return normalized
|
|
444
445
|
|
|
@@ -961,7 +962,7 @@ def _stable_id(prefix: str, *parts: str) -> str:
|
|
|
961
962
|
|
|
962
963
|
|
|
963
964
|
def _validate_location(location: dict[str, Any], context: str) -> None:
|
|
964
|
-
_require_safe_relative_path(
|
|
965
|
+
_require_safe_relative_path(location.get("path"), f"{context}.path")
|
|
965
966
|
start = location.get("startLine")
|
|
966
967
|
end = location.get("endLine", start)
|
|
967
968
|
if not isinstance(start, int) or start < 1:
|
|
@@ -1593,7 +1594,7 @@ def _validate_finding(finding: dict[str, Any], context: str) -> None:
|
|
|
1593
1594
|
_require_str(evidence, "code", evidence_context)
|
|
1594
1595
|
if evidence_key == "codeEvidence":
|
|
1595
1596
|
_require_safe_relative_path(
|
|
1596
|
-
|
|
1597
|
+
evidence.get("path"),
|
|
1597
1598
|
f"{evidence_context}.path",
|
|
1598
1599
|
)
|
|
1599
1600
|
|
|
@@ -3,14 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
This script stays deliberately model-free:
|
|
5
5
|
|
|
6
|
-
- `make-repo-
|
|
7
|
-
JSONL candidate worklist that ranking subagents consume.
|
|
6
|
+
- `make-repo-scope-input` lists every explicitly scoped repository file.
|
|
8
7
|
- `make-diff-rank-input` creates the deterministic diff-scoped JSONL candidate
|
|
9
8
|
worklist from Git changed paths. It supports committed revision diffs and
|
|
10
9
|
local working-tree patches.
|
|
11
10
|
|
|
12
11
|
Candidate selection uses repository scope, native tool ignore rules, and binary detection,
|
|
13
|
-
not filename or directory classifications.
|
|
12
|
+
not filename or directory classifications. Diff inputs use bounded source previews.
|
|
14
13
|
"""
|
|
15
14
|
|
|
16
15
|
from __future__ import annotations
|
|
@@ -41,29 +40,6 @@ def parse_args() -> argparse.Namespace:
|
|
|
41
40
|
parser = argparse.ArgumentParser(description="Codex Security scan worklist helper.")
|
|
42
41
|
subparsers = parser.add_subparsers(dest="command", required=True)
|
|
43
42
|
|
|
44
|
-
make = subparsers.add_parser(
|
|
45
|
-
"make-repo-rank-input",
|
|
46
|
-
help="Create rank_input.jsonl for subagent-based file ranking.",
|
|
47
|
-
)
|
|
48
|
-
make.add_argument("--repo", required=True, help="Repository root.")
|
|
49
|
-
make.add_argument(
|
|
50
|
-
"--scope",
|
|
51
|
-
default=".",
|
|
52
|
-
help="Path within the repository to scan. Defaults to the repository root.",
|
|
53
|
-
)
|
|
54
|
-
make.add_argument(
|
|
55
|
-
"--scopes-file",
|
|
56
|
-
help="JSON array of repository-relative files and directories to scan together.",
|
|
57
|
-
)
|
|
58
|
-
make.add_argument("--out", required=True, help="Output rank_input.jsonl path.")
|
|
59
|
-
make.add_argument("--area", default="", help="Area label. Defaults to scope.")
|
|
60
|
-
make.add_argument(
|
|
61
|
-
"--preview-bytes",
|
|
62
|
-
type=int,
|
|
63
|
-
default=DEFAULT_PREVIEW_BYTES,
|
|
64
|
-
help=f"Maximum UTF-8 bytes in each preview. Defaults to {DEFAULT_PREVIEW_BYTES}.",
|
|
65
|
-
)
|
|
66
|
-
|
|
67
43
|
scoped = subparsers.add_parser(
|
|
68
44
|
"make-repo-scope-input",
|
|
69
45
|
help="List every explicitly scoped file without ranking or reading its contents.",
|
|
@@ -90,7 +66,7 @@ def parse_args() -> argparse.Namespace:
|
|
|
90
66
|
)
|
|
91
67
|
diff.add_argument("--head", default="HEAD", help="Git diff head revision.")
|
|
92
68
|
diff.add_argument("--out", required=True, help="Output rank_input.jsonl path.")
|
|
93
|
-
diff.add_argument("--area", default="diff", help="Area label for
|
|
69
|
+
diff.add_argument("--area", default="diff", help="Area label for changed-file rows.")
|
|
94
70
|
diff.add_argument(
|
|
95
71
|
"--preview-bytes",
|
|
96
72
|
type=int,
|
|
@@ -101,39 +77,32 @@ def parse_args() -> argparse.Namespace:
|
|
|
101
77
|
return parser.parse_args()
|
|
102
78
|
|
|
103
79
|
|
|
104
|
-
def resolve_scope(
|
|
105
|
-
|
|
106
|
-
scope: str,
|
|
107
|
-
*,
|
|
108
|
-
expand_user: bool = True,
|
|
109
|
-
reject_symlinks: bool = False,
|
|
110
|
-
) -> Path:
|
|
111
|
-
scope_path = Path(scope).expanduser() if expand_user else Path(scope)
|
|
80
|
+
def resolve_scope(repo: Path, scope: str) -> Path:
|
|
81
|
+
scope_path = Path(scope)
|
|
112
82
|
stream = windows_stream_component(scope_path)
|
|
113
83
|
if stream is not None:
|
|
114
84
|
raise SystemExit(f"Scope must not use an NTFS alternate data stream: {stream}")
|
|
115
85
|
if not scope_path.is_absolute():
|
|
116
86
|
scope_path = repo / scope_path
|
|
117
|
-
|
|
118
|
-
|
|
87
|
+
repository = repo.resolve()
|
|
88
|
+
try:
|
|
89
|
+
relative = scope_path.relative_to(repository)
|
|
90
|
+
except ValueError as exc:
|
|
91
|
+
raise SystemExit(f"Scope must be inside repo: {scope_path}") from exc
|
|
92
|
+
ancestor = repository
|
|
93
|
+
for part in relative.parts:
|
|
94
|
+
if part == "..":
|
|
95
|
+
if ancestor == repository:
|
|
96
|
+
raise SystemExit(f"Scope must be inside repo: {scope_path}")
|
|
97
|
+
ancestor = ancestor.parent
|
|
98
|
+
continue
|
|
99
|
+
ancestor /= part
|
|
119
100
|
try:
|
|
120
|
-
|
|
121
|
-
except
|
|
122
|
-
raise SystemExit(f"Scope
|
|
123
|
-
ancestor
|
|
124
|
-
|
|
125
|
-
if part == "..":
|
|
126
|
-
if ancestor == repository:
|
|
127
|
-
raise SystemExit(f"Scope must be inside repo: {scope_path}")
|
|
128
|
-
ancestor = ancestor.parent
|
|
129
|
-
continue
|
|
130
|
-
ancestor /= part
|
|
131
|
-
try:
|
|
132
|
-
metadata = ancestor.stat(follow_symlinks=False)
|
|
133
|
-
except OSError as exc:
|
|
134
|
-
raise SystemExit(f"Scope path not found: {ancestor}") from exc
|
|
135
|
-
if ancestor.is_symlink() or getattr(metadata, "st_reparse_tag", 0) & 0x20000000:
|
|
136
|
-
raise SystemExit(f"Requested scope must not contain symbolic links: {ancestor}")
|
|
101
|
+
metadata = ancestor.stat(follow_symlinks=False)
|
|
102
|
+
except OSError as exc:
|
|
103
|
+
raise SystemExit(f"Scope path not found: {ancestor}") from exc
|
|
104
|
+
if ancestor.is_symlink() or getattr(metadata, "st_reparse_tag", 0) & 0x20000000:
|
|
105
|
+
raise SystemExit(f"Requested scope must not contain symbolic links: {ancestor}")
|
|
137
106
|
scope_path = scope_path.resolve()
|
|
138
107
|
repo_resolved = repo.resolve()
|
|
139
108
|
try:
|
|
@@ -221,54 +190,6 @@ def scope_candidates(repo: Path, scope_path: Path) -> Iterable[Path]:
|
|
|
221
190
|
return (repo / os.fsdecode(path) for path in result.stdout.split(b"\0") if path)
|
|
222
191
|
|
|
223
192
|
|
|
224
|
-
def make_repo_rank_input(args: argparse.Namespace) -> None:
|
|
225
|
-
repo = Path(args.repo).expanduser().resolve()
|
|
226
|
-
if not repo.is_dir():
|
|
227
|
-
raise SystemExit(f"Repo path not found: {repo}")
|
|
228
|
-
scopes = [args.scope]
|
|
229
|
-
explicit_scopes = args.scopes_file is not None
|
|
230
|
-
if explicit_scopes:
|
|
231
|
-
scopes = load_scopes_file(Path(args.scopes_file).expanduser())
|
|
232
|
-
|
|
233
|
-
resolved_scopes = [
|
|
234
|
-
resolve_scope(repo, scope, expand_user=not explicit_scopes) for scope in scopes
|
|
235
|
-
]
|
|
236
|
-
directly_requested_files = {
|
|
237
|
-
scope_abs for scope_abs in resolved_scopes if explicit_scopes and scope_abs.is_file()
|
|
238
|
-
}
|
|
239
|
-
rows_by_path: dict[str, JsonRow] = {}
|
|
240
|
-
for scope_abs in resolved_scopes:
|
|
241
|
-
scope_rel = scope_abs.relative_to(repo)
|
|
242
|
-
area = args.area or scope_rel.as_posix()
|
|
243
|
-
candidates = scope_candidates(repo, scope_abs)
|
|
244
|
-
for path in candidates:
|
|
245
|
-
try:
|
|
246
|
-
if path.is_symlink() or not path.is_file():
|
|
247
|
-
continue
|
|
248
|
-
path.resolve(strict=True).relative_to(repo)
|
|
249
|
-
except (OSError, ValueError):
|
|
250
|
-
continue
|
|
251
|
-
rel = path.relative_to(repo)
|
|
252
|
-
directly_requested = path in directly_requested_files
|
|
253
|
-
if ".git" in rel.parts:
|
|
254
|
-
continue
|
|
255
|
-
|
|
256
|
-
preview, is_binary = preview_for(path, args.preview_bytes)
|
|
257
|
-
if is_binary or is_binary_file(path):
|
|
258
|
-
if not directly_requested:
|
|
259
|
-
continue
|
|
260
|
-
preview = ""
|
|
261
|
-
rows_by_path.setdefault(
|
|
262
|
-
rel.as_posix(),
|
|
263
|
-
{"path": rel.as_posix(), "area": area, "preview": preview},
|
|
264
|
-
)
|
|
265
|
-
|
|
266
|
-
rows = sorted(rows_by_path.values(), key=lambda row: str(row["path"]))
|
|
267
|
-
output = Path(args.out).expanduser()
|
|
268
|
-
write_jsonl(output, rows)
|
|
269
|
-
print(f"Wrote {len(rows)} rows to {output}")
|
|
270
|
-
|
|
271
|
-
|
|
272
193
|
def make_repo_scope_input(args: argparse.Namespace) -> None:
|
|
273
194
|
repo = Path(args.repo).expanduser().resolve()
|
|
274
195
|
if not repo.is_dir():
|
|
@@ -277,7 +198,7 @@ def make_repo_scope_input(args: argparse.Namespace) -> None:
|
|
|
277
198
|
scopes = load_scopes_file(Path(args.scopes_file).expanduser())
|
|
278
199
|
rows_by_path: dict[str, JsonRow] = {}
|
|
279
200
|
for scope in scopes:
|
|
280
|
-
scope_path = resolve_scope(repo, scope
|
|
201
|
+
scope_path = resolve_scope(repo, scope)
|
|
281
202
|
candidates = scope_candidates(repo, scope_path)
|
|
282
203
|
for path in candidates:
|
|
283
204
|
try:
|
|
@@ -410,9 +331,7 @@ def make_diff_rank_input(args: argparse.Namespace) -> None:
|
|
|
410
331
|
|
|
411
332
|
def main() -> None:
|
|
412
333
|
args = parse_args()
|
|
413
|
-
if args.command == "make-repo-
|
|
414
|
-
make_repo_rank_input(args)
|
|
415
|
-
elif args.command == "make-repo-scope-input":
|
|
334
|
+
if args.command == "make-repo-scope-input":
|
|
416
335
|
make_repo_scope_input(args)
|
|
417
336
|
elif args.command == "make-diff-rank-input":
|
|
418
337
|
make_diff_rank_input(args)
|