Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add provenance publish notice #6247

Merged
merged 1 commit into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ graph LR;
libnpmpublish-->npmcli-eslint-config["@npmcli/eslint-config"];
libnpmpublish-->npmcli-mock-registry["@npmcli/mock-registry"];
libnpmpublish-->npmcli-template-oss["@npmcli/template-oss"];
libnpmpublish-->proc-log;
libnpmpublish-->semver;
libnpmpublish-->ssri;
libnpmsearch-->npm-registry-fetch;
Expand Down Expand Up @@ -408,6 +409,7 @@ graph LR;
libnpmpublish-->npmcli-eslint-config["@npmcli/eslint-config"];
libnpmpublish-->npmcli-mock-registry["@npmcli/mock-registry"];
libnpmpublish-->npmcli-template-oss["@npmcli/template-oss"];
libnpmpublish-->proc-log;
libnpmpublish-->semver;
libnpmpublish-->sigstore;
libnpmpublish-->ssri;
Expand Down
1 change: 1 addition & 0 deletions package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -15210,6 +15210,7 @@
"normalize-package-data": "^5.0.0",
"npm-package-arg": "^10.1.0",
"npm-registry-fetch": "^14.0.3",
"proc-log": "^3.0.0",
"semver": "^7.3.7",
"sigstore": "^1.0.0",
"ssri": "^10.0.1"
Expand Down
13 changes: 13 additions & 0 deletions workspaces/libnpmpublish/lib/publish.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
const { fixer } = require('normalize-package-data')
const npmFetch = require('npm-registry-fetch')
const npa = require('npm-package-arg')
const log = require('proc-log')
const semver = require('semver')
const { URL } = require('url')
const ssri = require('ssri')
const ciInfo = require('ci-info')

const { generateProvenance } = require('./provenance')

const TLOG_BASE_URL = 'https://rekor.sigstore.dev/api/v1/log/entries'

const publish = async (manifest, tarballData, opts) => {
if (manifest.private) {
throw Object.assign(
Expand Down Expand Up @@ -169,6 +172,16 @@ const buildMetadata = async (registry, manifest, tarballData, spec, opts) => {
}
const provenanceBundle = await generateProvenance([subject], opts)

/* eslint-disable-next-line max-len */
log.notice('publish', 'Signed provenance statement with source and build information from GitHub Actions')

const tlogEntry = provenanceBundle?.verificationMaterial?.tlogEntries[0]
/* istanbul ignore else */
if (tlogEntry) {
const logUrl = `${TLOG_BASE_URL}?logIndex=${tlogEntry.logIndex}`
log.notice('publish', `Provenance statement published to transparency log: ${logUrl}`)
}

const serializedBundle = JSON.stringify(provenanceBundle)
root._attachments[provenanceBundleName] = {
content_type: provenanceBundle.mediaType,
Expand Down
1 change: 1 addition & 0 deletions workspaces/libnpmpublish/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"normalize-package-data": "^5.0.0",
"npm-package-arg": "^10.1.0",
"npm-registry-fetch": "^14.0.3",
"proc-log": "^3.0.0",
"semver": "^7.3.7",
"sigstore": "^1.0.0",
"ssri": "^10.0.1"
Expand Down