@@ -22,9 +22,9 @@ class VerifySignatures {
2222 this . keys = new Map ( )
2323 this . invalid = [ ]
2424 this . missing = [ ]
25- this . auditedPackages = new Set ( )
25+ this . checkedPackages = new Set ( )
26+ this . auditedWithKeysCount = 0
2627 this . verifiedCount = 0
27- this . missingSigningKeysCount = 0
2828 this . output = [ ]
2929 this . exitCode = 0
3030 }
@@ -47,11 +47,9 @@ class VerifySignatures {
4747 }
4848 await pMap ( edges , mapper , { concurrency : 10 , stopOnError : true } )
4949
50- // Packages that were audited from a supported registry that returned signing keys
51- const auditedSupportedCount = this . auditedPackages . size - this . missingSigningKeysCount
5250 // Didn't find any dependencies that could be verified, e.g. only local
5351 // deps, missing version, not on a registry etc.
54- if ( ! auditedSupportedCount ) {
52+ if ( ! this . auditedWithKeysCount ) {
5553 throw new Error ( 'found no dependencies to audit that where installed from ' +
5654 'a supported registry' )
5755 }
@@ -75,8 +73,8 @@ class VerifySignatures {
7573 const end = process . hrtime . bigint ( )
7674 const elapsed = end - start
7775
78- const auditedPlural = auditedSupportedCount > 1 ? 's' : ''
79- const timing = `audited ${ auditedSupportedCount } package${ auditedPlural } in ` +
76+ const auditedPlural = this . auditedWithKeysCount > 1 ? 's' : ''
77+ const timing = `audited ${ this . auditedWithKeysCount } package${ auditedPlural } in ` +
8078 `${ Math . floor ( Number ( elapsed ) / 1e9 ) } s`
8179 const verifiedPrefix = hasNoInvalidOrMissing && this . verifiedCount ?
8280 'verified registry signatures, ' : ''
@@ -265,14 +263,20 @@ class VerifySignatures {
265263 return
266264 }
267265 const { name, version, location, registry, type } = info
268- if ( this . auditedPackages . has ( location ) ) {
266+ const keys = this . keys . get ( registry ) || [ ]
267+ if ( this . checkedPackages . has ( location ) ) {
269268 // we already did or are doing this one
270269 return
271270 }
272- this . auditedPackages . add ( location )
271+ this . checkedPackages . add ( location )
272+
273+ // We only "audit" or verify the signature, or the presence of it, on
274+ // packages whose registry returns signing keys
275+ if ( keys . length ) {
276+ this . auditedWithKeysCount += 1
277+ }
273278
274279 try {
275- const keys = this . keys . get ( registry ) || [ ]
276280 const { integrity, signatures, resolved } = await this . verifySignatures (
277281 name , version , registry
278282 )
@@ -290,8 +294,6 @@ class VerifySignatures {
290294 integrity,
291295 registry,
292296 } )
293- } else {
294- this . missingSigningKeysCount += 1
295297 }
296298 } catch ( e ) {
297299 if ( e . code === 'EINTEGRITYSIGNATURE' ) {
0 commit comments