fix: avoid shell in miner hardware probes#4209
Conversation
|
Welcome to RustChain! Thanks for your first pull request. Before we review, please make sure:
Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150) A maintainer will review your PR soon. Thanks for contributing! |
cerredz
left a comment
There was a problem hiding this comment.
Approved. This is a scoped hardening change: the shell pipelines are replaced by fixed argv calls, the POWER8 /proc/cpuinfo fallback no longer shells out through cat | grep | cut, and the parser tests cover the expected lscpu / free -g shapes.
Validation I ran:
python -m pytest tests\\test_miner_hardware_probes.py -q=> 4 passedpython -m py_compile miners\\linux\\rustchain_linux_miner.py miners\\power8\\rustchain_power8_miner.py tests\\test_miner_hardware_probes.py=> passedgit diff --check origin/main...HEAD=> passed
Non-blocking residual debt: _run_cmd() still catches all exceptions and returns an empty string, matching the pre-existing fallback behavior. That is acceptable for this patch, but future cleanup could narrow the exception handling or log probe failures.
|
💰 PAID — 8 RTC pending, will confirm in 24h.
What workedRemoves shell pipelines from BOTH miner probes (linux + power8) and replaces them with Python parsers. Solid hardening across two miner paths in a single scoped PR. Second clean PR from you in one day — keep it coming. — auto-triage 2026-05-10 |
Summary:
lscpu | grep ...,nproc, andfree -g | awk ...probes in the Linux and POWER8 miners with argv-based subprocess calls/proc/cpuinfofallback directly instead of invokingcat | grep | cutshell=TrueSecurity note:
Verification:
python -m pytest tests\test_miner_hardware_probes.pyBounty note:
If this is accepted for the bounty loop, please use my GitHub-login miner_id for payout. I am not posting payment details publicly.