Skip to content

Commit e8126ac

Browse files
committed
fix: also strip npmPublishRegistry from .yarnrc.yml
npmPublishRegistry takes precedence over npmRegistryServer for yarn npm publish, bypassing the YARN_NPM_REGISTRY_SERVER env var.
1 parent 4782244 commit e8126ac

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

.github/workflows/publish-preview.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,14 @@ jobs:
213213
echo "::error::No package.json files found to validate"
214214
exit 1
215215
fi
216-
# Strip registry overrides from .yarnrc.yml to prevent scoped
217-
# registry redirects (npmScopes.<scope>.npmRegistryServer) which
218-
# take precedence over the YARN_NPM_REGISTRY_SERVER env var.
216+
# Strip registry overrides from .yarnrc.yml to prevent registry
217+
# redirects that could exfiltrate the NPM token. npmPublishRegistry
218+
# takes precedence over npmRegistryServer for yarn npm publish, and
219+
# npmScopes can override per-scope. YARN_NPM_REGISTRY_SERVER env var
220+
# only overrides npmRegistryServer, not the others.
219221
if [[ -f .yarnrc.yml ]]; then
220222
echo "Stripping registry config from .yarnrc.yml"
221-
yq -i 'del(.npmRegistryServer) | del(.npmScopes)' .yarnrc.yml
223+
yq -i 'del(.npmRegistryServer) | del(.npmPublishRegistry) | del(.npmScopes)' .yarnrc.yml
222224
fi
223225
for f in "${manifests[@]}"; do
224226
# Strip lifecycle scripts that run during pack/publish

0 commit comments

Comments
 (0)