Skip to content

fix(deps): bump chokidar to 4.0.3 to resolve braces advisory (#11308) - #11336

Merged
joehan merged 2 commits into
mainfrom
joehanley/fix-issue-11308
Oct 22, 2026
Merged

joehan merged 2 commits into
mainfrom
joehanley/fix-issue-11308

Conversation

@joehan

@joehan joehan commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Description

Fixes #11308.

  • Upgrades chokidar from ^3.6.0 to ^4.0.3 in package.json and updates npm-shrinkwrap.json.
  • Resolves the High security advisory on braces (GHSA-vfj7-8cjw-p6xm), removing braces from the production dependency graph as chokidar@4 only depends on readdirp@^4.0.1.
  • Adds an override for @angular-devkit/core's optional peer dependency on chokidar ("@angular-devkit/core": { "chokidar": "$chokidar" }).
  • Adapts the Functions emulator file watcher (src/emulator/functionsEmulator.ts) to use minimatch for backend.ignore pattern matching, preserving glob ignore functionality under chokidar@4 (which dropped native glob matching in favor of matcher functions and regexes).
  • Retains CommonJS and Node >= 14.16.0 compatibility (supporting Node 20.18 standalone binaries).
  • Adds unit tests in src/emulator/functionsEmulatorUtils.spec.ts for the Functions emulator ignore filter.

Scenarios Tested

  • npm audit --omit=dev --json verified that braces is completely removed from the production dependency graph.
  • Node 20.18.3 compatibility verified by executing CJS require() against all built emulator modules (databaseEmulator.js, firestoreEmulator.js, functionsEmulator.js, storage/rules/manager.js).
  • npm run build passed (TypeScript and Vite compilation).
  • npm run lint:quiet passed (ESLint and Prettier across all files).
  • Unit test suites passed:
    • src/emulator/functionsEmulatorUtils.spec.ts (30 passing)
    • src/emulator/databaseEmulator.spec.ts (4 passing)
    • src/emulator/storage/rules/config.spec.ts and src/emulator/storage/rules/runtime.spec.ts (13 passing)
  • Lockfile cleanliness verified with npm run sanitize:lockfile and reproducible lockfile generation.

Sample Commands

N/A

- Bump chokidar to ^4.0.3 in package.json and update npm-shrinkwrap.json
- Add @angular-devkit/core chokidar override to resolve optional peer dependency
- Remove vulnerable braces dependency from production graph (GHSA-vfj7-8cjw-p6xm)
- Use minimatch for glob matching in Functions emulator ignore filter for chokidar 4 compatibility
- Add unit tests for functions emulator ignore filter

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a helper function createIgnoredFilter to centralize and standardize the logic for ignoring files in the functions emulator, improving maintainability and testability. The changes include updating the chokidar dependency to version 4.0.3, adding the necessary minimatch dependency, and refactoring the file watcher configuration. Unit tests have been added to verify the ignore logic. I have included a review comment suggesting the pre-compilation of minimatch patterns to enhance performance during file-watching operations.

Comment thread src/emulator/functionsEmulator.ts Outdated
Comment on lines +200 to +206
const patterns = ignore.map((pattern) =>
pattern.startsWith("**/") ? pattern : `**/${pattern}`,
);
ignored.push((filePath: string) => {
const normalized = filePath.replace(/\\/g, "/");
return patterns.some((p) => minimatch(normalized, p, { dot: true }));
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Pre-compiling the minimatch patterns into Minimatch instances outside of the file-matching callback avoids recompiling the glob patterns or performing repetitive cache lookups for every single file and directory during the file-watching process. This significantly improves the efficiency of the file watcher, especially in larger projects with many files.

    const minimatchInstances = ignore.map((pattern) => {
      const p = pattern.startsWith("**/") ? pattern : `**/${pattern}`;
      return new minimatch.Minimatch(p, { dot: true });
    });
    ignored.push((filePath: string) => {
      const normalized = filePath.replace(/\\/g, "/");
      return minimatchInstances.some((m) => m.match(normalized));
    });

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit dba5f87 by pre-compiling the ignore patterns into minimatch.Minimatch instances outside the matcher callback.

@joehan
joehan requested review from aalej and avolkovi October 22, 2026 20:16
@joehan
joehan enabled auto-merge (squash) October 22, 2026 20:51
@joehan
joehan merged commit b5421ab into main Oct 22, 2026
51 checks passed
@joehan
joehan deleted the joehanley/fix-issue-11308 branch October 22, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dependency security advisory: braces GHSA-vfj7-8cjw-p6xm via chokidar (no patched version listed)

2 participants