Skip to content

fix: #417/#424 hook-leak security tests no longer skip the whole Windows CI leg - #439

Merged
fdaviddpt merged 2 commits into
mainfrom
fix/432
Aug 29, 2026
Merged

fdaviddpt merged 2 commits into
mainfrom
fix/432

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

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

  • Extracted _find_git_bash() out of tests/test_hooks_json.py into a new shared module, tests/_bash_runner.py, and added resolve_bash() alongside it, which covers the non-Windows case (plain shutil.which("bash")) as well.
  • tests/test_hooks_json.py now imports find_git_bash from the shared module instead of keeping its own private copy.
  • Both lane files now skip only when 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".
  • Added tests/test_bash_runner_432.py to pin 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.
  • A follow-up commit on this branch (from this run's own auditor spawn) rebuilt both lane files' subprocess env dicts as {**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 unset these 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).

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The hook-leak security tests skip on Windows although a working Git Bash runner already exists in the suite

1 participant