Skip to content

Commit 029294d

Browse files
authored
chore(deps): enforce 24h minimum release age (#13998)
1 parent 52e9082 commit 029294d

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ updates:
1010
day: "sunday"
1111
time: "06:00"
1212
versioning-strategy: increase
13+
# Match the 24h minimumReleaseAge enforced by pnpm in pnpm-workspace.yaml
14+
# so Dependabot doesn't open PRs that CI will then reject.
15+
cooldown:
16+
default-days: 1
1317
# the following is used to add the [C3] prefix to the PR title,
1418
# we override the commit message but setting a prefix like this
1519
# makes it so that also the PR title gets such prefix

packages/mock-npm-registry/src/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,24 @@ export async function startMockNpmRegistry(...targetPackages: string[]) {
7676
"npm_config_registry",
7777
`http://localhost:${registryPort}`
7878
);
79+
// `pnpm run` exports `npm_config_minimum_release_age` from the workspace
80+
// pnpm-workspace.yaml to subprocess env vars, but does NOT export the
81+
// matching `minimumReleaseAgeExclude` array. Tests using this mock registry
82+
// install freshly-published first-party packages, so the 24h cooldown would
83+
// reject them. Set the exclude list as a comma-separated env var so the
84+
// constraint still applies to other (third-party) deps pulled via uplinks.
85+
const revert_npm_config_minimum_release_age_exclude = overrideProcessEnv(
86+
"npm_config_minimum_release_age_exclude",
87+
[
88+
...pkgs.keys(),
89+
// workerd and @cloudflare/workers-types are pulled in transitively
90+
// (e.g. via miniflare) and may have been bumped same-day. Keep this
91+
// list in sync with `minimumReleaseAgeExclude` in pnpm-workspace.yaml.
92+
"workerd",
93+
"@cloudflare/workerd-*",
94+
"@cloudflare/workers-types",
95+
].join(",")
96+
);
7997

8098
if (debugLog.enabled) {
8199
debugLog("Updated");
@@ -105,6 +123,7 @@ export async function startMockNpmRegistry(...targetPackages: string[]) {
105123
revert_NPM_CONFIG_USERCONFIG();
106124
revert_npm_config_registry();
107125
revert_npm_config_userconfig();
126+
revert_npm_config_minimum_release_age_exclude();
108127
if (debugLog.enabled) {
109128
debugLog("After");
110129
debugLog(execSync("pnpm config list", { encoding: "utf8" }));

pnpm-workspace.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ gitChecks: false
3030
# URLs. Only direct dependencies may use exotic sources.
3131
blockExoticSubdeps: true
3232

33+
# Require packages to be at least 24 hours old before they can be installed.
34+
# This mitigates supply-chain attacks where a malicious version is published and
35+
# yanked quickly, by ensuring there is a window for detection before adoption.
36+
# Value is in minutes (1440 = 24 hours).
37+
minimumReleaseAge: 1440
38+
39+
# First-party Cloudflare packages are exempt from the cooldown so they can be
40+
# adopted same-day.
41+
minimumReleaseAgeExclude:
42+
- "workerd"
43+
# Platform-specific workerd binaries published in lock-step with workerd.
44+
- "@cloudflare/workerd-*"
45+
- "@cloudflare/workers-types"
46+
3347
# ──────────────────────────────────────────────────────────────────────────────
3448
# Build scripts
3549
# pnpm 10 blocks lifecycle scripts by default. Only the packages listed here

0 commit comments

Comments
 (0)