feat(filter-diff): support glob patterns in exclude-paths#224
feat(filter-diff): support glob patterns in exclude-paths#224jedp-docker wants to merge 1 commit into
Conversation
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟡 NEEDS ATTENTION
One medium-severity finding in the newly added glob-matching heuristic.
| const isExcluded = (filePath: string): boolean => | ||
| prefixes.some((prefix) => filePath.startsWith(prefix)); | ||
| prefixes.some((pattern) => | ||
| pattern.includes('*') ? matchesGlob(filePath, pattern) : filePath.startsWith(pattern), |
There was a problem hiding this comment.
[MEDIUM] Glob heuristic pattern.includes('*') misses ? and [...] metacharacters
The new heuristic on line 72 routes patterns to matchesGlob only when they contain *. However, path.matchesGlob also supports ? (match any single character) and [...] (character classes), which would silently fall through to startsWith instead.
For example:
file?.ts— passed tostartsWith, treated as a literal prefix string instead of a globsrc/[generated]/— same silent failure
The result is wrong exclusion behaviour with no error thrown — files that should be excluded won't be (or vice versa).
Suggested fix: Broaden the heuristic to detect any glob metacharacter:
const isGlob = (p: string) => /[*?[]/.test(p);
// then:
isGlob(pattern) ? matchesGlob(filePath, pattern) : filePath.startsWith(pattern)Note: the PR description and docs explicitly limit the feature to *-style globs ("Entries containing * are matched…"), so this may be an intentional scope limitation — but if so, it's worth documenting that ?/[...] patterns are unsupported rather than silently mishandled.
175d5bb to
e180664
Compare
Plain prefix matching required listing every package-lock.json path explicitly. With glob support, a single `**/package-lock.json` entry covers all lock files at any depth. Uses `path.matchesGlob` (added in Node v22.5.0/v20.17.0, available in the node24 runtime — no new dependencies). Patterns containing `*` are matched as globs; plain strings continue to use `startsWith` for backward compatibility. Adds a `declare module` augmentation for `matchesGlob` since the @types/node version pinned in pnpm-lock.yaml predates its type definition. The lockfile cannot be updated until a pre-existing exotic subdep in @actions/artifact@6.2.1 is resolved upstream. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
e180664 to
7a63f7e
Compare
Summary
exclude-pathsnow accepts glob patterns in addition to plain path prefixes**/package-lock.jsonentry covers lock files at any depth, instead of listing every path explicitlyImplementation
Uses
path.matchesGlob(added in Node v22.5.0/v20.17.0, available in thenode24runtime — no new dependencies). Patterns containing*are matched as globs; all others continue to usestartsWith.Type augmentation
path.matchesGlobis not typed in@types/node@22.0.0(the version pinned inpnpm-lock.yaml). Normally this would be fixed by bumping@types/node, but that requires regenerating the lockfile — which currently fails due to a pre-existing issue:@actions/artifact@6.2.1declares"@protobuf-ts/plugin": "^2.2.3-alpha.1"as a dependency. Under pnpm'sblockExoticSubdeps: true+resolutionMode: time-based(both required by docker-security/safe-defaults), any freshpnpm installfails withERR_PNPM_EXOTIC_SUBDEP. The frozen lockfile used in CI works fine because--frozen-lockfileskips resolution entirely and the check never fires.The fix (
@protobuf-ts/plugindropped from deps) is already merged in theactions/toolkitsource as@actions/artifact@6.2.2, but that version has not been published to npm yet. Once it is, a normalpnpm installwill work and we can bump@types/nodecleanly.In the meantime,
matchesGlobis declared via a module augmentation infilter-diff.tswith a comment explaining the blocker.Motivation
Without glob support, callers had to enumerate every lock file path explicitly. In docker/internal-agents there are 7
package-lock.jsonfiles — with this change that list collapses to one line:Test plan
**/nameglob matching at root depth, nested depth, non-matching files, mixed diffs, and coexistence with plain prefix patterns🤖 Generated with Claude Code