Skip to content

harden npm install in publish.yml - #1442

Closed
blakedeckard wants to merge 2 commits into
docker:mainfrom
blakedeckard:npm-cooldown
Closed

blakedeckard wants to merge 2 commits into
docker:mainfrom
blakedeckard:npm-cooldown

Conversation

@blakedeckard

Copy link
Copy Markdown

was reviewing the CI for anything unpinned with Claude, and came across this npm shrinkwrap generation. it seems quite difficult to match the yarn-lock and what gets published, but that might be an eventual goal. i'm not as familiar with yarn as npm, so i decided to just propose some changes that might help with the npm side in the meantime.

.yarnrc.yml currently sets npmMinimalAgeGate: 2d, while the npm install that resolves what goes into the shrinkwrap does not have any cooldown. adding --min-release-age=2 [0] should allow the shrinkwrap to reflect this same cooldown. it will NOT guarantee that what is pushed matches the yarn lock

--allow-git=none [1] blocks git dependencies, direct or transitive. this closes a code-execution path where a git dependency’s .npmrc could override the git executable even with --ignore-scripts [3]. if I understand properly, git dependencies also aren’t covered by min-release-age.

--allow-remote=none [2] blocks dependencies resolved from tarball URLs rather than the registry. if I understand properly, these also aren’t covered by min-release-age, since they aren’t registry publishes.

in npm v12 allow-git and allow-remote default to none, so this should only surface issues that could come from an eventual migration to npm v12 [3]

the risk of this change is that @docker/actions-toolkit is published on line 76, so if this causes any breaks, this would leave a half-published release where @docker/actions-toolkit was pushed and @docker/github-builder-runtime is not.

[0] https://docs.npmjs.com/cli/v11/using-npm/config#min-release-age

[1] https://docs.npmjs.com/cli/v11/using-npm/config#allow-git

[2] https://docs.npmjs.com/cli/v11/using-npm/config#allow-remote

[3] https://github.blog/changelog/2026-06-09-upcoming-breaking-changes-for-npm-v12/

I used Claude to help research the npm/Yarn behavior, review this change, and edit the above prose; I’ve read through the linked sources myself. I was familiar with min-release-age and allow-git, but it also suggested allow-remote, which was new to me.

@crazy-max

Copy link
Copy Markdown
Member

Thanks for digging into this and putting the PR together. The extra protections make sense for the separate npm resolution. I'll take it from here and also move runtime preparation before either publish, so a resolution failure doesn't leave us with only the toolkit published.

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.

2 participants