@openai/codex-security 0.4.0 → 0.5.1
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 +52 -9
- package/_bundled_plugin/.mcp.json +1 -0
- 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 +60 -9
- 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/core-scan.md +2 -0
- package/_bundled_plugin/references/final-report.md +5 -1
- package/_bundled_plugin/references/investigation-time-budget.md +11 -0
- package/_bundled_plugin/references/sarif-adapter.md +1 -0
- package/_bundled_plugin/references/scan-prologue.md +2 -6
- package/_bundled_plugin/references/scan-runtime.md +15 -0
- package/_bundled_plugin/references/threat-model.md +2 -0
- package/_bundled_plugin/schemas/definitions/artifact-common.schema.json +6 -2
- package/_bundled_plugin/scripts/deep_scan_workbench.py +7 -0
- package/_bundled_plugin/scripts/finalize_scan_contract.py +92 -44
- package/_bundled_plugin/scripts/finding_preview.py +5 -3
- package/_bundled_plugin/scripts/generate_in_scope_files.py +6 -6
- package/_bundled_plugin/scripts/generate_rank_input.py +13 -6
- package/_bundled_plugin/scripts/launch_codex_security_mcp +39 -4
- package/_bundled_plugin/scripts/report_projection.py +2 -1
- package/_bundled_plugin/scripts/snapshot_sqlite.py +7 -0
- package/_bundled_plugin/scripts/threat_model_projection.py +1 -3
- package/_bundled_plugin/scripts/windows_scan_local_files.py +43 -1
- package/_bundled_plugin/scripts/workbench/saved_coverage.py +234 -0
- package/_bundled_plugin/scripts/workbench_cli.py +5 -10
- package/_bundled_plugin/scripts/workbench_constants.py +4 -0
- package/_bundled_plugin/scripts/workbench_db.py +68 -39
- package/_bundled_plugin/scripts/workbench_native_indexes.py +10 -7
- package/_bundled_plugin/scripts/workbench_progress.py +0 -50
- package/_bundled_plugin/scripts/workbench_publication.py +4 -3
- package/_bundled_plugin/scripts/workbench_remediation.py +5 -1
- package/_bundled_plugin/scripts/workbench_saved_results.py +542 -148
- package/_bundled_plugin/scripts/workbench_scan_history.py +82 -80
- package/_bundled_plugin/scripts/workbench_scan_start.py +12 -4
- package/_bundled_plugin/scripts/workbench_scan_usage.py +246 -38
- package/_bundled_plugin/scripts/workbench_schema.py +1 -1
- package/_bundled_plugin/scripts/workbench_source_excerpt.py +74 -51
- package/_bundled_plugin/scripts/workbench_source_scopes.py +388 -0
- package/_bundled_plugin/scripts/workbench_target.py +28 -12
- package/_bundled_plugin/scripts/workbench_validation.py +52 -13
- package/_bundled_plugin/shared/workbench-history-repairs.json +19 -0
- package/_bundled_plugin/shared/workbench-migrations.json +15 -0
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +1 -1
- package/_bundled_plugin/skills/security-diff-scan/SKILL.md +4 -2
- package/_bundled_plugin/skills/security-scan/SKILL.md +3 -1
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +2 -2
- package/dist/api.d.ts +4 -3
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +215 -93
- package/dist/api.js.map +1 -1
- package/dist/artifact-export.d.ts +2 -1
- package/dist/artifact-export.d.ts.map +1 -1
- package/dist/artifact-export.js +38 -23
- package/dist/artifact-export.js.map +1 -1
- package/dist/classify-scan-severity.d.ts.map +1 -1
- package/dist/classify-scan-severity.js +16 -18
- package/dist/classify-scan-severity.js.map +1 -1
- package/dist/classify-severity-records.d.ts +76 -0
- package/dist/classify-severity-records.d.ts.map +1 -0
- package/dist/classify-severity-records.js +141 -0
- package/dist/classify-severity-records.js.map +1 -0
- package/dist/classify-severity.d.ts +1 -23
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js +3 -24
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli-daybreak.d.ts +5 -0
- package/dist/cli-daybreak.d.ts.map +1 -0
- package/dist/cli-daybreak.js +89 -0
- package/dist/cli-daybreak.js.map +1 -0
- package/dist/cli-help.d.ts.map +1 -1
- package/dist/cli-help.js +2 -0
- package/dist/cli-help.js.map +1 -1
- package/dist/cli.d.ts +9 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +957 -738
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.js +1 -1
- package/dist/cloud-publish.js.map +1 -1
- package/dist/codeowners.js +2 -2
- package/dist/codeowners.js.map +1 -1
- package/dist/codex-sdk-environment.js +1 -1
- package/dist/codex-sdk-environment.js.map +1 -1
- package/dist/component-plan.d.ts.map +1 -1
- package/dist/component-plan.js +3 -2
- package/dist/component-plan.js.map +1 -1
- package/dist/component-scan.js +2 -2
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts +12 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +15 -5
- package/dist/config.js.map +1 -1
- package/dist/contract.d.ts +5 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +65 -17
- package/dist/contract.js.map +1 -1
- package/dist/cost-model.d.ts.map +1 -1
- package/dist/cost-model.js +7 -2
- package/dist/cost-model.js.map +1 -1
- package/dist/cost.d.ts +2 -1
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +17 -8
- package/dist/cost.js.map +1 -1
- package/dist/custom-validation-prompt.js +3 -3
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/custom-validation.d.ts.map +1 -1
- package/dist/custom-validation.js +2 -5
- package/dist/custom-validation.js.map +1 -1
- package/dist/deduplication/codex-review.d.ts.map +1 -1
- package/dist/deduplication/codex-review.js +8 -6
- package/dist/deduplication/codex-review.js.map +1 -1
- package/dist/deduplication/deduplication-prompts.d.ts +1 -1
- package/dist/deduplication/deduplication-prompts.d.ts.map +1 -1
- package/dist/deduplication/deduplication-prompts.js +2 -2
- package/dist/deduplication/deduplication-prompts.js.map +1 -1
- package/dist/deduplication/local.d.ts.map +1 -1
- package/dist/deduplication/local.js +5 -2
- package/dist/deduplication/local.js.map +1 -1
- package/dist/deduplication/records.js +1 -1
- package/dist/deduplication/records.js.map +1 -1
- package/dist/deduplication/retry.d.ts.map +1 -1
- package/dist/deduplication/retry.js +5 -0
- package/dist/deduplication/retry.js.map +1 -1
- package/dist/deduplication/scan.d.ts.map +1 -1
- package/dist/deduplication/scan.js +15 -10
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/deep-config.d.ts +4 -1
- package/dist/deep-config.d.ts.map +1 -1
- package/dist/deep-config.js +21 -1
- package/dist/deep-config.js.map +1 -1
- package/dist/deep-scan.d.ts +6 -0
- package/dist/deep-scan.d.ts.map +1 -1
- package/dist/deep-scan.js +8 -6
- package/dist/deep-scan.js.map +1 -1
- package/dist/findings-import.d.ts +1 -1
- package/dist/findings-import.d.ts.map +1 -1
- package/dist/findings-import.js +26 -6
- package/dist/findings-import.js.map +1 -1
- package/dist/git-remote.d.ts +10 -0
- package/dist/git-remote.d.ts.map +1 -0
- package/dist/git-remote.js +24 -0
- package/dist/git-remote.js.map +1 -0
- package/dist/github.d.ts.map +1 -1
- package/dist/github.js +5 -7
- package/dist/github.js.map +1 -1
- package/dist/host-protocol.d.ts +1 -0
- package/dist/host-protocol.d.ts.map +1 -1
- package/dist/host-protocol.js +2 -2
- package/dist/host-protocol.js.map +1 -1
- package/dist/host-records-protocol.d.ts +15 -0
- package/dist/host-records-protocol.d.ts.map +1 -0
- package/dist/host-records-protocol.js +15 -0
- package/dist/host-records-protocol.js.map +1 -0
- package/dist/hosted-remediation-protocol.d.ts +5 -0
- package/dist/hosted-remediation-protocol.d.ts.map +1 -0
- package/dist/hosted-remediation-protocol.js +26 -0
- package/dist/hosted-remediation-protocol.js.map +1 -0
- package/dist/hosted-remediation.d.ts +89 -0
- package/dist/hosted-remediation.d.ts.map +1 -0
- package/dist/hosted-remediation.js +122 -0
- package/dist/hosted-remediation.js.map +1 -0
- package/dist/hosted-scan.d.ts +1 -6
- package/dist/hosted-scan.d.ts.map +1 -1
- package/dist/hosted-scan.js +2 -2
- package/dist/hosted-scan.js.map +1 -1
- package/dist/import-scan.d.ts +1 -0
- package/dist/import-scan.d.ts.map +1 -1
- package/dist/import-scan.js +5 -1
- package/dist/import-scan.js.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/knowledge-base.d.ts.map +1 -1
- package/dist/knowledge-base.js +87 -7
- package/dist/knowledge-base.js.map +1 -1
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +65 -29
- package/dist/multiscan.js.map +1 -1
- package/dist/patch-publication.d.ts +26 -0
- package/dist/patch-publication.d.ts.map +1 -0
- package/dist/patch-publication.js +105 -0
- package/dist/patch-publication.js.map +1 -0
- package/dist/patch-tui.d.ts.map +1 -1
- package/dist/patch-tui.js +4 -1
- package/dist/patch-tui.js.map +1 -1
- package/dist/project-config-schema.d.ts +2 -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 +29 -15
- package/dist/project-config.js.map +1 -1
- package/dist/publication.d.ts.map +1 -1
- package/dist/publication.js +135 -19
- package/dist/publication.js.map +1 -1
- package/dist/publish.d.ts +2 -0
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +48 -25
- package/dist/publish.js.map +1 -1
- package/dist/remediation.d.ts +63 -0
- package/dist/remediation.d.ts.map +1 -0
- package/dist/remediation.js +110 -0
- package/dist/remediation.js.map +1 -0
- package/dist/request-metadata.d.ts +17 -7
- package/dist/request-metadata.d.ts.map +1 -1
- package/dist/request-metadata.js +43 -8
- package/dist/request-metadata.js.map +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +104 -36
- package/dist/runtime.js.map +1 -1
- package/dist/saved-scan-bootstrap.d.ts +1 -0
- package/dist/saved-scan-bootstrap.d.ts.map +1 -1
- package/dist/saved-scan-bootstrap.js +16 -4
- package/dist/saved-scan-bootstrap.js.map +1 -1
- package/dist/scan-activity.js +8 -8
- package/dist/scan-activity.js.map +1 -1
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +15 -9
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +12 -6
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-executor.d.ts +5 -1
- package/dist/scan-executor.d.ts.map +1 -1
- package/dist/scan-executor.js +9 -8
- package/dist/scan-executor.js.map +1 -1
- package/dist/{deep-progress.d.ts → scan-progress.d.ts} +15 -7
- package/dist/scan-progress.d.ts.map +1 -0
- package/dist/scan-progress.js +138 -0
- package/dist/scan-progress.js.map +1 -0
- package/dist/scan-settings.d.ts +1 -0
- package/dist/scan-settings.d.ts.map +1 -1
- package/dist/scan-settings.js +7 -1
- package/dist/scan-settings.js.map +1 -1
- package/dist/scan-time-budget.d.ts +9 -0
- package/dist/scan-time-budget.d.ts.map +1 -0
- package/dist/scan-time-budget.js +16 -0
- package/dist/scan-time-budget.js.map +1 -0
- package/dist/security-policy.js +1 -1
- package/dist/security-policy.js.map +1 -1
- package/dist/server/embeddings.d.ts.map +1 -1
- package/dist/server/embeddings.js +4 -0
- package/dist/server/embeddings.js.map +1 -1
- package/dist/server/sqlite-store.d.ts.map +1 -1
- package/dist/server/sqlite-store.js +14 -2
- package/dist/server/sqlite-store.js.map +1 -1
- package/dist/severity-review.d.ts +29 -0
- package/dist/severity-review.d.ts.map +1 -0
- package/dist/severity-review.js +47 -0
- package/dist/severity-review.js.map +1 -0
- package/dist/severity-store.js +4 -1
- package/dist/severity-store.js.map +1 -1
- package/dist/timestamps.d.ts +3 -0
- package/dist/timestamps.d.ts.map +1 -0
- package/dist/timestamps.js +14 -0
- package/dist/timestamps.js.map +1 -0
- package/dist/validation-records.d.ts +38 -0
- package/dist/validation-records.d.ts.map +1 -0
- package/dist/validation-records.js +76 -0
- package/dist/validation-records.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +17 -4
- package/dist/version.js.map +1 -1
- package/dist/workbench-arguments.d.ts.map +1 -1
- package/dist/workbench-arguments.js +9 -3
- package/dist/workbench-arguments.js.map +1 -1
- package/dist/worker-progress.d.ts +13 -7
- package/dist/worker-progress.d.ts.map +1 -1
- package/dist/worker-progress.js +12 -44
- package/dist/worker-progress.js.map +1 -1
- package/docs/classify-severity-records.md +89 -0
- package/docs/cli.md +352 -45
- package/docs/findings-service.md +7 -2
- package/docs/hosted-remediation.md +117 -0
- package/docs/hosted-scans.md +8 -3
- package/docs/validate-records.md +69 -0
- package/package.json +13 -10
- package/schemas/project-config.schema.json +7 -1
- package/_bundled_plugin/preflight/capability-profiles.toml +0 -76
- package/_bundled_plugin/references/config-preflight.md +0 -93
- package/_bundled_plugin/references/desktop-config-preflight.md +0 -11
- package/_bundled_plugin/scripts/config_preflight.py +0 -911
- package/dist/deep-progress.d.ts.map +0 -1
- package/dist/deep-progress.js +0 -92
- package/dist/deep-progress.js.map +0 -1
|
@@ -19,8 +19,9 @@ from report_projection import SEVERITY_ORDER
|
|
|
19
19
|
from workbench_constants import ARTIFACTS, FINDINGS_PAGE_MAX
|
|
20
20
|
from workbench_scan_start import scan_target_identity
|
|
21
21
|
from workbench_scan_usage import stored_scan_cost_fields
|
|
22
|
+
from workbench_source_scopes import public_scan_recipe
|
|
22
23
|
from workbench_target import git_output, require_scan_target_identity
|
|
23
|
-
from workbench_validation import
|
|
24
|
+
from workbench_validation import timestamp_key
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
def rename_scan(connection: sqlite3.Connection, scan: sqlite3.Row, name: str) -> dict[str, Any]:
|
|
@@ -37,7 +38,7 @@ def scan_recipe(scan: sqlite3.Row) -> dict[str, Any]:
|
|
|
37
38
|
raise SystemExit("This scan does not have a saved launch recipe.")
|
|
38
39
|
return {
|
|
39
40
|
"parentScanId": scan["parent_scan_id"],
|
|
40
|
-
"recipe":
|
|
41
|
+
"recipe": public_scan_recipe(scan),
|
|
41
42
|
"scanId": scan["id"],
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -201,6 +202,69 @@ def _repository_origin(target: Path) -> tuple[str, str] | None:
|
|
|
201
202
|
return (host.lower(), path) if host and path else None
|
|
202
203
|
|
|
203
204
|
|
|
205
|
+
SCAN_SUMMARY_QUERY = """
|
|
206
|
+
SELECT
|
|
207
|
+
scans.*,
|
|
208
|
+
progress.reportable_findings_count,
|
|
209
|
+
progress.scope_file_count,
|
|
210
|
+
progress.review_items_completed,
|
|
211
|
+
progress.review_items_total,
|
|
212
|
+
progress.updated_at AS progress_updated_at,
|
|
213
|
+
(
|
|
214
|
+
SELECT COUNT(*)
|
|
215
|
+
FROM finding_occurrences AS occurrences
|
|
216
|
+
WHERE occurrences.scan_id = scans.id
|
|
217
|
+
) AS finding_count
|
|
218
|
+
FROM scans
|
|
219
|
+
JOIN scan_progress AS progress ON progress.scan_id = scans.id
|
|
220
|
+
"""
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
def scan_summary(row: sqlite3.Row) -> dict[str, Any]:
|
|
224
|
+
return {
|
|
225
|
+
"completedAt": row["completed_at"],
|
|
226
|
+
"continuationThreadId": row["continuation_thread_id"],
|
|
227
|
+
**stored_scan_cost_fields(row["cost_json"]),
|
|
228
|
+
"findingCount": row["finding_count"],
|
|
229
|
+
"handoffStatus": row["handoff_status"],
|
|
230
|
+
"mode": row["mode"],
|
|
231
|
+
"model": row["model"],
|
|
232
|
+
"name": row["name"],
|
|
233
|
+
"parentScanId": row["parent_scan_id"],
|
|
234
|
+
"progress": {
|
|
235
|
+
"candidates": {"reportable": row["reportable_findings_count"]},
|
|
236
|
+
"coverage": {
|
|
237
|
+
"closedRows": row["review_items_completed"],
|
|
238
|
+
"filesTotal": row["scope_file_count"],
|
|
239
|
+
"worklistRows": row["review_items_total"],
|
|
240
|
+
},
|
|
241
|
+
"phase": row["phase"],
|
|
242
|
+
"status": "canceled" if row["canceled_at"] else row["status"],
|
|
243
|
+
"updatedAt": row["progress_updated_at"],
|
|
244
|
+
},
|
|
245
|
+
"recipeAvailable": row["recipe_json"] is not None,
|
|
246
|
+
"reasoningEffort": row["reasoning_effort"],
|
|
247
|
+
"scanDir": row["scan_dir"],
|
|
248
|
+
"scanId": row["id"],
|
|
249
|
+
"scope": row["scope"],
|
|
250
|
+
"startedAt": row["started_at"],
|
|
251
|
+
"targetId": row["target_id"],
|
|
252
|
+
"targetPath": row["target_path"],
|
|
253
|
+
"targetRevision": row["target_revision"],
|
|
254
|
+
"targetSummary": row["target_summary"],
|
|
255
|
+
"updatedAt": max(
|
|
256
|
+
row["updated_at"],
|
|
257
|
+
row["progress_updated_at"],
|
|
258
|
+
key=lambda value: (timestamp_key(value), value),
|
|
259
|
+
),
|
|
260
|
+
**(
|
|
261
|
+
{"warnings": json.loads(row["completion_warnings_json"])}
|
|
262
|
+
if row["completion_warnings_json"] != "[]"
|
|
263
|
+
else {}
|
|
264
|
+
),
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
|
|
204
268
|
def list_scans(
|
|
205
269
|
connection: sqlite3.Connection, args: argparse.Namespace | None = None
|
|
206
270
|
) -> dict[str, Any]:
|
|
@@ -280,20 +344,7 @@ def list_scans(
|
|
|
280
344
|
values.extend((limit + 1, args.offset))
|
|
281
345
|
rows = connection.execute(
|
|
282
346
|
f"""
|
|
283
|
-
|
|
284
|
-
scans.*,
|
|
285
|
-
progress.reportable_findings_count,
|
|
286
|
-
progress.scope_file_count,
|
|
287
|
-
progress.review_items_completed,
|
|
288
|
-
progress.review_items_total,
|
|
289
|
-
progress.updated_at AS progress_updated_at,
|
|
290
|
-
(
|
|
291
|
-
SELECT COUNT(*)
|
|
292
|
-
FROM finding_occurrences AS occurrences
|
|
293
|
-
WHERE occurrences.scan_id = scans.id
|
|
294
|
-
) AS finding_count
|
|
295
|
-
FROM scans
|
|
296
|
-
JOIN scan_progress AS progress ON progress.scan_id = scans.id
|
|
347
|
+
{SCAN_SUMMARY_QUERY}
|
|
297
348
|
{where}
|
|
298
349
|
ORDER BY
|
|
299
350
|
CASE WHEN scans.status = 'running' AND scans.canceled_at IS NULL THEN 0 ELSE 1 END,
|
|
@@ -304,53 +355,7 @@ def list_scans(
|
|
|
304
355
|
""",
|
|
305
356
|
values,
|
|
306
357
|
).fetchall()
|
|
307
|
-
result = {
|
|
308
|
-
"scans": [
|
|
309
|
-
{
|
|
310
|
-
"completedAt": row["completed_at"],
|
|
311
|
-
"continuationThreadId": row["continuation_thread_id"],
|
|
312
|
-
**stored_scan_cost_fields(row["cost_json"]),
|
|
313
|
-
"findingCount": row["finding_count"],
|
|
314
|
-
"handoffStatus": row["handoff_status"],
|
|
315
|
-
"mode": row["mode"],
|
|
316
|
-
"model": row["model"],
|
|
317
|
-
"name": row["name"],
|
|
318
|
-
"parentScanId": row["parent_scan_id"],
|
|
319
|
-
"progress": {
|
|
320
|
-
"candidates": {"reportable": row["reportable_findings_count"]},
|
|
321
|
-
"coverage": {
|
|
322
|
-
"closedRows": row["review_items_completed"],
|
|
323
|
-
"filesTotal": row["scope_file_count"],
|
|
324
|
-
"worklistRows": row["review_items_total"],
|
|
325
|
-
},
|
|
326
|
-
"phase": row["phase"],
|
|
327
|
-
"status": "canceled" if row["canceled_at"] else row["status"],
|
|
328
|
-
"updatedAt": row["progress_updated_at"],
|
|
329
|
-
},
|
|
330
|
-
"recipeAvailable": row["recipe_json"] is not None,
|
|
331
|
-
"reasoningEffort": row["reasoning_effort"],
|
|
332
|
-
"scanDir": row["scan_dir"],
|
|
333
|
-
"scanId": row["id"],
|
|
334
|
-
"scope": row["scope"],
|
|
335
|
-
"startedAt": row["started_at"],
|
|
336
|
-
"targetId": row["target_id"],
|
|
337
|
-
"targetPath": row["target_path"],
|
|
338
|
-
"targetRevision": row["target_revision"],
|
|
339
|
-
"targetSummary": row["target_summary"],
|
|
340
|
-
"updatedAt": max(
|
|
341
|
-
row["updated_at"],
|
|
342
|
-
row["progress_updated_at"],
|
|
343
|
-
key=lambda value: (timestamp_key(value), value),
|
|
344
|
-
),
|
|
345
|
-
**(
|
|
346
|
-
{"warnings": json.loads(row["completion_warnings_json"])}
|
|
347
|
-
if row["completion_warnings_json"] != "[]"
|
|
348
|
-
else {}
|
|
349
|
-
),
|
|
350
|
-
}
|
|
351
|
-
for row in rows[:limit]
|
|
352
|
-
]
|
|
353
|
-
}
|
|
358
|
+
result = {"scans": [scan_summary(row) for row in rows[:limit]]}
|
|
354
359
|
if limit is not None:
|
|
355
360
|
result.update(
|
|
356
361
|
{
|
|
@@ -379,19 +384,19 @@ def list_unmatched_scan_pairs(
|
|
|
379
384
|
).fetchone()
|
|
380
385
|
selected = [
|
|
381
386
|
scan
|
|
382
|
-
for scan in connection.execute(
|
|
383
|
-
"SELECT * FROM scans WHERE status = 'complete' ORDER BY started_at, id"
|
|
384
|
-
)
|
|
387
|
+
for scan in connection.execute("SELECT * FROM scans WHERE status = 'complete'")
|
|
385
388
|
if _same_repository(scan, requested)
|
|
386
389
|
]
|
|
387
390
|
|
|
391
|
+
selected.sort(key=lambda scan: (timestamp_key(scan["started_at"]), scan["id"]))
|
|
392
|
+
|
|
388
393
|
available = []
|
|
389
|
-
for scan in selected:
|
|
394
|
+
for selected_index, scan in enumerate(selected):
|
|
390
395
|
try:
|
|
391
396
|
read_coverage(scan)
|
|
392
397
|
except SystemExit:
|
|
393
398
|
continue
|
|
394
|
-
available.append(scan)
|
|
399
|
+
available.append((selected_index, scan))
|
|
395
400
|
|
|
396
401
|
saved_pairs = {
|
|
397
402
|
(row["before_scan_id"], row["after_scan_id"])
|
|
@@ -401,10 +406,10 @@ def list_unmatched_scan_pairs(
|
|
|
401
406
|
skipped = 0
|
|
402
407
|
matching_findings: dict[str, list[dict[str, Any]]] = {}
|
|
403
408
|
known_links: list[sqlite3.Row] | None = None
|
|
404
|
-
for index, after in enumerate(available):
|
|
409
|
+
for index, (selected_index, after) in enumerate(available):
|
|
405
410
|
previous = [
|
|
406
411
|
before
|
|
407
|
-
for before in available[:index]
|
|
412
|
+
for _, before in available[:index]
|
|
408
413
|
if args.force or (before["id"], after["id"]) not in saved_pairs
|
|
409
414
|
]
|
|
410
415
|
skipped += index - len(previous)
|
|
@@ -424,11 +429,7 @@ def list_unmatched_scan_pairs(
|
|
|
424
429
|
]
|
|
425
430
|
known_groups = _known_finding_groups(
|
|
426
431
|
known_links,
|
|
427
|
-
{
|
|
428
|
-
scan["id"]
|
|
429
|
-
for scan in selected
|
|
430
|
-
if (scan["started_at"], scan["id"]) <= (after["started_at"], after["id"])
|
|
431
|
-
},
|
|
432
|
+
{scan["id"] for scan in selected[: selected_index + 1]},
|
|
432
433
|
)
|
|
433
434
|
batches.append(
|
|
434
435
|
{
|
|
@@ -666,14 +667,14 @@ def compare_scans(
|
|
|
666
667
|
for pair in related
|
|
667
668
|
]
|
|
668
669
|
if include_matching_inputs:
|
|
670
|
+
after_key = (timestamp_key(after["started_at"]), after["id"])
|
|
669
671
|
known_scan_ids = {
|
|
670
672
|
scan["id"]
|
|
671
673
|
for scan in connection.execute(
|
|
672
|
-
"SELECT
|
|
673
|
-
"AND (started_at < ? OR (started_at = ? AND id <= ?))",
|
|
674
|
-
(after["started_at"], after["started_at"], after["id"]),
|
|
674
|
+
"SELECT id, started_at, target_id, target_path FROM scans WHERE status = 'complete'"
|
|
675
675
|
)
|
|
676
|
-
if
|
|
676
|
+
if (timestamp_key(scan["started_at"]), scan["id"]) <= after_key
|
|
677
|
+
and _same_repository(scan, after)
|
|
677
678
|
}
|
|
678
679
|
excluded_pairs = {(before["id"], after["id"]), (after["id"], before["id"])}
|
|
679
680
|
known_groups = _known_finding_groups(
|
|
@@ -989,7 +990,8 @@ def finding_matches(
|
|
|
989
990
|
)
|
|
990
991
|
)
|
|
991
992
|
known_scans = sorted(
|
|
992
|
-
{(started_at, scan_id)} | {(row["started_at"], row["scan_id"]) for row in linked_rows}
|
|
993
|
+
{(started_at, scan_id)} | {(row["started_at"], row["scan_id"]) for row in linked_rows},
|
|
994
|
+
key=lambda scan: (timestamp_key(scan[0]), scan[1]),
|
|
993
995
|
)
|
|
994
996
|
included = {occurrence_id, *(row["occurrence_id"] for row in rows)}
|
|
995
997
|
rows.extend(
|
|
@@ -13,6 +13,7 @@ from collections.abc import Callable, Iterator
|
|
|
13
13
|
from contextlib import contextmanager
|
|
14
14
|
from datetime import datetime, timezone
|
|
15
15
|
from pathlib import Path
|
|
16
|
+
from typing import Any
|
|
16
17
|
|
|
17
18
|
# Some plugin hosts launch Python with safe-path isolation enabled.
|
|
18
19
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
@@ -160,8 +161,13 @@ def archive_scan(
|
|
|
160
161
|
archived_scan_dir.rmdir()
|
|
161
162
|
scan_dir.rename(archived_scan_dir)
|
|
162
163
|
moved = True
|
|
163
|
-
|
|
164
|
-
|
|
164
|
+
if os.name == "nt":
|
|
165
|
+
from windows_scan_local_files import create_directory_with_same_dacl
|
|
166
|
+
|
|
167
|
+
create_directory_with_same_dacl(scan_dir, archived_scan_dir)
|
|
168
|
+
else:
|
|
169
|
+
scan_dir.mkdir(mode=0o700)
|
|
170
|
+
scan_dir.chmod(0o700)
|
|
165
171
|
if previous_scan is not None:
|
|
166
172
|
connection.execute(
|
|
167
173
|
"UPDATE scans SET scan_dir = ?, updated_at = ? WHERE id = ?",
|
|
@@ -221,6 +227,7 @@ def insert_running_scan(
|
|
|
221
227
|
scope: str,
|
|
222
228
|
diff_target: dict[str, str] | None,
|
|
223
229
|
target_identity: tuple[str, str | None, int | str, int | str],
|
|
230
|
+
source_scopes: dict[str, Any],
|
|
224
231
|
target_root: Path,
|
|
225
232
|
target_summary: str | None,
|
|
226
233
|
scope_file_count: int,
|
|
@@ -244,11 +251,11 @@ def insert_running_scan(
|
|
|
244
251
|
"""
|
|
245
252
|
INSERT INTO scans (
|
|
246
253
|
id, workspace_id, target_id, target_path, target_revision, target_snapshot_digest,
|
|
247
|
-
target_device, target_inode, scope, mode, user_context,
|
|
254
|
+
target_device, target_inode, source_scopes_json, scope, mode, user_context,
|
|
248
255
|
deep_scan_owner_thread_id, diff_target_kind, diff_base_revision,
|
|
249
256
|
diff_head_revision, diff_content_digest, target_summary, scan_dir, model,
|
|
250
257
|
reasoning_effort, status, phase, handoff_status, started_at, created_at, updated_at
|
|
251
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
|
258
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
|
252
259
|
'running', 'preflight', ?, ?, ?, ?)
|
|
253
260
|
""",
|
|
254
261
|
(
|
|
@@ -257,6 +264,7 @@ def insert_running_scan(
|
|
|
257
264
|
workspace["target_id"],
|
|
258
265
|
str(target),
|
|
259
266
|
*target_identity,
|
|
267
|
+
json.dumps(source_scopes, allow_nan=False, separators=(",", ":"), sort_keys=True),
|
|
260
268
|
scope,
|
|
261
269
|
workspace["default_mode"],
|
|
262
270
|
user_context,
|