@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
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
from __future__ import annotations
|
|
5
5
|
|
|
6
6
|
import argparse
|
|
7
|
+
import json
|
|
7
8
|
import re
|
|
8
9
|
from collections import Counter
|
|
9
10
|
from typing import Any
|
|
@@ -28,7 +29,7 @@ class ReportProjectionError(ValueError):
|
|
|
28
29
|
def _text(value: Any, fallback: str) -> str:
|
|
29
30
|
candidate = value if isinstance(value, str) and value.strip() else fallback
|
|
30
31
|
normalized = " ".join(candidate.split())
|
|
31
|
-
if re.match(r"^(?:#{1,6}\s|[-*+]\s|>\s
|
|
32
|
+
if re.match(r"^(?:#{1,6}\s|[-*+]\s|>\s|```|~~~|\d+[.)]\s|\|)", normalized):
|
|
32
33
|
normalized = f"Text: {normalized}"
|
|
33
34
|
return "".join(
|
|
34
35
|
part if index % 2 else re.sub(r"([\\`*_\[\]<>])", r"\\\1", part)
|
|
@@ -44,6 +45,20 @@ def _strings(value: Any) -> list[str]:
|
|
|
44
45
|
return [text for item in value if (text := _text(item, ""))]
|
|
45
46
|
|
|
46
47
|
|
|
48
|
+
def _path_label(value: str) -> str:
|
|
49
|
+
if "," in value or value != " ".join(value.split()) or any(ord(c) < 32 for c in value):
|
|
50
|
+
return json.dumps(value)
|
|
51
|
+
return value
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _path_text(value: str) -> str:
|
|
55
|
+
label = _path_label(value)
|
|
56
|
+
if label != value:
|
|
57
|
+
marker = _code_fence(label, minimum=1)
|
|
58
|
+
return f"{marker}{label}{marker}"
|
|
59
|
+
return re.sub(r"([\\`*_\[\]<>])", r"\\\1", value)
|
|
60
|
+
|
|
61
|
+
|
|
47
62
|
def _cell(value: Any) -> str:
|
|
48
63
|
return _text(value, "none").replace("|", "\\|").replace("\n", "<br>")
|
|
49
64
|
|
|
@@ -386,17 +401,20 @@ def _root_cause_code_evidence(
|
|
|
386
401
|
def _code_evidence_location(item: dict[str, Any]) -> str:
|
|
387
402
|
location = item.get("location")
|
|
388
403
|
if isinstance(location, str):
|
|
389
|
-
return location
|
|
404
|
+
return " ".join(location.split())
|
|
390
405
|
if isinstance(location, dict):
|
|
391
406
|
item = location
|
|
392
407
|
path = item.get("path")
|
|
393
408
|
start = item.get("startLine")
|
|
394
|
-
end = item.get("endLine"
|
|
409
|
+
end = item.get("endLine")
|
|
395
410
|
if not isinstance(path, str) or not path:
|
|
396
411
|
return ""
|
|
397
|
-
|
|
412
|
+
path = _path_label(path)
|
|
413
|
+
if not isinstance(start, int) or isinstance(start, bool) or start < 1:
|
|
398
414
|
return path
|
|
399
|
-
|
|
415
|
+
if not isinstance(end, int) or isinstance(end, bool) or end <= start:
|
|
416
|
+
return f"{path}:{start}"
|
|
417
|
+
return f"{path}:{start}-{end}"
|
|
400
418
|
|
|
401
419
|
|
|
402
420
|
def _code_fence(code: str, minimum: int = 3) -> str:
|
|
@@ -408,7 +426,7 @@ def _code_evidence_lines(evidence: list[dict[str, Any]]) -> list[str]:
|
|
|
408
426
|
lines: list[str] = []
|
|
409
427
|
for index, item in enumerate(evidence):
|
|
410
428
|
label = _text(item.get("label"), f"Code evidence {index + 1}")
|
|
411
|
-
location =
|
|
429
|
+
location = _code_evidence_location(item)
|
|
412
430
|
explanation = _text(item.get("explanation"), "")
|
|
413
431
|
language = item.get("language") if isinstance(item.get("language"), str) else ""
|
|
414
432
|
language = language if re.fullmatch(r"[A-Za-z0-9_+.-]*", language) else ""
|
|
@@ -437,7 +455,7 @@ def _locations(finding: dict[str, Any]) -> str:
|
|
|
437
455
|
start = location["startLine"]
|
|
438
456
|
end = location.get("endLine", start)
|
|
439
457
|
suffix = f":{start}" if end == start else f":{start}-{end}"
|
|
440
|
-
rendered.append(f"{location['path']}{suffix}")
|
|
458
|
+
rendered.append(f"{_path_text(location['path'])}{suffix}")
|
|
441
459
|
return ", ".join(rendered)
|
|
442
460
|
|
|
443
461
|
|
|
@@ -541,7 +559,7 @@ def _finding_header(number: int, finding: dict[str, Any]) -> list[str]:
|
|
|
541
559
|
f"| Confidence rationale | {_cell(finding['confidence']['rationale'])} |",
|
|
542
560
|
f"| Category | {_cell(finding['taxonomy']['category'])} |",
|
|
543
561
|
f"| CWE | {_cell(cwes)} |",
|
|
544
|
-
|
|
562
|
+
"| Affected lines | " + _locations(finding).replace("|", "\\|") + " |",
|
|
545
563
|
]
|
|
546
564
|
|
|
547
565
|
|
|
@@ -615,9 +633,9 @@ def _finding_section(number: int, finding: dict[str, Any]) -> list[str]:
|
|
|
615
633
|
validation_code_evidence = _section_code_evidence(finding, validation)
|
|
616
634
|
dataflow_code_evidence = _section_code_evidence(finding, attack_path, *dataflow_sections)
|
|
617
635
|
reachability_code_evidence = _section_code_evidence(finding, reachability)
|
|
618
|
-
dataflow_summary = _text(
|
|
619
|
-
|
|
620
|
-
|
|
636
|
+
dataflow_summary = _text(dataflow.get("summary"), "") or (
|
|
637
|
+
f"The canonical finding records the affected path at {_locations(finding)}, "
|
|
638
|
+
"but no expanded source-to-sink narrative was recorded."
|
|
621
639
|
)
|
|
622
640
|
reachability_summary = _text(reachability.get("summary"), "") or _text(
|
|
623
641
|
attack_path.get("summary"),
|
|
@@ -769,8 +787,12 @@ def build_report_markdown(
|
|
|
769
787
|
deep_presentation = uses_deep_presentation(coverage, findings)
|
|
770
788
|
deep_finding_groups = _deep_finding_groups(findings, writeup_paths) if deep_presentation else []
|
|
771
789
|
hardening_portfolio_path = _hardening_portfolio_path(scan)
|
|
772
|
-
include_paths =
|
|
773
|
-
|
|
790
|
+
include_paths = [
|
|
791
|
+
_path_text(path) for path in coverage.get("includePaths", scope.get("includePaths", []))
|
|
792
|
+
]
|
|
793
|
+
exclude_paths = [
|
|
794
|
+
_path_text(path) for path in coverage.get("excludePaths", scope.get("excludePaths", []))
|
|
795
|
+
]
|
|
774
796
|
limitations = _strings(scope.get("limitations"))
|
|
775
797
|
explicit_exclusions = coverage.get("explicitExclusions", [])
|
|
776
798
|
lines = [
|
|
@@ -208,6 +208,14 @@ def parse_args(description: str) -> argparse.Namespace:
|
|
|
208
208
|
complete_scan.add_argument("--claim-token")
|
|
209
209
|
complete_scan.add_argument("--cost-json")
|
|
210
210
|
complete_scan.add_argument("--thread-id")
|
|
211
|
+
complete_scan.add_argument("--turn-id")
|
|
212
|
+
|
|
213
|
+
finalize_scan_usage = add_command(
|
|
214
|
+
"finalize-scan-usage", "--scan-id", "--thread-id", "--turn-id"
|
|
215
|
+
)
|
|
216
|
+
finalize_scan_usage.add_argument(
|
|
217
|
+
"--turn-status", choices=("completed", "interrupted", "failed"), default="completed"
|
|
218
|
+
)
|
|
211
219
|
|
|
212
220
|
complete_budget_exhausted_scan = add_command(
|
|
213
221
|
"complete-budget-exhausted-scan", "--scan-id", "--cost-json"
|
|
@@ -299,12 +307,7 @@ def parse_args(description: str) -> argparse.Namespace:
|
|
|
299
307
|
export_findings.add_argument("--format", choices=(*EXPORT_FORMATS, "md"))
|
|
300
308
|
export_findings.add_argument("--validate-only", action="store_true")
|
|
301
309
|
|
|
302
|
-
|
|
303
|
-
"inspect-linear-publication",
|
|
304
|
-
"prepare-linear-publication",
|
|
305
|
-
"record-linear-publications",
|
|
306
|
-
):
|
|
307
|
-
add_command(command, "--input-file")
|
|
310
|
+
subparsers.add_parser("finding-issues")
|
|
308
311
|
|
|
309
312
|
subparsers.add_parser("database-info")
|
|
310
313
|
subparsers.add_parser("finding-workflow")
|
|
@@ -1162,9 +1162,43 @@ def complete_scan(
|
|
|
1162
1162
|
cost_json,
|
|
1163
1163
|
prepare_only=prepare_only,
|
|
1164
1164
|
thread_id=getattr(args, "thread_id", None),
|
|
1165
|
+
turn_id=getattr(args, "turn_id", None),
|
|
1165
1166
|
)
|
|
1166
1167
|
|
|
1167
1168
|
|
|
1169
|
+
def finalize_scan_usage(connection: sqlite3.Connection, args: argparse.Namespace) -> dict[str, Any]:
|
|
1170
|
+
scan_id = require_uuid(args.scan_id, "scan-id")
|
|
1171
|
+
with scan_completion_lock(scan_id):
|
|
1172
|
+
scan = require_scan(connection, scan_id)
|
|
1173
|
+
stored = json.loads(scan["cost_json"]) if scan["cost_json"] is not None else {}
|
|
1174
|
+
usage = stored.get("usage", {})
|
|
1175
|
+
completion = usage.get("completion")
|
|
1176
|
+
if scan["status"] != "complete" or not completion:
|
|
1177
|
+
raise SystemExit("The scan has no pending completion usage.")
|
|
1178
|
+
if completion["threadId"] != args.thread_id or completion["turnId"] != args.turn_id:
|
|
1179
|
+
raise SystemExit("The scan usage belongs to a different completion turn.")
|
|
1180
|
+
if not completion["finalized"]:
|
|
1181
|
+
usage = scan_usage.collect_scan_usage(
|
|
1182
|
+
connection,
|
|
1183
|
+
scan,
|
|
1184
|
+
thread_id=args.thread_id,
|
|
1185
|
+
completed_turn_id=args.turn_id,
|
|
1186
|
+
)
|
|
1187
|
+
if usage["coverage"] == "unavailable":
|
|
1188
|
+
return scan_context(connection, scan_id)
|
|
1189
|
+
if args.turn_status != "completed":
|
|
1190
|
+
if usage["coverage"] == "complete":
|
|
1191
|
+
usage["coverage"] = "partial"
|
|
1192
|
+
usage["warnings"] = [*usage.get("warnings", []), f"scan_turn_{args.turn_status}"]
|
|
1193
|
+
usage["completion"] = {**completion, "finalized": True}
|
|
1194
|
+
cost_json = parse_scan_cost(json.dumps({**stored, "usage": usage}))
|
|
1195
|
+
with connection:
|
|
1196
|
+
connection.execute(
|
|
1197
|
+
"UPDATE scans SET cost_json = ? WHERE id = ?", (cost_json, scan_id)
|
|
1198
|
+
)
|
|
1199
|
+
return scan_context(connection, scan_id)
|
|
1200
|
+
|
|
1201
|
+
|
|
1168
1202
|
def complete_budget_exhausted_scan(
|
|
1169
1203
|
connection: sqlite3.Connection, args: argparse.Namespace
|
|
1170
1204
|
) -> dict[str, Any]:
|
|
@@ -1454,6 +1488,7 @@ def complete_scan_locked(
|
|
|
1454
1488
|
*,
|
|
1455
1489
|
prepare_only: bool = False,
|
|
1456
1490
|
thread_id: str | None = None,
|
|
1491
|
+
turn_id: str | None = None,
|
|
1457
1492
|
) -> dict[str, Any]:
|
|
1458
1493
|
scan = require_scan(connection, scan_id)
|
|
1459
1494
|
if scan["status"] == "complete":
|
|
@@ -1610,6 +1645,18 @@ def complete_scan_locked(
|
|
|
1610
1645
|
thread_id=thread_id,
|
|
1611
1646
|
completed_at=completion_timestamp,
|
|
1612
1647
|
)
|
|
1648
|
+
if thread_id is not None and turn_id is not None:
|
|
1649
|
+
measured_usage["completion"] = {
|
|
1650
|
+
"threadId": thread_id,
|
|
1651
|
+
"turnId": turn_id,
|
|
1652
|
+
"finalized": False,
|
|
1653
|
+
}
|
|
1654
|
+
if measured_usage["coverage"] == "complete":
|
|
1655
|
+
measured_usage["coverage"] = "partial"
|
|
1656
|
+
measured_usage["warnings"] = [
|
|
1657
|
+
*measured_usage.get("warnings", []),
|
|
1658
|
+
"turn_in_progress",
|
|
1659
|
+
]
|
|
1613
1660
|
cost_json = parse_scan_cost(scan_usage.measured_scan_cost_json(measured_usage))
|
|
1614
1661
|
connection.execute("BEGIN IMMEDIATE")
|
|
1615
1662
|
with connection:
|
|
@@ -3359,10 +3406,8 @@ def main(*, before_archive: Callable[[], None] | None = None) -> None:
|
|
|
3359
3406
|
if args.command in {"save-artifact", "read-artifact"}:
|
|
3360
3407
|
print(json.dumps(saved_results.read_or_save_artifact(args)))
|
|
3361
3408
|
return
|
|
3362
|
-
if args.command == "
|
|
3363
|
-
result = publication.
|
|
3364
|
-
_WORKBENCH_PUBLICATION_CONTEXT, read_json_object(Path(args.input_file))
|
|
3365
|
-
)
|
|
3409
|
+
if args.command == "finding-issues":
|
|
3410
|
+
result = publication.finding_issues(_WORKBENCH_PUBLICATION_CONTEXT, json.load(sys.stdin))
|
|
3366
3411
|
print(json.dumps(result, allow_nan=False, sort_keys=True))
|
|
3367
3412
|
return
|
|
3368
3413
|
with closing(
|
|
@@ -3386,6 +3431,7 @@ def main(*, before_archive: Callable[[], None] | None = None) -> None:
|
|
|
3386
3431
|
"register-cli-scan": partial(register_cli_scan, before_archive=before_archive),
|
|
3387
3432
|
"set-scan-thread": set_scan_thread,
|
|
3388
3433
|
"set-scan-cost-limit": set_scan_cost_limit,
|
|
3434
|
+
"finalize-scan-usage": finalize_scan_usage,
|
|
3389
3435
|
"list-global-findings": native_indexes.list_global_findings,
|
|
3390
3436
|
"list-repositories": native_indexes.list_repositories,
|
|
3391
3437
|
"list-findings": list_findings,
|
|
@@ -3415,21 +3461,10 @@ def main(*, before_archive: Callable[[], None] | None = None) -> None:
|
|
|
3415
3461
|
"attach-scan-continuation-thread": partial(
|
|
3416
3462
|
handoff.attach_scan_continuation_thread, command_context
|
|
3417
3463
|
),
|
|
3418
|
-
"prepare-linear-publication": partial(
|
|
3419
|
-
publication.prepare_linear_publication, _WORKBENCH_PUBLICATION_CONTEXT
|
|
3420
|
-
),
|
|
3421
|
-
"record-linear-publications": partial(
|
|
3422
|
-
publication.record_linear_publications, _WORKBENCH_PUBLICATION_CONTEXT
|
|
3423
|
-
),
|
|
3424
3464
|
"export-findings": partial(publication.export_findings, _WORKBENCH_PUBLICATION_CONTEXT),
|
|
3425
3465
|
}
|
|
3426
3466
|
if handler := handlers.get(args.command):
|
|
3427
|
-
|
|
3428
|
-
read_json_object(Path(args.input_file))
|
|
3429
|
-
if args.command in {"prepare-linear-publication", "record-linear-publications"}
|
|
3430
|
-
else args
|
|
3431
|
-
)
|
|
3432
|
-
result = handler(connection, payload)
|
|
3467
|
+
result = handler(connection, args)
|
|
3433
3468
|
elif args.command == "get-workspace":
|
|
3434
3469
|
result = workspace_state(
|
|
3435
3470
|
connection,
|