-
Notifications
You must be signed in to change notification settings - Fork 60
fix(deps): clear audit advisories by dropping rimraf/minimatch and bumping fast-xml-parser #2356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ | |
| * full fetch → evaluate → classify pipeline without system config access. | ||
| */ | ||
|
|
||
| import { runPacScript, findInObject, PACDetector } from '../src/checks/pac.js'; | ||
| import { runPacScript, findInObject, PACDetector, shExpMatch } from '../src/checks/pac.js'; | ||
| import { createPacServer, createHttpServer, withEnv, buildPacScript } from './helpers.js'; | ||
| import childProcess from 'child_process'; | ||
| import fsMod from 'fs'; | ||
|
|
@@ -81,6 +81,68 @@ describe('runPacScript — argument passing', () => { | |
| }); | ||
| }); | ||
|
|
||
| // ─── shExpMatch — PAC shell-expression semantics ────────────────────────────── | ||
|
|
||
| describe('shExpMatch', () => { | ||
| it('treats * as any sequence and ? as exactly one character', () => { | ||
| expect(shExpMatch('dev.percy.io', '*.percy.io')).toBe(true); | ||
| expect(shExpMatch('percy.io', '*.percy.io')).toBe(false); | ||
| expect(shExpMatch('percy.io', 'percy.i?')).toBe(true); | ||
| expect(shExpMatch('percy.ioo', 'percy.i?')).toBe(false); | ||
| expect(shExpMatch('percy.io', 'percy.io')).toBe(true); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Medium] No No test in the suite calls That gap lands on the one input class whose result actually changed in this PR: Suggestion: add the spec example, plus one end-to-end case through it('matches wildcards across "/" when matching a full URL (spec: */ari/*)', () => {
expect(shExpMatch('http://home.netscape.com/people/ari/index.html', '*/ari/*')).toBe(true);
expect(shExpMatch('http://home.netscape.com/people/montulli/index.html', '*/ari/*')).toBe(false);
});Reviewer: stack-code-reviewer |
||
| }); | ||
|
|
||
| it('matches the empty string against * and the empty pattern', () => { | ||
| expect(shExpMatch('', '*')).toBe(true); | ||
| expect(shExpMatch('', '')).toBe(true); | ||
| expect(shExpMatch('percy.io', '')).toBe(false); | ||
| expect(shExpMatch('percy.io', '***')).toBe(true); | ||
| }); | ||
|
|
||
| it('is case-sensitive, per PAC semantics', () => { | ||
| expect(shExpMatch('Percy.IO', 'percy.io')).toBe(false); | ||
| }); | ||
|
|
||
| // The PAC spec defines only * and ?. Brace expansion, character classes and | ||
| // extglobs are NOT shExpMatch syntax, so they must match literally rather | ||
| // than being expanded — expanding attacker-supplied patterns is the | ||
| // brace-expansion OOM vector (GHSA-mh99-v99m-4gvg). | ||
| it('treats brace, bracket and extglob syntax as literal characters', () => { | ||
| expect(shExpMatch('{a,b}', '{a,b}')).toBe(true); | ||
| expect(shExpMatch('a', '{a,b}')).toBe(false); | ||
| expect(shExpMatch('b', '{a,b}')).toBe(false); | ||
| expect(shExpMatch('[abc]', '[abc]')).toBe(true); | ||
| expect(shExpMatch('a', '[abc]')).toBe(false); | ||
| expect(shExpMatch('percy.io', '!(percy.io)')).toBe(false); | ||
| expect(shExpMatch('a+(b)', 'a+(b)')).toBe(true); | ||
| }); | ||
|
|
||
| it('treats regex metacharacters as literals', () => { | ||
| expect(shExpMatch('a.c', 'a.c')).toBe(true); | ||
| expect(shExpMatch('abc', 'a.c')).toBe(false); | ||
| expect(shExpMatch('a$^(b)', 'a$^(b)')).toBe(true); | ||
| }); | ||
|
|
||
| it('returns promptly for brace-bomb and backtracking-heavy patterns', () => { | ||
| // Nested braces well under the 256-char sandbox cap: expanding these would | ||
| // exhaust memory, and `vm`'s timeout cannot interrupt native allocation. | ||
| const target = 'a'.repeat(200); | ||
| const braceBomb = '{a,b}'.repeat(40); | ||
| const starBomb = '*a'.repeat(100); | ||
| const start = process.hrtime.bigint(); | ||
|
|
||
| // Literal braces, so no expansion and no match. | ||
| expect(shExpMatch(target, braceBomb)).toBe(false); | ||
| // 100 stars still resolve correctly, both matching and — the worst case for | ||
| // backtracking — failing only at the very last pattern character. | ||
| expect(shExpMatch(target, starBomb)).toBe(true); | ||
| expect(shExpMatch(target, starBomb + 'b')).toBe(false); | ||
|
|
||
| const elapsedMs = Number(process.hrtime.bigint() - start) / 1e6; | ||
| expect(elapsedMs).toBeLessThan(1000); | ||
| }); | ||
| }); | ||
|
|
||
| // ─── runPacScript — shExpMatch wildcard matching ────────────────────────────── | ||
|
|
||
| describe('runPacScript — shExpMatch', () => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Low] Behaviour change vs
minimatchworth a CHANGELOG noteThis is not a like-for-like replacement. Verified against the installed minimatch:
minimatch('http://home.netscape.com/people/ari/index.html', '*/ari/*', { dot: true, nocase: false })→false(minimatch will not let*cross/); the newshExpMatch→true, which is what the PAC spec specifies.minimatch('', '*')→false; the new implementation →true.Both are corrections — the old code silently mis-evaluated any
shExpMatch(url, ...)call using a path pattern — but they are functional changes riding in under a dependency-hygiene commit, and they can flip a PAC script betweenDIRECTandPROXY.Suggestion: no code change; mention in the CHANGELOG and PR description that removing
minimatchalso fixes full-URL and empty-string matching.Reviewer: stack-code-reviewer