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

refactor: simplify scan runtime bookkeeping (#903)

mldangelo-oaif7a8a2b064f3
diff --git a/plugins/codex-security/mcp-app/src/deep-scan/coordinator.ts b/plugins/codex-security/mcp-app/src/deep-scan/coordinator.ts
index 905c0c9a8..a76f737f5 100644
--- a/plugins/codex-security/mcp-app/src/deep-scan/coordinator.ts
+++ b/plugins/codex-security/mcp-app/src/deep-scan/coordinator.ts
@@ -959,7 +959,7 @@ export class DeepScanCoordinator {
throw new Error("Deep Scan ended without a successfully reduced Standard scan.");
}
return {
- reason: stopReason ?? "capped",
+ reason: stopReason,
omittedWorkerIds: unique(omittedWorkerIds),
canceledWorkerIds: unique(canceledWorkerIds),
accepted,
diff --git a/plugins/codex-security/scripts/windows_scan_local_files.py b/plugins/codex-security/scripts/windows_scan_local_files.py
index 0c5581740..c67c86eb6 100644
--- a/plugins/codex-security/scripts/windows_scan_local_files.py
+++ b/plugins/codex-security/scripts/windows_scan_local_files.py
@@ -465,7 +465,7 @@ def open_read_fd(scan_dir: Path, relative_path: str, context: str) -> int:
flags=_FILE_FLAG_OPEN_REPARSE_POINT,
)
assert handle is not None and handle.value is not None
- try:
+ with handle:
_verify_regular_file(handle.value, path)
raw_handle = handle.detach()
try:
@@ -474,8 +474,6 @@ def open_read_fd(scan_dir: Path, relative_path: str, context: str) -> int:
except BaseException:
_close_handle(raw_handle)
raise
- finally:
- handle.close()
except WindowsScanLocalFileError as exc:
raise WindowsScanLocalFileError(
exc.errno,
diff --git a/plugins/codex-security/scripts/workbench_db.py b/plugins/codex-security/scripts/workbench_db.py
index 161756ee0..282cd0c76 100644
--- a/plugins/codex-security/scripts/workbench_db.py
+++ b/plugins/codex-security/scripts/workbench_db.py
@@ -2486,7 +2486,7 @@ def require_reviewed_patch_applied(
checkout = checkout_root
copy_directory_excluding(target, checkout, excluded)
else:
- checkout = copy_git_worktree_files(target, checkout_root, excluded)
+ copy_git_worktree_files(target, checkout_root, excluded)
arguments = ["apply", "--reverse", "--whitespace=nowarn"]
if unversioned:
arguments.append("--no-index")
diff --git a/plugins/codex-security/scripts/workbench_saved_results.py b/plugins/codex-security/scripts/workbench_saved_results.py
index a32b96513..10519b8e9 100644
--- a/plugins/codex-security/scripts/workbench_saved_results.py
+++ b/plugins/codex-security/scripts/workbench_saved_results.py
@@ -1260,7 +1260,6 @@ def preserve_scan_results_locked(
for relative, digest in retained_sources.items()
):
raise ContractError("Stopped scan source digests could not be frozen.")
- frozen_source_digests = retained_sources
with connection:
connection.execute(
"UPDATE scans SET retained_source_digests_json = ? "
diff --git a/sdk/typescript/src/cli.ts b/sdk/typescript/src/cli.ts
index 9c00f32af..81e90a503 100644
--- a/sdk/typescript/src/cli.ts
+++ b/sdk/typescript/src/cli.ts
@@ -8348,10 +8348,10 @@ async function executeScan(
if (status.kind === "dispatch") {
dashboard.setStage(scanPhase(status.phase));
}
- if (message !== null) dashboard.note(message);
+ dashboard.note(message);
return;
}
- if (message === null || progress === null) return;
+ if (progress === null) return;
progress.stopTimer();
progress.stage(message);
progress.startTimer(runningMessage());
@@ -9242,7 +9242,7 @@ export function parseCodexOverrides(
return result;
}
-function workerStatusMessage(status: ScanWorkerStatus): string | null {
+function workerStatusMessage(status: ScanWorkerStatus): string {
if (status.kind === "preflight") {
if (status.delegation === "unavailable") {
return "Preflight: worker delegation unavailable; continuing without delegated workers.";