Skip to content

Commit 41417de

Browse files
authoredFeb 3, 2025··
fix: warn when TUF fetching of keys fails (#8080)
![example screenshot showing the new logging message being displayed](https://github.com/user-attachments/assets/51474264-0d19-4cb7-bb67-2641fcd27968)
1 parent 593c849 commit 41417de

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed
 

Diff for: ‎lib/utils/verify-signatures.js

+1
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ class VerifySignatures {
192192

193193
// If keys not found in Sigstore TUF repo, fallback to registry keys API
194194
if (!keys) {
195+
log.warn(`Fetching verification keys using TUF failed. Fetching directly from ${registry}.`)
195196
keys = await npmFetch.json('/-/npm/v1/keys', {
196197
...this.npm.flatOptions,
197198
registry,

Diff for: ‎test/lib/commands/audit.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ t.test('audit signatures', async t => {
940940
})
941941

942942
t.test('with key fallback to legacy API', async t => {
943-
const { npm, joinedOutput } = await loadMockNpm(t, {
943+
const { logs, npm, joinedOutput } = await loadMockNpm(t, {
944944
prefixDir: installWithValidSigs,
945945
})
946946
const registry = new MockRegistry({ tap: t, registry: npm.config.get('registry') })
@@ -952,6 +952,7 @@ t.test('audit signatures', async t => {
952952

953953
t.notOk(process.exitCode, 'should exit successfully')
954954
t.match(joinedOutput(), /audited 1 package/)
955+
t.match(logs.warn, ['Fetching verification keys using TUF failed. Fetching directly from https://registry.npmjs.org/.'])
955956
t.matchSnapshot(joinedOutput())
956957
})
957958

0 commit comments

Comments
 (0)
Please sign in to comment.