Repository navigation
Compare Directories by File Identity in tool_shadow_path - #1969
Conversation
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.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Repository: ptr727/ProjectTemplate/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1969 +/- ##
==========================================
Coverage ? 55.41%
==========================================
Files ? 16
Lines ? 7247
Branches ? 0
==========================================
Hits ? 4016
Misses ? 3231
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
-efidentity 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.
… 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)
Summary
tool_shadow_path(host-setup/linux/install-tools.sh) compared a PATH entry to$BIN_DIRbyliteral 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_notethen reported it as installedoutside
$BIN_DIR, andapply_toolin--upgrademode calledtool_unshadow, prompting toremove the very binary
--upgradewas about to reinstall.Adds a file-identity (
-ef) check alongside the literal comparison, gated on the PATH entry beingabsolute. A local-strict-review pass on an earlier version of this fix (ungated) found that an
ungated
-efcheck could let a relative PATH entry that merely resolves to$BIN_DIRfrom thecaller's current directory short-circuit the walk and mask a real, later, absolute shadow. Gating
on
is_absolutecloses that without losing the identity check for the doubled-slash/dot-segmentcase, and, as a side effect, also stops a directory symlinked to
$BIN_DIRfrom being reported andremoved as a shadow through the alias.
Closes on promotion: #1865
Verification
bash -n,shellcheck, andshfmt -dclean on the changed file.the relative-entry masking regression above, the second finding nothing further.
tool_shadow_pathfunction verifies: a doubled-slashspelling of
$BIN_DIRreports no shadow, a dot-segment spelling reports no shadow, and arelative PATH entry that resolves to
$BIN_DIRfrom 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