This commit is contained in:
2026-08-14 16:03:47 +01:00
parent fd53e3f4fb
commit dfdc3b2840
2463 changed files with 186456 additions and 111315 deletions
+3 -2
View File
@@ -10,7 +10,7 @@ const cacache = require('cacache')
const fsm = require('fs-minipass')
const getContents = require('@npmcli/installed-package-contents')
const npa = require('npm-package-arg')
const retry = require('promise-retry')
const { promiseRetry } = require('@gar/promise-retry')
const ssri = require('ssri')
const tar = require('tar')
const { Minipass } = require('minipass')
@@ -319,7 +319,7 @@ class FetcherBase {
this.spec
}. Extracting by manifest.`)
}
return this.resolve().then(() => retry(tryAgain =>
return this.resolve().then(() => promiseRetry(tryAgain =>
streamHandler(this.#istream(this[_.tarballFromResolved]()))
.catch(streamErr => {
// Most likely data integrity. A cache ENOENT error is unlikely
@@ -502,6 +502,7 @@ FetcherBase.get = (rawSpec, opts = {}) => {
case 'range':
case 'tag':
case 'alias':
canUse({ allow: opts.allowRegistry, isRoot: opts._isRoot, allowType: 'registry', spec })
return new RegistryFetcher(spec.subSpec || spec, opts)
case 'file':
+6 -2
View File
@@ -229,7 +229,7 @@ class RegistryFetcher extends Fetcher {
if (this.opts.verifyAttestations) {
// Always fetch attestations from the current registry host
const attestationsPath = new URL(dist.attestations.url).pathname
const attestationsUrl = removeTrailingSlashes(this.registry) + attestationsPath
const attestationsUrl = new URL(attestationsPath, this.registry).href
const res = await fetch(attestationsUrl, {
...this.opts,
// disable integrity check for attestations json payload, we check the
@@ -256,7 +256,10 @@ class RegistryFetcher extends Fetcher {
const attestationKeyIds = bundles.map((b) => b.keyid).filter((k) => !!k)
const attestationRegistryKeys = (this.registryKeys || [])
.filter(key => attestationKeyIds.includes(key.keyid))
if (!attestationRegistryKeys.length) {
// Only require registry keys when there are keyed attestations.
// Keyless (Sigstore/Fulcio) attestations embed their signing
// certificate in the bundle and don't need registry keys.
if (attestationKeyIds.length > 0 && !attestationRegistryKeys.length) {
throw Object.assign(new Error(
`${mani._id} has attestations but no corresponding public key(s) can be found`
), { code: 'EMISSINGSIGNATUREKEY' })
@@ -339,6 +342,7 @@ class RegistryFetcher extends Fetcher {
}
}
mani._attestations = dist.attestations
mani._attestationBundles = attestations
} else {
mani._attestations = dist.attestations
}
+4 -1
View File
@@ -8,7 +8,10 @@ const addGitSha = (spec, sha) => {
return `${base}#${sha}`
} else {
// don't use new URL for this, because it doesn't handle scp urls
return spec.rawSpec.replace(/#.*$/, '') + `#${sha}`
// strip the committish with indexOf/slice to avoid a regexp redos
const hashIndex = spec.rawSpec.indexOf('#')
const base = hashIndex === -1 ? spec.rawSpec : spec.rawSpec.slice(0, hashIndex)
return `${base}#${sha}`
}
}