* The commit the registry's SLSA provenance says this version was built from, * or an issue string when there is none to read. `pending` marks the issue npm * resolves on its own: the publish attestation is there but provenance isn't yet.
(manifest, label)
| 203 | * resolves on its own: the publish attestation is there but provenance isn't yet. |
| 204 | */ |
| 205 | async function provenanceCommit(manifest, label) { |
| 206 | const url = manifest.dist && manifest.dist.attestations && manifest.dist.attestations.url; |
| 207 | if (!url) { |
| 208 | return { issue: 'no provenance attestation (published without --provenance or by hand)' }; |
| 209 | } |
| 210 | |
| 211 | const body = await fetchJson(url, `${label} attestations`); |
| 212 | const provenance = ((body && body.attestations) || []).find( |
| 213 | attestation => attestation.predicateType === SLSA_PROVENANCE, |
| 214 | ); |
| 215 | if (!provenance) { |
| 216 | return { issue: `attestations have no ${SLSA_PROVENANCE} entry`, pending: true }; |
| 217 | } |
| 218 | |
| 219 | const statement = JSON.parse( |
| 220 | Buffer.from(provenance.bundle.dsseEnvelope.payload, 'base64').toString('utf8'), |
| 221 | ); |
| 222 | const dependencies = |
| 223 | (statement.predicate.buildDefinition && |
| 224 | statement.predicate.buildDefinition.resolvedDependencies) || |
| 225 | []; |
| 226 | const commit = dependencies.map(dep => dep.digest && dep.digest.gitCommit).find(Boolean); |
| 227 | return commit ? { commit } : { issue: 'provenance names no gitCommit' }; |
| 228 | } |
| 229 | |
| 230 | async function checkPackage(registry, pkg, context) { |
| 231 | const { name, version } = pkg; |
no test coverage detected