Repository navigation
Guard hint folders in any letter case - #83
Merged
Merged
Conversation
A case-insensitive volume, the default on macOS, opens ~/.claude/Code-Mode/hints as the hint folder. The file-tool guard compared paths as text, so a path in other letter case got past it. The guard now compares with isUnderAnyCase, which folds letter case and Unicode form. Other callers of isUnder give access, so they keep the exact comparison. Closes #75
Contributor
Author
|
@greptileai review |
Co-authored-by: Gabe <gpavanello@thefork.com>
The guard normalizes HOME and folds letter case. This test checks both at once.
Main is at 0.12.17, so the case-alias guard needs a higher version.
Contributor
Author
|
@greptileai review |
Contributor
Author
|
@greptile review |
1 similar comment
Owner
|
@greptile review |
[Medium impact] The PR appears safe to merge.
|
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.
Intent
The guard denies Write, Edit and NotebookEdit on a guarded folder also when the path spells the folder in other letter case.
A case-insensitive volume, the default on macOS, opens
~/.claude/Code-Mode/hintsas the hint folder.%%{init: {'theme': 'neutral'}}%% flowchart TD A["The model calls Write, Edit or NotebookEdit"] --> B["Find where the path lands: as written and through links"] B --> C["Fold letter case and Unicode form of each path and each guarded folder"] C --> D{"Is a path inside a guarded folder?"} D -->|yes| E["Deny the call with the guard message"] D -->|no| F["Run the file tool"]Drift
None.
Decisions
realpathSync.nativekeeps the spelling of the alias.isUnderstays exact. Its other callers give access:readForProgramskips the Read prompt for saved files, andsaveFunctionaccepts paths underpending/.tests/hints.test.ts.Evidence
Head: the merge of main 548fddb, then two commits. Tree
2422c9cc25a5e7c548fd2603c89d56ab1bb70ec6.Real Claude Code 2.1.296 on a case-insensitive exFAT volume (FUSE on a loop device) on Linux.
Claude Code installs the plugin from a local git copy of the commit, so the plugin loads from
~/.claude/plugins/cache/.A scripted Messages API on localhost sends the Write calls, because the box has no Claude Code login.
Claude Code, the plugin hooks, the Write tool and the volume are real.
Run A uses
drive.mjsfrom the verify skill. Run B usesclaude -p --permission-mode bypassPermissions.Before (main 548fddb with #74, plugin 0.12.17). Long lines end in …:
In run A, the Claude Code prompt for sensitive files stops the alias, not the guard.
With that prompt approved or skipped, as in run B, the alias files land.
A second run with
HOME=$HOME/gives the same lines: #74 denies the lowercase controls, and the four aliases land.After (this branch, plugin 0.12.18). The runs with
HOME=$HOMEandHOME=$HOME/give the same lines:The function-level check from the issue, for HOME
/Users/me,/Users/me/and/Users//me:The new tests on main 548fddb (the import of the new function removed), then on this branch:
Reading map
tests/hints.test.tslines 1554-1555, 1583-1620 and 1633-1649 add tests. No test is removed or weakened..claude-plugin/plugin.jsonline 3, the version.hooks/hints.tslines 505-516 exportisUnderAnyCase.hooks/register.tsxlines 817-825 use it in the guard.Closes #75