Full security and code quality audit fixes#733
Open
GaltRanch wants to merge 2 commits intocurly60e:masterfrom
Open
Full security and code quality audit fixes#733GaltRanch wants to merge 2 commits intocurly60e:masterfrom
GaltRanch wants to merge 2 commits intocurly60e:masterfrom
Conversation
Security (Critical): - Eliminate all shell=True command injection vectors (~95 instances in ppi.py, spvblock.py) - Replace subprocess curl calls with requests library - Add input validation (fiat code allowlist, IP address validation) - Replace weak random.randint/choice with secrets module for crypto ops - Remove token/credential exposure from print statements - Add path traversal prevention in config.py - Create .conf.example templates, scrub local credentials Stability: - Replace 63 bare except clauses with specific exceptions + logging - Fix file handle leaks with context managers (lnd.py, apisnd.py) - Add threading.Lock for race conditions in clock/data.py - Cap unbounded list growth (MAX_HISTORY_LEN=50) - Add timeout=10 to ~50 requests calls missing timeouts Maintainability: - Extract _load_macaroon() helper (dedup 69 instances in PyBlock.py) - Extract _load_lnd_config() helper (dedup 33 instances in nodeconnection.py) - Normalize json import (simplejson with stdlib fallback) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Sorry @GaltRanch, your pull request is larger than the review limit of 150000 diff characters
β¦conditions - Replace all shell=True subprocess calls with Python-native processing (nodeconnection.py, SPV/nodeconnection.py, SPV/ppi.py) - Mask sensitive inputs (private keys, passwords, tokens) with getpass - Add threading.Lock to block_explorer.py shared state - Use json.loads() instead of fragile string splitting in apisnd.py - Add path validation before file open in apisnd.py - Replace random.randint with secrets.randbelow for mining nonces - Fix destructive exception handlers in clone.py and feed.py - Replace bare except clauses with specific exceptions + logging - Remove unused imports (psutil, xmltodict, block_visualizer, base64, say) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
shell=Truewith user input/interpolation) acrossppi.pyandSPV/spvblock.py, replacing withrequestslibrary or safe list-form subprocessexceptclauses with specific exception types + structured logging across 10 filesrandom.randint/choiceβsecretsmodule; add input validation (fiat allowlist, IP validation); path traversal prevention in config; remove token exposure from stdoutthreading.Lockfor shared state inclock/data.py,timeout=10on ~50 requests calls, bounded list growth_load_macaroon()(69x in PyBlock.py),_load_lnd_config()(33x in nodeconnection.py + 2x in PyBlock.py).conf.exampletemplates for safe onboarding without credential exposureFiles changed: 21 | +1057 / -725 lines
Test plan
python3 -m py_compilepasses on all 18 modified.pyfiles (verified locally)pyblockmain menurateSXList/rateSXGraphwith valid fiat code (e.g., USD)π€ Generated with Claude Code