Guard CLI bundle upload against oversized and out-of-app paths#7542
Draft
isaacroldan wants to merge 1 commit into
Draft
Guard CLI bundle upload against oversized and out-of-app paths#7542isaacroldan wants to merge 1 commit into
isaacroldan wants to merge 1 commit into
Conversation
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.

WHY are these changes introduced?
Follow-up from the Slack discussion in #app-management around uploaded bundle size (thread). Today the CLI has no guard rails on the asset zip we upload to GCS: an asset path pointing outside the app folder (e.g.
source = "../../"or an absolute home directory) silently copies whatever it resolves to, and the resulting bundle is then uploaded regardless of size. Josh confirmed a 2GB end-to-end upload, with the byproduct that a failed deploy still leaves a giant zip in.shopify/.Server-side enforcement (#713307, capping
ProcessBundleat 100MB) is the security boundary. This PR adds the CLI-side fail-fast for the accidental-misuse cases so developers don't OOM their own machine or wait through a multi-GB upload before being told no.WHAT is this pull request doing?
Two guards in the bundle pipeline:
Asset paths must resolve inside the app directory.
include_assetsentries (configKey,static,pattern) now reject sources that resolve outside the app folder (whereshopify.app.tomllives). Sibling-extension paths still work (the boundary is the app, not the extension). Implemented via a smallassertPathWithinAppDirhelper plus a threadedappDirectoryparam through the three entry handlers andinclude-assets-step.ts.uploadToGCSaborts when the compressed bundle exceeds 100MB. Single chokepoint covers both deploy (services/deploy/upload.ts) and dev session (services/dev/processes/dev-session/dev-session.ts). The cap matches the new server-side check so the CLI and server agree on the limit. Error message points the developer at their asset config.Out of scope on purpose: file-count limits, streaming the upload, and any opt-in GCS-side header — those were debated in the thread but defer cleanly.
How to test your changes?
Unit tests cover both guards:
packages/app/src/cli/services/build/steps/include-assets/assert-path-within-app.test.tspackages/app/src/cli/services/build/steps/include-assets/*.test.ts(existing tests adjusted; behaviour preserved when paths stay inside the app dir)packages/app/src/cli/services/bundle.test.ts(newuploadToGCSdescribe block — happy path + 101MB rejection)Manual repro of the path bound: in any app, set an asset entry to
source = "../../"ortools = "/Users/me/some/dir"and runshopify app build/deploy— you should get a clearAsset path '...' resolves outside the app directoryerror instead of a silent home-directory copy.Manual repro of the size guard: temporarily lower
MAX_BUNDLE_SIZE_MBto1inbundle.ts, then rundeploy— the CLI should abort before the GCS PUT.Post-release steps
None.
Checklist
relativePathfrom cli-kit which normalises both POSIX and Windows separatorspatchbump for@shopify/app)