fix(zip): make includeSources use allowlist behavior#2111
fix(zip): make includeSources use allowlist behavior#2111kaigritun wants to merge 1 commit intowxt-dev:mainfrom
Conversation
When includeSources patterns are provided, only files matching those patterns should be included in the sources ZIP. Previously, includeSources patterns were added to the default **/* glob, which could leak sensitive files that weren't explicitly excluded. This change makes includeSources behave as an allowlist: - When includeSources is provided: only matching files are included - When includeSources is not provided: all files are included (current behavior) This prevents accidental inclusion of secrets, credentials, or other sensitive files that might not be covered by excludeSources patterns. BREAKING CHANGE: If you were using includeSources to add specific files to the default set (e.g., hidden files), you now need to include all files you want in the ZIP. The old behavior can be replicated by explicitly listing all desired patterns. Fixes wxt-dev#2059
✅ Deploy Preview for creative-fairy-df92c4 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
I've been trying to cleanup random config defaults outside the resolve-config.ts file. So there's a couple more changes this PR needs to make:
-
Can you move the
**/*default into theresolveZipConfigfunction here:wxt/packages/wxt/src/core/resolve-config.ts
Line 303 in 3417bd3
includeSources: mergedConfig.zip.includeSources ?? ['**/*'],
-
Similarly, if we move the
excludeSoucesarray into the glob'signoreoption, we can remove the hard-codednode_modulesglob from herewxt/packages/wxt/src/core/zip.ts
Line 120 in 3417bd3
because it will already be included. While the zipDir function is called multiple times, the other place it's called doesn't need to ignore the
node_modulesfolder since it's zipping the build output.
Finally, this is a breaking change, so the PR needs to be based off the major branch instead of main, and the PR should target major as well.
| ).filter((relativePath) => { | ||
| return ( | ||
| minimatchMultiple(relativePath, options?.include) || | ||
| !minimatchMultiple(relativePath, options?.exclude) | ||
| ); | ||
| // Exclude files that match any exclude pattern | ||
| return !minimatchMultiple(relativePath, options?.exclude); | ||
| }); |
There was a problem hiding this comment.
We can simplify this and remove the whole filter, moving the options?.exclude globs up to here:
wxt/packages/wxt/src/core/zip.ts
Lines 119 to 120 in 3417bd3
|
Superseded by #2114 which targets the |
Summary
When
includeSourcespatterns are provided, only files matching those patterns should be included in the sources ZIP. Previously,includeSourcespatterns were added to the default**/*glob, which could leak sensitive files that weren't explicitly excluded.Problem
As described in #2059, the current behavior is unintuitive and can lead to data leaks:
Expected: Only
entrypoints/**files are includedActual: ALL files are included, plus the entrypoints patterns override excludeSources
This means sensitive files like
secrets/api-key.txtorcache/credentials.jsoncould accidentally be included in the sources ZIP submitted to Firefox.Solution
This change makes
includeSourcesbehave as an allowlist:includeSourcesis provided: only matching files are includedincludeSourcesis not provided: all files are included (current behavior)excludeSourcesstill applies on top of include patternsChanges
packages/wxt/src/core/zip.ts: Whenincludepatterns are provided, use only those patterns for globbing instead of combining with**/*packages/wxt/src/types.ts: Updated documentation to clarify the allowlist behaviorpackages/wxt/e2e/tests/zip.test.ts: Added test to verify non-included files are excludedBreaking Change
If you were using
includeSourcesto add specific files to the default set (e.g., hidden files), you now need to include all files you want in the ZIP:Fixes #2059