Skip to content

Commit c4d8e63

Browse files
Potential fix for pull request finding 'CodeQL / Uncontrolled command line'
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 1c02608 commit c4d8e63

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎tools/bitcoin_core_main_smoke.py‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,24 @@ def main() -> None:
2929
parser.add_argument("--bitcoind", default="bitcoind")
3030
parser.add_argument("--bitcoin-cli", default="bitcoin-cli")
3131
arguments = parser.parse_args()
32+
allowed_bitcoind = {"bitcoind"}
33+
allowed_bitcoin_cli = {"bitcoin-cli"}
34+
if arguments.bitcoind not in allowed_bitcoind:
35+
raise RuntimeError("unsupported bitcoind executable")
36+
if arguments.bitcoin_cli not in allowed_bitcoin_cli:
37+
raise RuntimeError("unsupported bitcoin-cli executable")
3238

3339
with tempfile.TemporaryDirectory(prefix="codex32-core-main-") as temporary:
3440
datadir = Path(temporary)
41+
real_bitcoind = shutil.which(arguments.bitcoind)
42+
if real_bitcoind is None:
43+
raise RuntimeError("bitcoind was not found")
3544
real_cli = shutil.which(arguments.bitcoin_cli)
3645
if real_cli is None:
3746
raise RuntimeError("bitcoin-cli was not found")
3847
daemon = subprocess.Popen(
3948
[
40-
arguments.bitcoind,
49+
real_bitcoind,
4150
"-chain=main",
4251
f"-datadir={datadir}",
4352
"-server=1",

0 commit comments

Comments
 (0)