fix(sign): Excluded the artifacts directory from the signed package - #3834
Open
MaxFreedomPollard wants to merge 1 commit into
Open
MaxFreedomPollard wants to merge 1 commit into
MaxFreedomPollard wants to merge 1 commit into
Conversation
The sign command builds its package into a temporary directory, and build creates its default file filter from that temporary path. FileFilter only adds ignore rules for the artifacts directory when it sits inside the source directory, so a temporary path meant the rule was never added and everything under web-ext-artifacts that is not a .zip or .xpi ended up in the archive sent to AMO. Sign now builds the file filter itself from the real artifacts directory and passes it to build. The same ignoreFiles are still passed in, so --ignore-files is unaffected, and the existing isSubPath guard keeps behaviour unchanged when --artifacts-dir points outside the source directory.
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.
Fixes #1640.
web-ext buildleaves the artifacts directory out of the package it creates, butweb-ext signputs it in. Anything underweb-ext-artifacts/that is not a.zipor.xpiends up inside the archive that is uploaded to AMO:.crxand.nexfiles from Chrome or Opera builds, unpacked copies of the extension, screenshots. Previously built.zipand.xpipackages are already dropped by the base ignore patterns, so those are not the problem, but everything else is shipped and signed.The cause is the temporary build directory.
sign()builds into a temp dir (artifactsDir: tmpDir.path(), src/cmd/sign.js:59 on master), andbuild()creates its default file filter from whatever artifacts directory it was given (src/cmd/build.js:210-214).FileFilteronly adds ignore rules for the artifacts directory when that directory is inside the source directory (src/util/file-filter.js:53). A temp dir is never a subpath of the source dir, so the rule is never added and the realweb-ext-artifacts/is packaged.The fix is to build the filter where the real artifacts directory is known. Sign now calls
createFileFilter({ sourceDir, ignoreFiles, artifactsDir })itself and passes the result tobuild()as itsfileFilteroption, which is a default parameter, so no signature change is needed. That is the same call-site patternlint.jsand the extension runners already use. ThoseignoreFilesgo into the filter sign constructs, so--ignore-filesbehaves exactly as before, and theisSubPathguard added in #790 is untouched, so behaviour is also unchanged when--artifacts-dirpoints outside the source directory. Only the extension package is affected. The source bundle for--upload-source-codeis a user supplied path.Two tests were added to
tests/unit/test-cmd/test.sign.js. The first runs the real sign command over a source directory that has aweb-ext-artifacts/previous-build.crxin it, with only the submission call stubbed, and asserts the zip containsmanifest.jsonand not the artifacts file. The zip is read inside that stub because sign removes its temporary directory as soon as it returns. The second injects a spycreateFileFilterand asserts it is called with the real artifacts directory and that the resulting filter reachesbuild().The one existing test that runs the real build signs a source directory with no artifacts directory inside it, so nothing leaked; every other sign test stubs build. Both new tests fail before the change, with
AssertionError: expected [ 'web-ext-artifacts/', …(3) ] to not include 'web-ext-artifacts/previous-build.crx'. With the change,tests/unit/test-cmd/test.sign.jsgives 16 passing,test.build.js28 passing andtests/unit/test-util/test.file-filter.js18 passing.