You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow tar in bootstrap.ps1 Only Through Get-TarPath - #2476
Answers the Copilot overview note on promotion #2475, "Extend the regression guard to reject path-qualified tar executables". A path to Git's own tar.exe reaches the same MSYS tar without going through PATH.
test_bootstrap_ps1_names_the_system32_tar used to enumerate the forms that resolve tar through PATH, and each review round found another. It is now an allow-list. Outside a .tar.gz archive name, the only non-comment lines in bootstrap.ps1 that may name tar are the exact Get-TarPath definition and its whole-line die '...' message. Any other line naming tar fails, whatever form its invocation takes.
The guard enumerated the invocation forms that resolve tar through PATH, and
each review round found another: a reordered Get-Command, an assignment, a
path-qualified Git tar. It is now an allow-list, outside a .tar.gz archive
name the only lines that may name tar are the Get-TarPath definition and its
die message, so a spelling nobody enumerated fails it too.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Restrict tar.gz exemption to known archive contexts
tests/test_bootstrap.py:605
[P1] Do not exempt arbitrary tar.gz executables
The negative lookahead exempts every tar.gz token, not just the two archive references. A line such as & "$env:ProgramFiles\\Git\\usr\\bin\\tar.gz" therefore produces no stray and bypasses this regression guard, even though it is a path-qualified executable invocation outside Get-TarPath. Match the known archive contexts (or allow-list their complete lines) while scanning tar generally so this form is rejected too.
Copilot previously-missed finding ("[P1] Do not exempt arbitrary tar.gz executables", tests/test_bootstrap.py:605, on 34136bb): real, fixed in 66f6f59. This is the fourth probe at the same exemption, so the exemption no longer patches token shapes. It is now structural: (?<=\.)tar\b(?!\.gz(?![\w.]))|(?<!\.)\btar\b(?!\.gz/). A tar.gz is excused only as an archive extension (name.tar.gz, preceded by a dot) or as a path segment followed by /, and neither can name a program. PowerShell hands a .gz file to its file association rather than running it, and a trailing / makes the segment a directory. A mutation probe replaced the extraction line with each of & "$env:ProgramFiles\Git\usr\bin\tar.gz", & /usr/bin/tar.gz, & tar.gz, tar.gz.exe, x.tar.exe, the Git tar.exe path, a bare tar, $t='tar'; & $t and a reordered Get-Command, and the test failed for every one. An archive extension, a URL segment and the unchanged file all pass. local-strict-review on 66f6f59 found nothing.
Copilot overview on 66f6f59 ("The allow-list still has validation gaps that must be addressed before approval", Findings: None): declined, because the note names no input that escapes the check. Here is the evidence. Every \btar\b token either follows a dot or does not, so it falls under exactly one branch of (?<=\.)tar\b(?!\.gz(?![\w.]))|(?<!\.)\btar\b(?!\.gz/). A token escapes only where it is a complete .tar.gz extension, which PowerShell hands to the file association rather than running, or a tar.gz followed by /, which is a directory segment, never a program. Every other code line naming tar must be the exact Get-TarPath definition or a whole-line single-quoted die message, and neither can invoke anything. The mutation probe in the previous comment fails the test for every executable form tried. A name built at run time, such as ('t' + 'ar'), never spells tar on a line, and the docstring scopes its claim to lines that name tar. The bootstrap.ps1 fix this guards was verified natively on Windows in #2474.
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
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
Answers the Copilot overview note on promotion #2475, "Extend the regression guard to reject path-qualified tar executables". A path to Git's own
tar.exereaches the same MSYS tar without going throughPATH.test_bootstrap_ps1_names_the_system32_tarused to enumerate the forms that resolve tar throughPATH, and each review round found another. It is now an allow-list. Outside a.tar.gzarchive name, the only non-comment lines inbootstrap.ps1that may name tar are the exactGet-TarPathdefinition and its whole-linedie '...'message. Any other line naming tar fails, whatever form its invocation takes.Part of #2471.
Verification
tar& tar& "$env:ProgramFiles\Git\usr\bin\tar.exe"& /usr/bin/tarGet-Command -ErrorAction SilentlyContinue tar$t = 'tar'; & $tStart-Process -FilePath tar.exedie 'x'; tar ...('t' + 'ar'), and the docstring says so by scoping its claim to lines that name tar.local-strict-review: round 1 raised one finding, a docstring that overclaimed, fixed in 9c83788. Round 2 found nothing.🤖 Generated with Claude Code