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(plugin): save artifacts with long POSIX filenames (#2533)
Michael D'Angelo5ee74aeedc0b
diff --git a/plugins/codex-security/scripts/posix_scan_local_files.py b/plugins/codex-security/scripts/posix_scan_local_files.pyindex 5df348ab1..bc75e38ab 100644--- a/plugins/codex-security/scripts/posix_scan_local_files.py+++ b/plugins/codex-security/scripts/posix_scan_local_files.py@@ -168,7 +168,10 @@ def stage_write(if matches:yield lambda _directory=None: (opened, opened.st_ctime_ns)return- candidate = f".{name}.{secrets.token_hex(8)}.tmp"+ # A valid destination may already occupy the filesystem's entire name limit.+ candidate = f".{secrets.token_hex(8)}.tmp"+ if name.casefold() == candidate:+ candidate = "." + candidatewith stage_file(parent_fd, candidate, payload, owner_read_write) as staged_fd:staged = os.fstat(staged_fd)diff --git a/plugins/codex-security/tests/test_scan_local_write_cleanup.py b/plugins/codex-security/tests/test_scan_local_write_cleanup.pyindex efc54e40f..5d1a5fe15 100644--- a/plugins/codex-security/tests/test_scan_local_write_cleanup.py+++ b/plugins/codex-security/tests/test_scan_local_write_cleanup.py@@ -143,7 +143,7 @@ def test_atomic_write_closes_directories_after_cleanup_failures(assert destination.read_bytes() == b"original"else:assert destination.read_bytes() == b"replacement"- staging = list(tmp_path.glob(".report.md.*.tmp"))+ staging = list(tmp_path.glob(".*.tmp"))assert len(staging) == (1 if failure == "write_and_unlink" else 0)finally:# Keep a failed regression assertion from leaking descriptors in the test runner.@@ -245,7 +245,7 @@ def test_new_patch_rejects_same_size_edit_during_publication(tmp_path, monkeypatdef test_existing_temporary_file_survives_a_name_collision(tmp_path, monkeypatch):monkeypatch.setattr(secrets, "token_hex", lambda _: "collision")- existing = tmp_path / ".generated.patch.collision.tmp"+ existing = tmp_path / ".collision.tmp"existing.write_bytes(b"another writer")with pytest.raises(FileExistsError):FINALIZER.write_scan_local_bytes(@@ -253,3 +253,16 @@ def test_existing_temporary_file_survives_a_name_collision(tmp_path, monkeypatch)assert existing.read_bytes() == b"another writer"assert not (tmp_path / "generated.patch").exists()++[email protected]("name", ["a" * 251 + ".txt", "é" * 125 + "x.txt", ".0123456789abcdef.tmp"])+def test_stage_and_replace_valid_artifact_names(tmp_path, monkeypatch, name):+ monkeypatch.setattr(secrets, "token_hex", lambda _: "0123456789abcdef")+ destination = tmp_path / name+ with FINALIZER.stage_scan_local_bytes(tmp_path, name, b"first") as publish:+ assert not destination.exists()+ publish()+ assert destination.read_bytes() == b"first"+ FINALIZER.write_scan_local_bytes(tmp_path, name, b"updated")+ assert destination.read_bytes() == b"updated"+ assert list(tmp_path.iterdir()) == [destination]