@openai/codex-security 0.1.26 → 0.1.27
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 +398 -30
- 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/config-preflight.md +2 -0
- package/_bundled_plugin/references/core-scan.md +1 -1
- package/_bundled_plugin/references/scan-contract.md +35 -35
- package/_bundled_plugin/references/security-guidance.md +7 -1
- 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/workbench_cli.py +4 -0
- package/_bundled_plugin/scripts/workbench_db.py +33 -29
- package/_bundled_plugin/scripts/workbench_scan_history.py +117 -2
- package/_bundled_plugin/scripts/workbench_validation.py +4 -0
- package/_bundled_plugin/skills/define-security-policy/SKILL.md +3 -3
- package/dist/api.d.ts +7 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +481 -60
- package/dist/api.js.map +1 -1
- package/dist/auth.js +10 -0
- package/dist/auth.js.map +1 -1
- package/dist/cli.d.ts +18 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +962 -276
- 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/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +17 -2
- 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 +16 -0
- package/dist/cost-model.d.ts.map +1 -1
- package/dist/cost-model.js +57 -3
- 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-validation-prompt.js +1 -1
- package/dist/custom-validation-prompt.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.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/feedback.d.ts +20 -0
- package/dist/feedback.d.ts.map +1 -0
- package/dist/feedback.js +121 -0
- package/dist/feedback.js.map +1 -0
- 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/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 +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -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 +2 -2
- package/dist/knowledge-base.js.map +1 -1
- package/dist/multiscan.d.ts +2 -0
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +144 -52
- package/dist/multiscan.js.map +1 -1
- 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/runtime.d.ts +5 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +8 -2
- package/dist/runtime.js.map +1 -1
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +19 -6
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-logs.d.ts +29 -0
- package/dist/scan-logs.d.ts.map +1 -1
- package/dist/scan-logs.js +36 -5
- package/dist/scan-logs.js.map +1 -1
- 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/targets.d.ts +8 -1
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +243 -14
- package/dist/targets.js.map +1 -1
- package/package.json +8 -4
- package/_bundled_plugin/scripts/resolve_security_md.py +0 -158
|
@@ -138,6 +138,7 @@ from workbench_validation import (
|
|
|
138
138
|
optional_text,
|
|
139
139
|
parse_scan_cost,
|
|
140
140
|
path_within_scope,
|
|
141
|
+
reject_non_finite_json,
|
|
141
142
|
require_close_note,
|
|
142
143
|
require_occurrence,
|
|
143
144
|
require_uuid,
|
|
@@ -503,7 +504,9 @@ def expected_coverage_mode(scan: sqlite3.Row) -> str:
|
|
|
503
504
|
return "deep_repository" if scan["mode"] == "deep" else "repository"
|
|
504
505
|
|
|
505
506
|
|
|
506
|
-
def workbench_completion_binding(
|
|
507
|
+
def workbench_completion_binding(
|
|
508
|
+
scan: sqlite3.Row, completed_at: str, manifest: dict[str, Any] | None = None
|
|
509
|
+
) -> dict[str, Any]:
|
|
507
510
|
contract = scan_contract(scan)
|
|
508
511
|
target_contract = contract["target"]
|
|
509
512
|
plugin_manifest = read_json_object(
|
|
@@ -532,7 +535,7 @@ def workbench_completion_binding(scan: sqlite3.Row, completed_at: str) -> dict[s
|
|
|
532
535
|
"excludePaths": contract["scope"]["requiredExcludePaths"],
|
|
533
536
|
}
|
|
534
537
|
|
|
535
|
-
|
|
538
|
+
binding: dict[str, Any] = {
|
|
536
539
|
"scanId": scan["id"],
|
|
537
540
|
"startedAt": scan["started_at"],
|
|
538
541
|
"completedAt": completed_at,
|
|
@@ -542,6 +545,7 @@ def workbench_completion_binding(scan: sqlite3.Row, completed_at: str) -> dict[s
|
|
|
542
545
|
"scope": scope,
|
|
543
546
|
"coverageMode": expected_coverage_mode(scan),
|
|
544
547
|
}
|
|
548
|
+
return scan_history.preserve_sealed_completion(binding, manifest)
|
|
545
549
|
|
|
546
550
|
|
|
547
551
|
def verify_manifest_binding(scan: sqlite3.Row, manifest: dict[str, Any]) -> None:
|
|
@@ -1484,8 +1488,8 @@ def complete_scan_locked(
|
|
|
1484
1488
|
add_warning()
|
|
1485
1489
|
scan_dir = require_canonical_scan_directory(Path(scan["scan_dir"]))
|
|
1486
1490
|
completion_timestamp = now()
|
|
1487
|
-
completion_binding = workbench_completion_binding(scan, completion_timestamp)
|
|
1488
1491
|
current_manifest_path = artifact_path(scan_dir, ARTIFACTS["manifest"], required=False)
|
|
1492
|
+
current_manifest = None
|
|
1489
1493
|
if current_manifest_path is not None:
|
|
1490
1494
|
current_manifest = read_json_object(current_manifest_path)
|
|
1491
1495
|
if (
|
|
@@ -1503,8 +1507,8 @@ def complete_scan_locked(
|
|
|
1503
1507
|
or current_manifest["scan"].get("artifacts") is not None
|
|
1504
1508
|
)
|
|
1505
1509
|
)
|
|
1510
|
+
completion_binding = workbench_completion_binding(scan, completion_timestamp, current_manifest)
|
|
1506
1511
|
if scan["recipe_json"] is not None:
|
|
1507
|
-
draft_artifacts: dict[str, Path] = {}
|
|
1508
1512
|
missing_drafts = []
|
|
1509
1513
|
for file_name in (
|
|
1510
1514
|
ARTIFACTS["manifest"],
|
|
@@ -1516,20 +1520,13 @@ def complete_scan_locked(
|
|
|
1516
1520
|
except FileNotFoundError:
|
|
1517
1521
|
missing_drafts.append(file_name)
|
|
1518
1522
|
continue
|
|
1519
|
-
|
|
1520
|
-
if draft_path is not None:
|
|
1521
|
-
draft_artifacts[file_name] = draft_path
|
|
1523
|
+
artifact_path(scan_dir, file_name, required=True)
|
|
1522
1524
|
if missing_drafts:
|
|
1523
1525
|
raise SystemExit(
|
|
1524
1526
|
"Scan agent did not create required draft artifacts: "
|
|
1525
1527
|
f"{', '.join(missing_drafts)}. Check that the scan agent can run shell "
|
|
1526
1528
|
"commands and write to the scan directory before retrying."
|
|
1527
1529
|
)
|
|
1528
|
-
manifest = read_json_object(draft_artifacts[ARTIFACTS["manifest"]])
|
|
1529
|
-
manifest_scan = manifest.get("scan")
|
|
1530
|
-
if isinstance(manifest_scan, dict) and manifest_scan.get("sealedAt") is not None:
|
|
1531
|
-
completion_binding["startedAt"] = manifest_scan.get("startedAt")
|
|
1532
|
-
completion_binding["completedAt"] = manifest_scan.get("completedAt")
|
|
1533
1530
|
wrote = False
|
|
1534
1531
|
try:
|
|
1535
1532
|
prepared = _prepare_scan_finalization(
|
|
@@ -1558,7 +1555,11 @@ def complete_scan_locked(
|
|
|
1558
1555
|
wrote = True
|
|
1559
1556
|
manifest, findings, _ = _write_prepared_scan_finalization(prepared)
|
|
1560
1557
|
except ContractError as exc:
|
|
1561
|
-
if wrote or (
|
|
1558
|
+
if wrote or (
|
|
1559
|
+
scan["mode"] == "deep"
|
|
1560
|
+
and not already_sealed
|
|
1561
|
+
and not isinstance(exc, RecoverableContractError)
|
|
1562
|
+
):
|
|
1562
1563
|
args = argparse.Namespace(claim_token=claim_token, cost_json=cost_json)
|
|
1563
1564
|
args.message, args.scan_id = str(exc), scan_id
|
|
1564
1565
|
fail_scan_locked(connection, args)
|
|
@@ -1869,17 +1870,6 @@ def parse_scan_recipe(value: str, repository: Path) -> dict[str, Any]:
|
|
|
1869
1870
|
return recipe
|
|
1870
1871
|
|
|
1871
1872
|
|
|
1872
|
-
def get_scan_recipe(connection: sqlite3.Connection, args: argparse.Namespace) -> dict[str, Any]:
|
|
1873
|
-
scan = require_scan(connection, args.scan_id)
|
|
1874
|
-
if scan["recipe_json"] is None:
|
|
1875
|
-
raise SystemExit("This scan does not have a saved launch recipe.")
|
|
1876
|
-
return {
|
|
1877
|
-
"parentScanId": scan["parent_scan_id"],
|
|
1878
|
-
"recipe": json.loads(scan["recipe_json"], parse_constant=reject_non_finite_json),
|
|
1879
|
-
"scanId": scan["id"],
|
|
1880
|
-
}
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
1873
|
_WORKBENCH_DB_CONTEXT: saved_results.WorkbenchDbContext
|
|
1884
1874
|
|
|
1885
1875
|
|
|
@@ -3376,10 +3366,6 @@ def read_json_object(path: Path) -> dict[str, Any]:
|
|
|
3376
3366
|
return payload
|
|
3377
3367
|
|
|
3378
3368
|
|
|
3379
|
-
def reject_non_finite_json(value: str) -> None:
|
|
3380
|
-
raise ValueError(f"non-finite JSON number {value!r} is not supported")
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
3369
|
_WORKBENCH_PUBLICATION_CONTEXT = publication.WorkbenchPublicationContext(
|
|
3384
3370
|
ARTIFACTS=ARTIFACTS,
|
|
3385
3371
|
artifact_path=artifact_path,
|
|
@@ -3518,7 +3504,25 @@ def main() -> None:
|
|
|
3518
3504
|
elif args.command == "set-scan-cost-limit":
|
|
3519
3505
|
result = set_scan_cost_limit(connection, args)
|
|
3520
3506
|
elif args.command == "get-scan-recipe":
|
|
3521
|
-
result =
|
|
3507
|
+
result = scan_history.scan_recipe(require_scan(connection, args.scan_id))
|
|
3508
|
+
elif args.command == "get-cli-scan-resume":
|
|
3509
|
+
scan = require_scan(connection, args.scan_id)
|
|
3510
|
+
try:
|
|
3511
|
+
result = scan_history.cli_scan_resume(
|
|
3512
|
+
connection,
|
|
3513
|
+
scan,
|
|
3514
|
+
require_workspace(connection, scan["workspace_id"]),
|
|
3515
|
+
parse_scan_recipe=parse_scan_recipe,
|
|
3516
|
+
scan_contract=scan_contract,
|
|
3517
|
+
require_scan_directory=require_canonical_scan_directory,
|
|
3518
|
+
artifact_path=artifact_path,
|
|
3519
|
+
read_json_object=read_json_object,
|
|
3520
|
+
workbench_completion_binding=workbench_completion_binding,
|
|
3521
|
+
)
|
|
3522
|
+
except SystemExit as exc:
|
|
3523
|
+
if not args.allow_unavailable:
|
|
3524
|
+
raise
|
|
3525
|
+
result = {"unavailable": str(exc)}
|
|
3522
3526
|
elif args.command == "compare-scans":
|
|
3523
3527
|
result = scan_history.compare_scans(
|
|
3524
3528
|
connection,
|
|
@@ -14,10 +14,125 @@ from urllib.parse import urlsplit
|
|
|
14
14
|
|
|
15
15
|
# Some plugin hosts launch Python with safe-path isolation enabled.
|
|
16
16
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
17
|
+
from finalize_scan_contract import ContractError, _prepare_scan_finalization
|
|
17
18
|
from report_projection import SEVERITY_ORDER
|
|
18
|
-
from workbench_constants import FINDINGS_PAGE_MAX
|
|
19
|
+
from workbench_constants import ARTIFACTS, FINDINGS_PAGE_MAX
|
|
20
|
+
from workbench_scan_start import scan_target_identity
|
|
19
21
|
from workbench_scan_usage import stored_scan_cost_fields
|
|
20
|
-
from workbench_target import git_output
|
|
22
|
+
from workbench_target import git_output, require_scan_target_identity
|
|
23
|
+
from workbench_validation import reject_non_finite_json
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def scan_recipe(scan: sqlite3.Row) -> dict[str, Any]:
|
|
27
|
+
if scan["recipe_json"] is None:
|
|
28
|
+
raise SystemExit("This scan does not have a saved launch recipe.")
|
|
29
|
+
return {
|
|
30
|
+
"parentScanId": scan["parent_scan_id"],
|
|
31
|
+
"recipe": json.loads(scan["recipe_json"], parse_constant=reject_non_finite_json),
|
|
32
|
+
"scanId": scan["id"],
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def preserve_sealed_completion(
|
|
37
|
+
binding: dict[str, Any], manifest: dict[str, Any] | None
|
|
38
|
+
) -> dict[str, Any]:
|
|
39
|
+
manifest_scan = manifest.get("scan") if manifest is not None else None
|
|
40
|
+
if isinstance(manifest_scan, dict) and manifest_scan.get("sealedAt") is not None:
|
|
41
|
+
# Keep the original producer; finalization still validates schema, seal and owner.
|
|
42
|
+
binding["startedAt"] = manifest_scan.get("startedAt")
|
|
43
|
+
binding["completedAt"] = manifest_scan.get("completedAt")
|
|
44
|
+
producer = manifest_scan.get("producer")
|
|
45
|
+
if isinstance(producer, dict):
|
|
46
|
+
binding["producer"]["version"] = producer.get("version")
|
|
47
|
+
return binding
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def cli_scan_resume(
|
|
51
|
+
connection: sqlite3.Connection,
|
|
52
|
+
scan: sqlite3.Row,
|
|
53
|
+
workspace: sqlite3.Row,
|
|
54
|
+
*,
|
|
55
|
+
parse_scan_recipe: Callable[[str, Path], dict[str, Any]],
|
|
56
|
+
scan_contract: Callable[[sqlite3.Row], dict[str, Any]],
|
|
57
|
+
require_scan_directory: Callable[[Path], Path],
|
|
58
|
+
artifact_path: Callable[..., Path | None],
|
|
59
|
+
read_json_object: Callable[[Path], dict[str, Any]],
|
|
60
|
+
workbench_completion_binding: Callable[..., dict[str, Any]],
|
|
61
|
+
) -> dict[str, Any]:
|
|
62
|
+
if scan["mode"] != "deep" or scan["recipe_json"] is None:
|
|
63
|
+
raise SystemExit("Resume requires a Deep Scan with a saved CLI launch recipe.")
|
|
64
|
+
if scan["status"] != "running" or scan["canceled_at"] is not None:
|
|
65
|
+
raise SystemExit(
|
|
66
|
+
"Resume requires a running scan; completed, failed, and canceled scans cannot resume."
|
|
67
|
+
)
|
|
68
|
+
thread_id = scan["continuation_thread_id"]
|
|
69
|
+
owner = scan["deep_scan_owner_thread_id"] or workspace["thread_id"]
|
|
70
|
+
if (
|
|
71
|
+
not thread_id
|
|
72
|
+
or (owner is not None and owner != thread_id)
|
|
73
|
+
or scan["handoff_status"] != "delivered"
|
|
74
|
+
or scan["handoff_claim_token"] is not None
|
|
75
|
+
):
|
|
76
|
+
raise SystemExit("Resume requires the original owning CLI session.")
|
|
77
|
+
run = connection.execute(
|
|
78
|
+
"SELECT status, cancel_requested FROM deep_scan_runs WHERE scan_id = ?", (scan["id"],)
|
|
79
|
+
).fetchone()
|
|
80
|
+
if run is not None and (
|
|
81
|
+
run["status"] not in {"running", "succeeded"} or run["cancel_requested"]
|
|
82
|
+
):
|
|
83
|
+
raise SystemExit("This Deep Scan has stopped and cannot resume.")
|
|
84
|
+
try:
|
|
85
|
+
repository = require_scan_target_identity(scan)
|
|
86
|
+
except SystemExit as exc:
|
|
87
|
+
raise SystemExit(
|
|
88
|
+
"Cannot resume: the original checkout is missing or was replaced."
|
|
89
|
+
) from exc
|
|
90
|
+
if scan_target_identity(repository, None) != (
|
|
91
|
+
scan["target_revision"],
|
|
92
|
+
scan["target_snapshot_digest"],
|
|
93
|
+
scan["target_device"],
|
|
94
|
+
scan["target_inode"],
|
|
95
|
+
):
|
|
96
|
+
raise SystemExit("Cannot resume: the original checkout revision or contents changed.")
|
|
97
|
+
recipe = parse_scan_recipe(scan["recipe_json"], repository)
|
|
98
|
+
scan_dir = require_scan_directory(Path(scan["scan_dir"]))
|
|
99
|
+
progress = connection.execute(
|
|
100
|
+
"SELECT scope_file_count FROM scan_progress WHERE scan_id = ?", (scan["id"],)
|
|
101
|
+
).fetchone()
|
|
102
|
+
result = {
|
|
103
|
+
"contract": scan_contract(scan),
|
|
104
|
+
"recipe": recipe,
|
|
105
|
+
"scanDir": str(scan_dir),
|
|
106
|
+
"scanId": scan["id"],
|
|
107
|
+
"scopeFileCount": progress["scope_file_count"],
|
|
108
|
+
"startedAt": scan["started_at"],
|
|
109
|
+
"targetId": scan["target_id"],
|
|
110
|
+
"targetRevision": scan["target_revision"],
|
|
111
|
+
"threadId": thread_id,
|
|
112
|
+
"userContext": scan["user_context"],
|
|
113
|
+
}
|
|
114
|
+
# Active coordinators may still be writing drafts. Validate sealed results
|
|
115
|
+
# before attaching to a coordinator that has finished.
|
|
116
|
+
if run is not None and run["status"] == "succeeded":
|
|
117
|
+
manifest_path = artifact_path(scan_dir, ARTIFACTS["manifest"], required=False)
|
|
118
|
+
if manifest_path is not None:
|
|
119
|
+
manifest = read_json_object(manifest_path)
|
|
120
|
+
manifest_scan = manifest.get("scan")
|
|
121
|
+
if isinstance(manifest_scan, dict) and (
|
|
122
|
+
manifest_scan.get("sealedAt") is not None
|
|
123
|
+
or manifest_scan.get("artifacts") is not None
|
|
124
|
+
):
|
|
125
|
+
try:
|
|
126
|
+
binding = workbench_completion_binding(scan, scan["started_at"], manifest)
|
|
127
|
+
_prepare_scan_finalization(
|
|
128
|
+
scan_dir,
|
|
129
|
+
expected_coverage_mode=binding["coverageMode"],
|
|
130
|
+
completion_binding=binding,
|
|
131
|
+
)
|
|
132
|
+
result["sealedProducerVersion"] = manifest_scan["producer"]["version"]
|
|
133
|
+
except ContractError as exc:
|
|
134
|
+
raise SystemExit(f"Cannot resume sealed scan: {exc}") from exc
|
|
135
|
+
return result
|
|
21
136
|
|
|
22
137
|
|
|
23
138
|
def _windows_path_key(value: str) -> str:
|
|
@@ -16,6 +16,10 @@ from typing import Any
|
|
|
16
16
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
17
17
|
|
|
18
18
|
|
|
19
|
+
def reject_non_finite_json(value: str) -> None:
|
|
20
|
+
raise ValueError(f"non-finite JSON number {value!r} is not supported")
|
|
21
|
+
|
|
22
|
+
|
|
19
23
|
def require_uuid(value: str, label: str) -> str:
|
|
20
24
|
try:
|
|
21
25
|
return str(uuid.UUID(value))
|
|
@@ -12,15 +12,15 @@ A useful `SECURITY.md` tells Codex Security what matters in a repository: the sy
|
|
|
12
12
|
Confirm the repository or component the user wants to cover. Inventory policy paths, including hidden directories, before reading them:
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
<
|
|
15
|
+
<plugin_dir>/scripts/launch_codex_security_mcp --helper resolve-security-md --repo <repo_root> --list
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
The
|
|
18
|
+
On Windows, use `launch_codex_security_mcp.cmd` with the same arguments. The launcher reuses the plugin's configured or bundled Node runtime. It emits a sorted JSON array of repository-relative policy paths, escapes control characters unambiguously, includes linked policies without following directory links, and prunes Git metadata. Resolve each candidate within the repository and check the resolved regular file's byte size. Do not pass policies larger than 1 MiB to the resolver; report them so the user can decide how to proceed. The resolver enforces the same limit for regular files and repository-local symbolic links.
|
|
19
19
|
|
|
20
20
|
Read `../../references/security-guidance.md`, then resolve the policy chain for the file or directory being reviewed:
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
<
|
|
23
|
+
<plugin_dir>/scripts/launch_codex_security_mcp --helper resolve-security-md --repo <repo_root> --scope <file_or_directory> --out -
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
`<plugin_dir>` is the Codex Security plugin root containing `.codex-plugin/plugin.json`, not the target repository or this skill directory.
|
package/dist/api.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { type ScanCost, type ScanSessionEvent } from "./cost.js";
|
|
|
5
5
|
import { type DeepScanProgress } from "./deep-progress.js";
|
|
6
6
|
import { ScanResult } from "./result.js";
|
|
7
7
|
import type { SeverityLevel } from "./models.js";
|
|
8
|
+
import { type SecurityPolicyDraft, type SecurityPolicyOptions, type SecurityPolicyPreflight } from "./security-policy.js";
|
|
8
9
|
import { type ScanActivity } from "./scan-activity.js";
|
|
9
10
|
import { type ScanProgress, type ScanWorkerStatus } from "./worker-progress.js";
|
|
10
11
|
import { importAmbientAuth, type ProcessEnvironment } from "./runtime.js";
|
|
@@ -96,7 +97,7 @@ export interface ScanBudget {
|
|
|
96
97
|
cost: Readonly<ScanCost>;
|
|
97
98
|
signal: AbortSignal;
|
|
98
99
|
}
|
|
99
|
-
type ScanObserverName = "onAuthentication" | "onCost" | "onOutputArchived" | "onOutputDirReady" | "onScanStarted" | "onTrustedAccessStatus" | "onReconnect" | "onActivity" | "onSessionEvent" | "onProgress" | "onDeepProgress" | "onWorkerStatus" | "onWarning";
|
|
100
|
+
type ScanObserverName = "onAuthentication" | "onCost" | "onOutputArchived" | "onOutputDirReady" | "onScanStarted" | "onTrustedAccessStatus" | "onReconnect" | "onActivity" | "onSessionEvent" | "onProgress" | "onDeepProgress" | "onWorkerStatus" | "onStage" | "onWarning";
|
|
100
101
|
export interface ScanPreflight extends DeepScanOptions {
|
|
101
102
|
repository: string;
|
|
102
103
|
target: NormalizedTarget;
|
|
@@ -128,6 +129,11 @@ export declare class CodexSecurity {
|
|
|
128
129
|
run(repository: string, options?: ScanOptions): Promise<ScanResult>;
|
|
129
130
|
validate(options: ValidationOptions): Promise<ValidationResult>;
|
|
130
131
|
preflight(repository: string, options?: ScanOptions): Promise<ScanPreflight>;
|
|
132
|
+
preflightPolicy(repository: string, options?: SecurityPolicyOptions): Promise<SecurityPolicyPreflight>;
|
|
133
|
+
generatePolicy(repository: string, options?: SecurityPolicyOptions): Promise<SecurityPolicyDraft>;
|
|
134
|
+
previewPolicy(draft: SecurityPolicyDraft, options?: {
|
|
135
|
+
signal?: AbortSignal;
|
|
136
|
+
}): Promise<string>;
|
|
131
137
|
loginApiKey(apiKey: string): Promise<void>;
|
|
132
138
|
loginChatGPT(): Promise<CodexLoginHandle>;
|
|
133
139
|
loginChatGPTDeviceCode(): Promise<CodexLoginHandle>;
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AAqCA,OAAO,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AAqCA,OAAO,EAKL,gBAAgB,EAGhB,KAAK,aAAa,EACnB,MAAM,WAAW,CAAC;AAMnB,OAAO,EAaL,KAAK,mBAAmB,EACxB,KAAK,UAAU,EAEhB,MAAM,aAAa,CAAC;AACrB,OAAO,EAGL,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACtB,MAAM,WAAW,CAAC;AACnB,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAiC5B,OAAO,EACL,UAAU,EAIX,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAaL,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAI7B,MAAM,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