Skip to content

Allow tar in bootstrap.ps1 Only Through Get-TarPath - #2476

Merged
ptr727 merged 4 commits into
developfrom
fix/bootstrap-tar-allow-list
Oct 7, 2026
Merged

ptr727 merged 4 commits into
developfrom
fix/bootstrap-tar-allow-list

Conversation

@ptr727

@ptr727 ptr727 commented Oct 7, 2026

Copy link
Copy Markdown
Owner

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.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.

Part of #2471.

Verification

  • A mutation probe replaced the extraction line with each of these, and the test failed for every one:
    • a bare tar
    • & tar
    • & "$env:ProgramFiles\Git\usr\bin\tar.exe"
    • & /usr/bin/tar
    • a reordered Get-Command -ErrorAction SilentlyContinue tar
    • $t = 'tar'; & $t
    • Start-Process -FilePath tar.exe
    • die 'x'; tar ...
  • The unchanged file passes.
  • A line check cannot reach a computed name such as ('t' + 'ar'), and the docstring says so by scoping its claim to lines that name tar.
  • ruff check and format are clean.
  • local-strict-review: round 1 raised one finding, a docstring that overclaimed, fixed in 9c83788. Round 2 found nothing.

🤖 Generated with Claude Code

ptr727 and others added 2 commits October 7, 2026 07:26
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]>
Copilot AI lite review requested due to automatic review settings October 7, 2026 14:30
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Repository: ptr727/ProjectTemplate/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0e4edf45-9061-4858-a04d-05a397ec3a47
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.47%. Comparing base (f9a6573) to head (66f6f59).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #2476   +/-   ##
========================================
  Coverage    58.47%   58.47%           
========================================
  Files           16       16           
  Lines         8062     8062           
========================================
  Hits          4714     4714           
  Misses        3348     3348           
Flag Coverage Δ
python-3.13 58.47% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The moderate P1 finding regarding tar.gz.exe matching remains unresolved.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Strengthens the bootstrap regression guard to allow tar references only through Get-TarPath.

Changes:

  • Replaces invocation-pattern checks with an allow-list.
  • Covers path-qualified and indirect tar references.
  • Updates documentation for permitted references.
File Summary
tests/​test_bootstrap.py Updates the static tar allow-list test; its archive exception can incorrectly allow a path-qualified tar.gz.exe executable.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/test_bootstrap.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Two unresolved review findings must be addressed before approval.

Review effort: Lite
Findings: None

Resolved since last review (1)
Previously missed (1)

In code that hasn't changed since last review

Medium severity 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.

@ptr727

ptr727 commented Oct 7, 2026

Copy link
Copy Markdown
Owner Author

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 AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The allow-list still has validation gaps that must be addressed before approval.

Review effort: Lite
Findings: None

@ptr727

ptr727 commented Oct 7, 2026

Copy link
Copy Markdown
Owner Author

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.

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.

2 participants