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): preserve saved results with non-UTF-8 artifact names (#1289)
mldangelo-oai73a6974df45d
diff --git a/plugins/codex-security/scripts/workbench_db.py b/plugins/codex-security/scripts/workbench_db.pyindex 8159f7764..3bdbc8eba 100644--- a/plugins/codex-security/scripts/workbench_db.py+++ b/plugins/codex-security/scripts/workbench_db.py@@ -3039,15 +3039,15 @@ def finding_artifact_paths(scan_dir: Path, details: dict[str, Any]) -> list[str]def scan_local_regular_file(scan_dir: Path, relative_path: str) -> bool:- if len(relative_path.encode("utf-8")) > FINDING_LOCATION_PATH_BYTES:- return Falsetry:+ if len(relative_path.encode("utf-8")) > FINDING_LOCATION_PATH_BYTES:+ return Falsedescriptor = open_scan_local_file_descriptor(scan_dir,relative_path,f"finding artifact {relative_path}",)- except (ContractError, OSError):+ except (ContractError, OSError, UnicodeEncodeError):return Falsetry:return stat.S_ISREG(os.fstat(descriptor).st_mode)diff --git a/plugins/codex-security/tests/test_workbench_db.py b/plugins/codex-security/tests/test_workbench_db.pyindex 1a4cc9ad5..5b679d25c 100644--- a/plugins/codex-security/tests/test_workbench_db.py+++ b/plugins/codex-security/tests/test_workbench_db.py@@ -6,6 +6,7 @@ import osimport runpyimport sqlite3import subprocess+import sysimport timeimport uuidfrom concurrent.futures import ThreadPoolExecutor@@ -3817,7 +3818,22 @@ def test_workbench_preserves_scan_when_git_revision_cannot_be_rechecked(tmp_pathassert manifest["scan"]["target"]["revision"] == "deadbeef"-def test_completed_finding_projects_writeup_and_poc_artifact_paths(tmp_path: Path) -> None:+ "non_utf8_artifact",+ [+ False,+ pytest.param(+ True,+ marks=pytest.mark.skipif(+ os.name == "nt" or sys.platform == "darwin",+ reason="Windows and macOS filesystems cannot retain arbitrary non-UTF-8 bytes",+ ),+ ),+ ],+)+def test_completed_finding_projects_writeup_and_poc_artifact_paths(+ tmp_path: Path, non_utf8_artifact: bool+) -> None:state_dir = tmp_path / "state"target = tmp_path / "target"target.mkdir()@@ -3848,6 +3864,9 @@ def test_completed_finding_projects_writeup_and_poc_artifact_paths(tmp_path: Pat(poc / "outside-link.txt").symlink_to(outside)completed = run_workbench(state_dir, "complete-scan", "--scan-id", scan_id)+ if non_utf8_artifact:+ (poc / os.fsdecode(b"caf\xe9.txt")).write_text("Supplemental fixture.\n")+ completed = run_workbench(state_dir, "get-scan", "--scan-id", scan_id)assert completed["scan"]["findings"][0]["artifactPaths"] == [report_path,f"findings/{slug}/poc/README.md",