Skip to content

Compare Directories by File Identity in tool_shadow_path - #1969

Merged
ptr727 merged 1 commit into
developfrom
feature/auto-1865
Sep 28, 2026
Merged

ptr727 merged 1 commit into
developfrom
feature/auto-1865

Conversation

@ptr727

@ptr727 ptr727 commented Sep 28, 2026

Copy link
Copy Markdown
Owner

Summary

tool_shadow_path (host-setup/linux/install-tools.sh) compared a PATH entry to $BIN_DIR by
literal string equality, so a doubled-slash or dot-segment spelling of $BIN_DIR (for example
$BIN_DIR// or a /./ segment) named the same directory but did not match, and the walk reported
$BIN_DIR's own managed binary as a shadow of itself. tool_note then reported it as installed
outside $BIN_DIR, and apply_tool in --upgrade mode called tool_unshadow, prompting to
remove the very binary --upgrade was about to reinstall.

Adds a file-identity (-ef) check alongside the literal comparison, gated on the PATH entry being
absolute. A local-strict-review pass on an earlier version of this fix (ungated) found that an
ungated -ef check could let a relative PATH entry that merely resolves to $BIN_DIR from the
caller's current directory short-circuit the walk and mask a real, later, absolute shadow. Gating
on is_absolute closes that without losing the identity check for the doubled-slash/dot-segment
case, and, as a side effect, also stops a directory symlinked to $BIN_DIR from being reported and
removed as a shadow through the alias.

Closes on promotion: #1865

Verification

  • bash -n, shellcheck, and shfmt -d clean on the changed file.
  • Two rounds of a local-strict-review pass (full-file context, adversarial), the first catching
    the relative-entry masking regression above, the second finding nothing further.
  • A constructed test extracting the shipped tool_shadow_path function verifies: a doubled-slash
    spelling of $BIN_DIR reports no shadow, a dot-segment spelling reports no shadow, and a
    relative PATH entry that resolves to $BIN_DIR from the cwd does not mask a real, later,
    absolute shadow. Each case was proven to fail against the pre-fix (or, for the third case, the
    intermediate) code and pass with the final fix.

🤖 Generated with Claude Code

tool_shadow_path compared a PATH entry to $BIN_DIR by literal string
equality, so a doubled-slash or dot-segment spelling of $BIN_DIR (for
example $BIN_DIR// or a /./ segment) named the same directory but did
not match, and the walk reported $BIN_DIR's own managed binary as a
shadow of itself. Add a file-identity (-ef) check alongside the
literal comparison, gated on the entry being absolute so a relative
PATH entry that happens to resolve to $BIN_DIR from the caller's
current directory can never short-circuit the walk past a real,
later shadow. "-ef" is false rather than an error when either side is
empty or does not exist, so it is safe for every PATH entry the walk
sees.
@ptr727 ptr727 added the comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses label Sep 28, 2026
Copilot AI lite review requested due to automatic review settings September 28, 2026 04:57
@coderabbitai

coderabbitai Bot commented Sep 28, 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: 137d24ce-527e-4d47-94f4-990d4faff38a


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 Sep 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (develop@2576755). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #1969   +/-   ##
==========================================
  Coverage           ?   55.41%           
==========================================
  Files              ?       16           
  Lines              ?     7247           
  Branches           ?        0           
==========================================
  Hits               ?     4016           
  Misses             ?     3231           
  Partials           ?        0           
Flag Coverage Δ
python-3.13 55.41% <ø> (?)

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

🟢 Approval recommended

The change is narrowly scoped, matches the stated failure mode, and the absolute-only gating avoids the relative-PATH masking regression.

Review effort: Lite
Findings: None

What changed in this PR

This PR fixes a false-positive “shadowing” report in tool_shadow_path by comparing PATH entries to $BIN_DIR by directory identity (inode) in addition to literal string equality, avoiding self-shadow detection when $BIN_DIR is spelled with doubled slashes or dot segments.

Changes:

  • Add an absolute-only -ef identity check so $BIN_DIR// and $BIN_DIR/./... are treated as $BIN_DIR.
  • Keep the early-return behavior safe by gating identity checks to absolute PATH entries, preventing relative entries from short-circuiting the scan.
File Description
host-setup/​linux/​install-tools.sh Updates tool_shadow_path to treat $BIN_DIR-equivalent absolute PATH entries as the same directory via -ef.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@ptr727
ptr727 merged commit ec9995b into develop Sep 28, 2026
11 checks passed
@ptr727
ptr727 deleted the feature/auto-1865 branch September 28, 2026 05:01
ptr727 added a commit that referenced this pull request Sep 28, 2026
… and Setup Tooling (#2000)

## Summary

Promotes develop to main, carrying the 16 pull requests merged to
develop since #1943.

- **Wait-loop guard (requirement 7):**
[#1999](#1999) credits a
comparison bound only inside a `[`, `[[`, or `test` invocation, and
[#1996](#1996) reconciles
the requirement's README count and diagram with its hook.
- **Registry:**
[#1994](#1994) and
[#1976](#1976) record
Vantage-Config's line endings and description.
- **Scripts and tooling:**
- [#1988](#1988) and
[#1972](#1972) harden
`ruleset_id()`.
- [#1974](#1974) and
[#1949](#1949) fix
`pr_review.py` `reply --match` and `wait`.
- [#1969](#1969),
[#1964](#1964),
[#1954](#1954) and
[#1951](#1951) fix
host-setup tool shadowing, shims, hook ownership and dpkg ownership
checks.
- **Gates and audit:**
- [#1980](#1980) triages a
path collision.
- [#1967](#1967) and
[#1962](#1962) tighten
sha-pin and version-literal checks.
- [#1956](#1956) keeps a
folded `if:` visible to the interface audit.

Closes #1636
Closes #1639
Closes #1948
Closes #1971
Closes #1718
Closes #1934
Closes #1877
Closes #1880
Closes #1865
Closes #1889
Closes #1966
Closes #1906
Closes #1935
Closes #1901
Closes #1905
Closes #1866
Closes #1897

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants