mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-25 17:18:11 +00:00
Adds a new rule to scripts/check-windows-footguns.py that flags subprocess.run/Popen/call/check_output/check_call(..., text=True, ...) calls missing an explicit encoding= kwarg. On Chinese Windows (cp936/GBK) and other non-UTF-8 default codepages, text=True without encoding= decodes child output with locale.getpreferredencoding(False), crashing _readerthread with UnicodeDecodeError on non-default-codepage bytes (issues #47939, #53428, rule prevents future regressions. Rule design: - Pattern matches 'text=True' / 'text = True' - post_filter skips lines that: - already pass encoding= on the same line - are method definitions (def text) - contain text=True inside string literals - are not subprocess-shaped calls (heuristic via _is_likely_subprocess_call) - Two helper functions: _is_likely_subprocess_call, _looks_like_string_literal - Multi-line calls where subprocess.X( and text=True are on different lines are not flagged (acceptable false negative for a line-based scanner) Also fixes the linter's own footgun: get_staged_files() and get_diff_files() used subprocess.check_output(text=True) without encoding= — now fixed. Suppresses 4 false positives on non-Windows platform-exclusive calls: - tools/voice_mode.py (Termux/Android) - tools/environments/singularity.py (Linux HPC) - plugins/google_meet/cli.py (macOS system_profiler) Test plan: - 21 unit tests in tests/scripts/test_footgun_subprocess_encoding.py - TestDetection: 6 cases verifying the rule flags real subprocess calls - TestSuppression: 7 cases verifying false-positive avoidance - TestHelpers: 7 cases for the two helper functions - TestFullRepoScan: scans the whole tree and asserts the new rule finds only the 7 call sites that PR #60741 fixes (or zero, once #60741 merges) Verified: full-repo scan reports 7 matches on main (the #60741 sites), 4 platform-exclusive calls correctly suppressed, zero false positives. |
||
|---|---|---|
| .. | ||
| test_build_skills_index_health.py | ||
| test_contributor_map.py | ||
| test_footgun_subprocess_encoding.py | ||