fix: match sensitive file names case-insensitively - #3
Merged
Merged
Conversation
walk excluded credentials.json on a case-insensitive filesystem while
update_file("CREDENTIALS.JSON") indexed the same on-disk file, so a full
scan and an incremental update could disagree. Normalize the shared
name predicate with ASCII lowercase.
Regression tests cover uppercase variants through patch and delete-plus-add
update paths, and the case-alias bypass.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Gap (real, reproduced on macOS)
After b58b429,
walkandupdate_fileshareis_sensitive_file_name, but the match stayed case-sensitive. On a case-insensitive filesystem the two paths disagree for the same on-disk file:Index::buildwalks the real directory entrycredentials.json→ excluded.update_file(root, "CREDENTIALS.JSON")resolves the same file through the case-insensitive FS, the name predicate misses, and the sensitive content is indexed under the alias key.Reachable via delete+add git status handling (case-only renames use rename detection, but D+A paths exist) or any direct
update_filecaller.Repro (pre-fix): full scan
search("aliascanary") == [], updatesearch == ["CREDENTIALS.JSON"].Fix
One line: ASCII-lowercase the name inside the single shared predicate (
src/lib.rs). This keeps the policy shared and makes walk/update agree on both case-sensitive and case-insensitive filesystems, and also closes uppercase variants likeA.PEM/CLIENT.P12on Linux.Tests
sensitive_names_match_case_insensitively— uppercase sensitive variants, and near-misses stay indexable.full_scan_and_update_agree_on_case_variant_sensitive_names— actual uppercase files, walk vs update.update_file_case_alias_cannot_bypass_sensitive_policy— the case-alias bypass; verified to FAIL before the fix on this machine.Verification