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(windows): normalize canonical scan path casing (#64)

Hồ Quang Anhc17d0744dc32
diff --git a/sdk/typescript/_bundled_plugin/scripts/deep_scan_workbench.py b/sdk/typescript/_bundled_plugin/scripts/deep_scan_workbench.py
index caaeedbb2..8e56da531 100644
--- a/sdk/typescript/_bundled_plugin/scripts/deep_scan_workbench.py
+++ b/sdk/typescript/_bundled_plugin/scripts/deep_scan_workbench.py
@@ -239,7 +239,7 @@ def deep_scan_path(
resolved.relative_to(scan_dir)
except (OSError, RuntimeError, ValueError) as exc:
raise SystemExit(f"{label} must be an existing path inside the scan directory.") from exc
- if resolved != supplied.absolute():
+ if resolved.as_posix().lower() != supplied.absolute().as_posix().lower():
raise SystemExit(f"{label} must be a canonical non-symlink path.")
if kind == "file" and not resolved.is_file():
raise SystemExit(f"{label} must be a regular file.")
diff --git a/sdk/typescript/_bundled_plugin/scripts/finalize_scan_contract.py b/sdk/typescript/_bundled_plugin/scripts/finalize_scan_contract.py
index 035cd1bed..5e5599cb2 100644
--- a/sdk/typescript/_bundled_plugin/scripts/finalize_scan_contract.py
+++ b/sdk/typescript/_bundled_plugin/scripts/finalize_scan_contract.py
@@ -316,7 +316,7 @@ def _require_scan_directory(scan_dir: Path) -> Path:
resolved = scan_dir.resolve(strict=True)
except OSError as exc:
raise ContractError("scan directory: expected an existing non-symlink directory") from exc
- if resolved != scan_dir:
+ if resolved.as_posix().lower() != scan_dir.as_posix().lower():
raise ContractError("scan directory: expected a canonical non-symlink directory")
return resolved
@@ -327,7 +327,7 @@ def _validate_scan_local_output_path(scan_dir: Path, path: Path, relative_path:
resolved_parent.relative_to(scan_dir)
except (OSError, RuntimeError, ValueError) as exc:
raise ContractError(f"{relative_path}: expected a path inside the scan directory") from exc
- if resolved_parent != path.parent or path.is_symlink():
+ if resolved_parent.as_posix().lower() != path.parent.as_posix().lower() or path.is_symlink():
raise ContractError(
f"{relative_path}: expected a non-symlink path inside the scan directory"
)
diff --git a/sdk/typescript/_bundled_plugin/scripts/workbench_db.py b/sdk/typescript/_bundled_plugin/scripts/workbench_db.py
index e95aad9b3..d142da291 100644
--- a/sdk/typescript/_bundled_plugin/scripts/workbench_db.py
+++ b/sdk/typescript/_bundled_plugin/scripts/workbench_db.py
@@ -3435,7 +3435,7 @@ def artifact_path(scan_dir: Path, file_name: str, *, required: bool) -> Path | N
raise SystemExit(
f"{file_name}: expected a regular file inside the scan directory."
) from exc
- if resolved != candidate or not candidate.is_file():
+ if resolved.as_posix().lower() != candidate.as_posix().lower() or not candidate.is_file():
raise SystemExit(f"{file_name}: expected a regular non-symlink file.")
return resolved
@@ -3449,7 +3449,7 @@ def require_canonical_scan_directory(scan_dir: Path) -> Path:
raise SystemExit(
"Scan directory must be an existing canonical non-symlink directory."
) from exc
- if not stat.S_ISDIR(metadata.st_mode) or resolved != scan_dir:
+ if not stat.S_ISDIR(metadata.st_mode) or resolved.as_posix().lower() != scan_dir.as_posix().lower():
raise SystemExit("Scan directory must be an existing canonical non-symlink directory.")
return scan_dir