OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security
TypeScript ai-securityapplication-securityclicode-scanningcodexcodex-securitycybersecuritydevsecopsnodejsnpmopenaisdksecuritytypescriptvulnerability-scanning
test: share remediation patch fixtures (#1470)
mldangelo-oaiec8e799de0f1
diff --git a/plugins/codex-security/tests/test_workbench_db.py b/plugins/codex-security/tests/test_workbench_db.pyindex 6d3fdf864..0fd91c4f3 100644--- a/plugins/codex-security/tests/test_workbench_db.py+++ b/plugins/codex-security/tests/test_workbench_db.py@@ -45,6 +45,7 @@ from workbench_test_support import (update_progress,workspace_command,write_completed_contract,+ write_remediation_patch,)HEAD_CHANGED_WARNING = (@@ -1038,15 +1039,7 @@ def test_completed_finding_triage_and_remediation_persist()assert "pending remediation operation" in str(pending_close["stderr"])patch_path = scan_dir / "remediation.patch"- patch_path.write_text(- "diff --git a/source.txt b/source.txt\n"- "--- a/source.txt\n"- "+++ b/source.txt\n"- "@@ -1 +1 @@\n"- "-vulnerable\n"- "+fixed\n",- newline="\n",- )+ write_remediation_patch(patch_path, newline="\n")generated = set_remediation(state_dir,occurrence_id,diff --git a/plugins/codex-security/tests/test_workbench_remediation_cancellation.py b/plugins/codex-security/tests/test_workbench_remediation_cancellation.pyindex ace5d85f4..49ea51086 100644--- a/plugins/codex-security/tests/test_workbench_remediation_cancellation.py+++ b/plugins/codex-security/tests/test_workbench_remediation_cancellation.py@@ -13,6 +13,7 @@ from workbench_test_support import (set_remediation,start_saved_scan,write_completed_contract,+ write_remediation_patch,)@@ -46,14 +47,7 @@ def test_cancel_finding_remediation_request_restores_previous_state(tmp_path: Pageneration_token = str(uuid.uuid4())request_remediation(state_dir, occurrence_id, request_id, generation_token)patch_path = scan_dir / "remediation.patch"- patch_path.write_text(- "diff --git a/source.txt b/source.txt\n"- "--- a/source.txt\n"- "+++ b/source.txt\n"- "@@ -1 +1 @@\n"- "-vulnerable\n"- "+fixed\n"- )+ write_remediation_patch(patch_path)generated = set_remediation(state_dir,occurrence_id,diff --git a/plugins/codex-security/tests/test_workbench_remediation_retry.py b/plugins/codex-security/tests/test_workbench_remediation_retry.pyindex ffd552c3b..d0fd1f282 100644--- a/plugins/codex-security/tests/test_workbench_remediation_retry.py+++ b/plugins/codex-security/tests/test_workbench_remediation_retry.py@@ -18,6 +18,7 @@ from workbench_test_support import (set_triage,start_saved_scan,write_completed_contract,+ write_remediation_patch,)@@ -118,14 +119,7 @@ def test_failed_remediation_steps_can_retry_or_regenerate(tmp_path: Path) -> Nonassert regenerated["state"] == "requested"patch_path = scan_dir / "remediation.patch"- patch_path.write_text(- "diff --git a/source.txt b/source.txt\n"- "--- a/source.txt\n"- "+++ b/source.txt\n"- "@@ -1 +1 @@\n"- "-vulnerable\n"- "+fixed\n"- )+ write_remediation_patch(patch_path)patch_digest = f"sha256:{hashlib.sha256(patch_path.read_bytes()).hexdigest()}"update_remediation(state_dir,diff --git a/plugins/codex-security/tests/workbench_test_support.py b/plugins/codex-security/tests/workbench_test_support.pyindex cdb166350..7b7f77242 100644--- a/plugins/codex-security/tests/workbench_test_support.py+++ b/plugins/codex-security/tests/workbench_test_support.py@@ -403,6 +403,18 @@ def workspace_command(return run_workbench(state_dir, command, "--workspace-id", workspace_id, *extra, **options)+def write_remediation_patch(patch_path: Path, **text_options: Any) -> None:+ patch_path.write_text(+ "diff --git a/source.txt b/source.txt\n"+ "--- a/source.txt\n"+ "+++ b/source.txt\n"+ "@@ -1 +1 @@\n"+ "-vulnerable\n"+ "+fixed\n",+ **text_options,+ )++def request_remediation(state_dir: Path,occurrence_id: str,