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

test(workbench): release the SQLite writer after lock acquisition (#2585)

Michael D'Angelo514de3d48982
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 120a05885..a00a347b5 100644
--- a/plugins/codex-security/tests/test_workbench_prompt_only_scan.py
+++ b/plugins/codex-security/tests/test_workbench_prompt_only_scan.py
@@ -317,7 +317,7 @@ def test_prompt_scan_revalidates_target_after_database_lock_wait(
calls = 0
args = prompt_scan_arguments(target, tmp_path)
- acquiring = Event()
+ released = None
def inspect_identity(*args, **kwargs):
nonlocal calls
@@ -342,13 +342,14 @@ def test_prompt_scan_revalidates_target_after_database_lock_wait(
return getattr(connection, name)
def execute(self, sql, *parameters):
+ nonlocal released
if (
writer_arrival == "before_hash"
and sql == "BEGIN IMMEDIATE"
- and not acquiring.is_set()
+ and released is None
):
blocker.execute("BEGIN IMMEDIATE")
- acquiring.set()
+ released = pool.submit(release_writer)
try:
return connection.execute(sql, *parameters)
except sqlite3.OperationalError:
@@ -358,7 +359,6 @@ def test_prompt_scan_revalidates_target_after_database_lock_wait(
raise
def release_writer():
- assert acquiring.wait(timeout=10)
if target_changes:
source.write_text("changed during lock acquisition\n")
blocker.commit()
@@ -368,7 +368,6 @@ def test_prompt_scan_revalidates_target_after_database_lock_wait(
ThreadPoolExecutor(max_workers=1) as pool,
mock.patch.dict(globals_, {"scan_target_identity": inspect_identity}),
):
- released = pool.submit(release_writer) if writer_arrival == "before_hash" else None
if target_changes:
with pytest.raises(SystemExit, match="target changed"):
start(ContendedConnection(), args, headless_standard=False)
@@ -386,7 +385,6 @@ def test_prompt_scan_revalidates_target_after_database_lock_wait(
assert not connection.in_transaction
assert connection.execute("PRAGMA busy_timeout").fetchone()[0] == 5000
finally:
- acquiring.set()
blocker.close()
connection.close()
assert calls == (2 if writer_arrival == "before_hash" else 3)