MCPcopy Create free account
hub / github.com/decaporg/decap-cms / provenanceCommit

Function provenanceCommit

scripts/verify-published-packages.mjs:205–228  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

203 * resolves on its own: the publish attestation is there but provenance isn't yet.
204 */
205async 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
230async function checkPackage(registry, pkg, context) {
231 const { name, version } = pkg;

Callers 1

checkPackageFunction · 0.85

Calls 4

findMethod · 0.80
mapMethod · 0.80
fetchJsonFunction · 0.70
toStringMethod · 0.45

Tested by

no test coverage detected