Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

fix(contract): preserve Unicode colon source paths (#542)

Sylvester Kaczmarek5c8a8d662fb5
diff --git a/plugins/codex-security/scripts/finalize_scan_contract.py b/plugins/codex-security/scripts/finalize_scan_contract.py
index 949e58aa3..abcb82736 100644
--- a/plugins/codex-security/scripts/finalize_scan_contract.py
+++ b/plugins/codex-security/scripts/finalize_scan_contract.py
@@ -432,7 +432,7 @@ def _require_safe_relative_path(value: object, context: str, *, allow_dot: bool
normalized = path.as_posix()
if (
(normalized == "." and not allow_dot)
- or (len(value) >= 2 and value[0].isalpha() and value[1] == ":")
+ or re.match(r"^[A-Za-z]:", value)
or "\\" in value
or "\0" in value
or any(ord(character) < 32 for character in value)
diff --git a/plugins/codex-security/tests/test_finalize_scan_contract.py b/plugins/codex-security/tests/test_finalize_scan_contract.py
index 48de0b9c2..fa35e2582 100644
--- a/plugins/codex-security/tests/test_finalize_scan_contract.py
+++ b/plugins/codex-security/tests/test_finalize_scan_contract.py
@@ -82,7 +82,7 @@ class FinalizeScanContractTest(ScanFixtureTestCase):
@skipIf(os.name == "nt", "POSIX source filenames")
def test_sarif_hashes_source_names_that_are_not_portable_artifact_names(self) -> None:
source_root = self.scan_dir / "source"
- for name in ("aux.c", "con.py", "src/a:b.c", "what?.md", " ", "\u00a0"):
+ for name in ("aux.c", "con.py", "src/a:b.c", "é:helper.ts", "what?.md", " ", "\u00a0"):
with self.subTest(name=name):
source = source_root / name
source.parent.mkdir(parents=True, exist_ok=True)
@@ -2407,7 +2407,7 @@ The extraction root is not enforced.
)
def test_preserves_literal_repository_paths(self) -> None:
- for path in (" ", " ", "\u00a0", "src/a:b.py", "report:summary.py"):
+ for path in (" ", " ", "\u00a0", "src/a:b.py", "report:summary.py", "é:helper.ts"):
with self.subTest(path=path):
self.manifest["scan"]["scope"]["includePaths"] = [path]
self.coverage["includePaths"] = [path]
diff --git a/sdk/typescript/tests-ts/contract.test.ts b/sdk/typescript/tests-ts/contract.test.ts
index 1a0824a58..7fdc0ec19 100644
--- a/sdk/typescript/tests-ts/contract.test.ts
+++ b/sdk/typescript/tests-ts/contract.test.ts
@@ -1100,6 +1100,8 @@ describe("canonical scan contract", () => {
["src/handler.py", true],
["src/a:b.py", true],
["report:summary.py", true],
+ ["é:helper.ts", true],
+ ["./é:helper.ts", true],
["src/name with spaces.py", true],
["src/日本語.py", true],
["./src//handler.py", true],
@@ -1109,6 +1111,7 @@ describe("canonical scan contract", () => {
["/outside.py", false],
["C:/outside.py", false],
["C:outside.py", false],
+ ["c:outside.py", false],
["src\\outside.py", false],
[".", false],
["src/\u0000outside.py", false],