fix(security-guidance): make ** glob patterns match zero-depth paths - #87079
Open
anishsamant wants to merge 1 commit into
Open
fix(security-guidance): make ** glob patterns match zero-depth paths#87079anishsamant wants to merge 1 commit into
anishsamant wants to merge 1 commit into
Conversation
_glob_match delegated to fnmatch, where a bare * already crosses '/', so **/*.ts requires a literal '/' and silently excludes top-level files from security-patterns.json rules even though the docstring promises "** matches any depth". Since these are security rules, the failure mode is silent non-coverage with no error. Replace it with a small glob-to-regex translator where **/ matches zero or more path segments, so **/*.ts matches both config.ts and src/a.ts. Fixes anthropics#86545 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
elenyscleaning-dotcom
approved these changes
Aug 16, 2026
This was referenced Aug 16, 2026
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.
_glob_match delegated to fnmatch, where a bare * already crosses '/', so /*.ts requires a literal '/' and silently excludes top-level files from security-patterns.json rules even though the docstring promises " matches any depth". Since these are security rules, the failure mode is silent non-coverage with no error — a rule that never fires looks identical to a rule that passed.
Replace it with a small glob-to-regex translator:
**/matches zero or more path segments (so**/*.tsmatches bothconfig.tsandsrc/a.ts), a bare**matches any depth including/, and*,?,[...]keep their existing fnmatch-equivalent meaning. Thebasename fallback in
_hit()is unchanged.Verified
config.tsandsrc/a.tsboth match**/*.ts(previously only the latter did)utils/**/*.tsmatchesutils/x.ts,utils/sub/x.ts, and correctly excludesother/x.ts*.tsstill matches via basename fallback for nested pathsexclude_paths) still works as beforeFixes #86545