change test_runner.py to be cwd independent by calling subprocess.run with cwd arg.
What changed, and why it matters
This is a small developer-tooling fix for Bitcoin Core's fuzzing test runner. It changes how a Python script calls Git so the script works correctly no matter which folder you run it from. There is no security vulnerability or user-facing risk.
No security action needed. Treat as normal code-quality/test-infrastructure maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies test/fuzz/test_runner.py to make subprocess.run calls to git grep current-working-directory independent by passing the cwd=src_dir argument and using relative paths inside that directory. Previously the script constructed absolute paths and relied on the caller’s working directory. This is a robustness/correctness improvement for the fuzzing test harness, not a security patch.
Changed components
test/fuzz/test_runner.pyInspect captured patch +4 / −2
diff --git a/test/fuzz/test_runner.py b/test/fuzz/test_runner.py
index d31d95ed..503acdc1 100755
--- a/test/fuzz/test_runner.py
+++ b/test/fuzz/test_runner.py
@@ -208,10 +208,11 @@ def transform_process_message_target(targets, src_dir):
p2p_msg_target = "process_message"
if (p2p_msg_target, {}) in targets:
lines = subprocess.run(
- ["git", "grep", "--function-context", "ALL_NET_MESSAGE_TYPES{", src_dir / "src" / "protocol.h"],
+ ["git", "grep", "--function-context", "ALL_NET_MESSAGE_TYPES{", "src/protocol.h"],
check=True,
stdout=subprocess.PIPE,
text=True,
+ cwd=src_dir,
).stdout.splitlines()
lines = [l.split("::", 1)[1].split(",")[0].lower() for l in lines if l.startswith("src/protocol.h- NetMsgType::")]
assert len(lines)
@@ -226,10 +227,11 @@ def transform_rpc_target(targets, src_dir):
rpc_target = "rpc"
if (rpc_target, {}) in targets:
lines = subprocess.run(
- ["git", "grep", "--function-context", "RPC_COMMANDS_SAFE_FOR_FUZZING{", src_dir / "src" / "test" / "fuzz" / "rpc.cpp"],
+ ["git", "grep", "--function-context", "RPC_COMMANDS_SAFE_FOR_FUZZING{", "src/test/fuzz/rpc.cpp"],
check=True,
stdout=subprocess.PIPE,
text=True,
+ cwd=src_dir,
).stdout.splitlines()
lines = [l.split("\"", 1)[1].split("\"")[0] for l in lines if l.startswith("src/test/fuzz/rpc.cpp- \"")]
assert len(lines)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.