Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a condition to fix third-party registries returning E400 #5480

Merged
merged 2 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/commands/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class VerifySignatures {
...key,
pemkey: `-----BEGIN PUBLIC KEY-----\n${key.key}\n-----END PUBLIC KEY-----`,
}))).catch(err => {
if (err.code === 'E404') {
if (err.code === 'E404' || err.code === 'E400') {
return null
} else {
throw err
Expand Down
8 changes: 8 additions & 0 deletions test/lib/commands/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,14 @@ t.test('audit signatures', async t => {
npm.exec('audit', ['signatures']),
/found no dependencies to audit that where installed from a supported registry/
)

// Some registries return 400 instead, even though 404 would be more appropriate
registry.nock.get('/-/npm/v1/keys').reply(400)

await t.rejects(
juanheyns marked this conversation as resolved.
Show resolved Hide resolved
npm.exec('audit', ['signatures']),
/found no dependencies to audit that where installed from a supported registry/
)
})

t.test('third-party registry with keys and signatures', async t => {
Expand Down