feat(npm-cli): add npmAuditRegistry config option #3583
Merged
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.
What's the problem this PR addresses?
yarn npm audit
fails when using artifactory as a registry and when no recommendations are available.Closes #3520.
Closes #3569.
How did you fix it?
Introduced a new
npmAuditRegistry
config option. On further testing against an artifactory server, I found that npm was also erroring out.npm v6 throws...
npm v7 throws...
We still want to default to using the custom registry as using a public registry may unintentionally leak private information. It also seems that private registries can modify the generated reports before responding to the request (https://jfrog.com/blog/protect-your-code-with-npm-audit-jfrog-xray/).
If the private registry does not support audit, we know that the default registries do. This provides an escape hatch for users to configure a custom audit registry.
Also added a null check to advisory recommendations to protect against the case where a patch does not yet exist.
Also updated the auth type to
BEST_EFFORT
as suggested by @ejsmith03. It looks like the public registries work regardless, and this also bypasses theInvalid authentication (as an anonymous user)
error returned by the private registry.Checklist