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: preserve hyphens in scan directory names (#2102)

Michael D'Angelode4d17f547d8
diff --git a/plugins/codex-security/scripts/workbench_scan_start.py b/plugins/codex-security/scripts/workbench_scan_start.py
index c9326f890..fa6885b30 100644
--- a/plugins/codex-security/scripts/workbench_scan_start.py
+++ b/plugins/codex-security/scripts/workbench_scan_start.py
@@ -30,7 +30,10 @@ from workbench_validation import optional_text
def safe_segment(value: str) -> str:
- return re.sub(r"[^\w.-]", "-", value).strip("-") or "scan"
+ segment = re.sub(r"[^\w.-]", "-", value)
+ if segment != value:
+ segment = segment.strip("-")
+ return segment or "scan"
def compact_timestamp() -> str:
diff --git a/plugins/codex-security/tests/test_workbench_prompt_only_scan.py b/plugins/codex-security/tests/test_workbench_prompt_only_scan.py
index d25f5eb59..3c116be86 100644
--- a/plugins/codex-security/tests/test_workbench_prompt_only_scan.py
+++ b/plugins/codex-security/tests/test_workbench_prompt_only_scan.py
@@ -126,7 +126,7 @@ def test_headless_standard_scan_starts_without_setup_opt_out(tmp_path: Path) ->
def test_headless_standard_scan_joins_only_the_owning_thread(tmp_path: Path) -> None:
state_dir = tmp_path / "state"
- target = tmp_path / "target"
+ target = tmp_path / "target-"
target.mkdir()
(target / "fixture.py").write_text("print('fixture')\n")
scan_root = tmp_path / "scans"
@@ -138,6 +138,7 @@ def test_headless_standard_scan_joins_only_the_owning_thread(tmp_path: Path) ->
)
assert first["startDisposition"] == "created"
+ assert Path(first["scan"]["scanDir"]).parent == scan_root / target.name
assert joined["startDisposition"] == "joined"
assert joined["scan"]["scanId"] == first["scan"]["scanId"]
assert joined["scan"]["handoffClaimToken"] == first["scan"]["handoffClaimToken"]