feat(core): set default HTTP user agent#7149
Open
kgrg wants to merge 1 commit into
Open
Conversation
30d0544 to
50cdefc
Compare
50cdefc to
837d09f
Compare
3 tasks
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.
Bug description
Yarn HTTP requests currently fall back to got's default
User-Agent, which identifies the HTTP client rather than Yarn itself. This makes it difficult for sysadmins to distinguish Yarn traffic or enforce package-manager/version allow-lists.Closes #7146
Root cause
httpUtils.requestforwarded caller-provided headers directly to got. When callers didn't provide aUser-Agent, got supplied its own default header.Fix
User-Agentheader for Yarn HTTP requests in the formyarn/<version> node/<node-version>User-Agentheaders when callers/plugins explicitly provide onehttpUtilsunit testsVerification
yarn test:unit packages/yarnpkg-core/tests/httpUtils.test.ts --runInBandyarn typecheck:allgit diff --checkNote
I also tried
yarn test:lint, but it failed before linting the changed files with an ESLint config-loader error:TypeError: Cannot convert undefined or null to object.Risk
Low. The change only adds a default header when no
User-Agentis already configured; explicit caller-provided values are left unchanged.