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
fix(workbench): identify replaced checkout parent directories (#2537)
Michael D'Angelod84df10c1a70
diff --git a/plugins/codex-security/scripts/workbench_target.py b/plugins/codex-security/scripts/workbench_target.pyindex 18eee2a92..4c395e92f 100644--- a/plugins/codex-security/scripts/workbench_target.py+++ b/plugins/codex-security/scripts/workbench_target.py@@ -1369,7 +1369,10 @@ def require_remediation_target(value: str) -> Path:raise SystemExit("Remediation target must be an absolute local directory path.")try:resolved = stored.resolve(strict=True)- except (FileNotFoundError, OSError) as exc:+ except NotADirectoryError:+ # A component of the recorded checkout path now names a non-directory.+ resolved = None+ except OSError as exc:raise SystemExit("Remediation is unavailable because the selected checkout is no longer accessible.") from excdiff --git a/plugins/codex-security/tests/test_workbench_target.py b/plugins/codex-security/tests/test_workbench_target.pyindex c09c12ea0..512e67480 100644--- a/plugins/codex-security/tests/test_workbench_target.py+++ b/plugins/codex-security/tests/test_workbench_target.py@@ -132,6 +132,26 @@ def junction_factory(request: pytest.FixtureRequest, monkeypatch: pytest.MonkeyPreturn create[email protected](os.name != "posix", reason="requires POSIX directory component errors")+def test_recorded_checkout_distinguishes_a_replaced_parent_from_a_missing_path(+ tmp_path: Path,+) -> None:+ from workbench_target import require_remediation_target++ parent = tmp_path / "projects"+ checkout = parent / "repository"+ checkout.mkdir(parents=True)+ assert require_remediation_target(str(checkout)) == checkout++ checkout.rmdir()+ with pytest.raises(SystemExit, match="no longer accessible"):+ require_remediation_target(str(checkout))+ parent.rmdir()+ parent.write_text("ordinary file")+ with pytest.raises(SystemExit, match="checkout path was replaced"):+ require_remediation_target(str(checkout))++def write_reviewed_patch(tmp_path: Path, source: Path, patch: bytes, revision: str = "unversioned") -> dict[str, object]: