Skip to content

build(deps): pin wrangler so the preview deploy uses the lockfile version - #993

Merged
Danathar merged 1 commit into
mainfrom
sec-check/pin-wrangler
Nov 10, 2026
Merged

Danathar merged 1 commit into
mainfrom
sec-check/pin-wrangler

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Summary: Every pull request to this website gets a temporary preview copy published to Cloudflare so reviewers can click through it. The step that publishes it borrows a command-line tool called wrangler, and until now it fetched whichever version of that tool happened to be newest at the moment the job ran, in the same job that holds the Cloudflare publishing credential. This change records one exact wrangler version in the project's dependency list, so the preview job installs the version we chose and reviewed, the same way the documentation site already does. Nothing about the preview itself changes.


What changes

  • package.json: adds wrangler 4.157.0 as an exact devDependency (same style as every other entry; 4.157.0 is past Renovate's 3-day minimumReleaseAge, so Renovate will keep it current from here).
  • package-lock.json: the resulting lockfile entries. 83 packages added, none removed; the only existing entry whose resolved version moved is the hoisted semver (7.7.4 → 7.8.6), pulled up by wrangler's range.

Why

.github/workflows/preview.yml runs cloudflare/wrangler-action without a wranglerVersion input. Per the action's README, when that input is omitted it uses an already-installed wrangler if one exists, otherwise it installs a default version from npm at run time. This repository did not ship wrangler, so each preview run resolved and executed an unpinned package while CLOUDFLARE_API_TOKEN was in scope. (The previous cloudflare/pages-action had the same shape, so this is not a regression from #991 — the replacement just made the fix straightforward.)

Because the job already runs npm ci before the deploy step, declaring wrangler in the lockfile is enough: the action finds node_modules/.bin/wrangler and skips its own install. No workflow edit is needed, so this lands from this lane. The same approach is what projectbluefin/documentation adopted for its Cloudflare deploy (documentation#1074).

This applies the accepted ruling on projectbluefin/utah#902 (pin build-time fetched tools to an exact, lockfile-verified version); an instance note is posted there rather than a separate issue here.

Verification

  • npm ci from the updated lockfile, then ./node_modules/.bin/wrangler --version → 4.157.0.
  • npm run test:run → 112 files, 1549 passed, 1 skipped (unchanged).

Filed by sec-check agent (ACMM L6 — full mode)

— hive: agent=sec-check backend=copilot model=claude-fable-5.1 copilot=1.0.88

…sion

The Cloudflare Pages preview job runs wrangler through cloudflare/wrangler-action
without a wranglerVersion input. When wrangler is absent from the project the
action installs whatever the registry currently serves, so the deploy step
resolves an unpinned package at run time. Declaring wrangler as an exact dev
dependency means npm ci installs it from package-lock.json first and the action
uses that existing installation, matching how projectbluefin/documentation
already pins it.

Assisted-by: Claude Fable 5.1 via GitHub Copilot CLI
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: sec-check <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author
b60871c

ℹ️ Sentinel notice — informational; author is trusted (hive agent), merge is not blocked

Hive flagged this PR (author @hivecommons-hive[bot], head b60871ca37d8) because it matches behaviors that can override security controls, escalate privileges or damage the codebase. This is a heuristic, not an accusation — a maintainer should confirm the change is intended before it merges.

  • sensitive_path — changes 2 sensitive path(s) (Touches a sensitive path (OWNERS, workflows, policies, hive config, security docs, …))
    • package-lock.json
    • package.json

Hive did not add the sentinel-alert label because this author is trusted. The finding remains recorded for audit and the dashboard Security tab; set sentinel.trusted_authors_block: true to require the blocking label for trusted authors too.

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Looks correct to me. Verified rather than inferred:

  • Mechanism holds. .github/workflows/preview.yml runs npm ci (Install dependencies) before cloudflare/wrangler-action@953926a… (v4.1.3), with no wranglerVersion input. At that pinned SHA, src/wranglerAction.ts:137-142 takes the !didUserProvideWranglerVersion && installedVersion branch and logs "using pre-installed wrangler version" — it does not call npm install wrangler@… (line 169-171) when the lockfile already provides one. So the deploy step will run 4.157.0 from node_modules/.bin.
  • Lockfile diff is what the body says. Parsed packages in base vs head: 0 entries removed, 83 added, exactly one existing entry changes version (node_modules/semver 7.7.4 → 7.8.6). The 328 "deleted" lines are the @eslint/* blocks shifting down to make room for the alphabetically-earlier @cloudflare/* / @cspotcode/* entries, not removals.
  • wrangler lands as "dev": true; package.json uses an exact version like every neighbouring devDependency.

No workflow change, so no new permissions. Checks are green (test, Audit GitHub Actions); preview is skipped as expected for a non-same-repo trigger condition.

Confidence: 5/5 (safe)

— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@Danathar Danathar 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.

Reviewed head b60871c: pins wrangler 4.157.0 as an exact devDependency so wrangler-action uses the lockfile copy; lockfile entries resolve from registry.npmjs.org (sampled, not read line by line); no workflow changes, production deploy does not use wrangler.

@Danathar
Danathar added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit 8fc1b6b Nov 10, 2026
4 checks passed
@Danathar
Danathar deleted the sec-check/pin-wrangler branch November 10, 2026 11:23
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.

1 participant