Repository navigation
Conversation
…ows CI leg (#432) Both carried a blanket skipif(sys.platform == "win32"), so the leg was collected, skipped, and reported green with zero coverage -- for one release-blocking security regression test. tests/test_hooks_json.py already proved a real bash is reachable there via Git Bash; extract that resolution into tests/_bash_runner.py, share it across all three files, and narrow the skip to "no usable bash found." Co-Authored-By: Max <noreply>
…l Windows Git Bash Follow-up to the previous commit on this branch, from this repo's own auditor spawn: the two rewritten env dicts in test_hook_cwd_leak_417.py and test_transcript_path_leak_424.py were built from scratch (no SystemRoot, no native PATH) and, under the old blanket skip, never actually executed on Windows. Narrowing that skip to "no bash found" means they now spawn a real Windows Git Bash for the first time -- which a from-scratch env risks failing to spawn at all, unrelated to the #417/#424 mechanism under test. Inherit os.environ first, same as test_hooks_json.py's own Git-Bash tests already do, with the explicit keys still overriding afterward. Co-Authored-By: Max <noreply>
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.
Closes #432
tests/test_hook_cwd_leak_417.py and tests/test_transcript_path_leak_424.py -- the regression tests for two ambient-environment-variable-leak security fixes, one of them release-blocking -- carried a blanket
pytestmark = pytest.mark.skipif(sys.platform == "win32"). The windows-latest CI leg collected and skipped both, reporting the leg green while coverage there was zero: a check that never ran rendering exactly like a check that found nothing. tests/test_hooks_json.py already proved a real bash was reachable on that leg via Git Bash (_find_git_bash()), so the skip was copied from a precedent rather than derived from an actual limitation.What changed
_find_git_bash()out of tests/test_hooks_json.py into a new shared module, tests/_bash_runner.py, and addedresolve_bash()alongside it, which covers the non-Windows case (plainshutil.which("bash")) as well.find_git_bashfrom the shared module instead of keeping its own private copy.resolve_bash()returns None (no usable bash found at all, on any platform) instead of skipping on the whole Windows platform, and invoke the resolved bash path instead of the literal string "bash".resolve_bash()'s behaviour: a positive control that it finds a real bash on this platform, a control that it reports None when nothing is reachable, a reasoned (not observed -- see below) check of the Windows-Git-Bash-over-PATH preference logic, and a control proving a resolved-but-nonexistent bash path fails loudly (FileNotFoundError) rather than silently passing or silently skipping.{**os.environ, <explicit overrides>}instead of from-scratch dicts, matching test_hooks_json.py's own env-construction pattern -- the from-scratch dicts never ran under a real interpreter on Windows before (always skipped), and the auditor flagged that a Windows-native Git Bash process needs SystemRoot and friends from the native environment to spawn at all.What is observed vs. reasoned
This cannot be run under Windows locally. Everything about Git Bash's actual behaviour under this change -- whether it resolves correctly, whether it spawns with the inherited-env fix, and above all whether the
unsetthese tests guard behaves identically under Git Bash's environment-inheritance semantics as under macOS/Linux bash -- is reasoned, not observed, and will only be confirmed once the windows-latest CI leg runs on this branch. If CI disagrees, that is the real discovery this issue was written to surface, and is worth more than the issue itself.Locally (macOS): the four affected test files (
test_bash_runner_432.py,test_hook_cwd_leak_417.py,test_transcript_path_leak_424.py,test_hooks_json.py) pass, 16 passed / 40 skipped (the skips are pre-existing Windows-only/pwsh-only tests in test_hooks_json.py, unrelated to this change). Full suite: 1795 passed, 43 skipped, no failures.Review
Spawned reviewer (Explore) returned NO FINDINGS after checking the extraction, the subprocess call sites, and the new pinning tests for tautology. Spawned auditor (oss:auditor) returned one finding -- the from-scratch env dicts described above -- fixed in the follow-up commit on this branch; re-ran the affected tests after the fix (still 16 passed / 40 skipped, no new lint findings).