-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix: provenance-file takes precedence over OIDC auto-generated provenance #9882
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
Open
yunseo-kim
wants to merge
3
commits into
npm:latest
Choose a base branch
from
yunseo-kim:fix/provenance-file-precedence
base: latest
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
7b2ab6d
fix: provenance-file takes precedence over OIDC auto-generated proven…
yunseo-kim 66710dc
fix(libnpmpublish): throw when provenance and provenanceFile are both…
yunseo-kim df4e300
docs: document provenance-file precedence over automatic provenance
yunseo-kim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,11 +58,15 @@ A couple of options of note: | |
|
|
||
| * `opts.provenance` - when running in a supported CI environment, will trigger | ||
| the generation of a signed provenance statement to be published alongside | ||
| the package. Mutually exclusive with the `provenanceFile` option. | ||
| the package. Mutually exclusive with the `provenanceFile` option; providing | ||
| both will throw an `EPROVENANCECONFLICT` error. In the npm CLI's trusted | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. update this to |
||
| publishing flows, automatic provenance generation is skipped when | ||
| `provenanceFile` is supplied. | ||
|
|
||
| * `opts.provenanceFile` - specifies the path to an externally-generated | ||
| provenance statement to be published alongside the package. Mutually | ||
| exclusive with the `provenance` option. The specified file should be a | ||
| exclusive with the `provenance` option; providing both will throw an | ||
| `EPROVENANCECONFLICT` error. The specified file should be a | ||
| [Sigstore Bundle](https://github.com/sigstore/protobuf-specs/blob/main/protos/sigstore_bundle.proto) | ||
| containing a [DSSE](https://github.com/secure-systems-lab/dsse)-packaged | ||
| provenance statement. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -144,6 +144,12 @@ const buildMetadata = async (registry, manifest, tarballData, spec, opts) => { | |
|
|
||
| // Handle case where --provenance flag was set to true | ||
| let transparencyLogUrl | ||
| if (provenance === true && provenanceFile) { | ||
| throw Object.assign( | ||
| new Error('provenance and provenanceFile are mutually exclusive'), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets use the existing throw Object.assign(
new Error('provenance and provenanceFile cannot be used together'),
{ code: 'EUSAGE' }
) |
||
| { code: 'EPROVENANCECONFLICT' } | ||
| ) | ||
| } | ||
| if (provenance === true || provenanceFile) { | ||
| let provenanceBundle | ||
| const subject = { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add another test to prove that
publishConfigis flattened intoopts.provenanceFilebeofreoidc()decides whether to enable automatic provenance.The important distinction is:
versus:
The second case exercises
Publish.#getManifest()and its specialflatten(filteredPublishConfig, opts)path inlib/commands/publish.js. Automatic provenance would still be enabled if that flattening did not reachopts.provenanceFile.Rather than duplicating the existing 119-line test, I would parameterize it:
The omitted bundle and registry setup remains unchanged from the existing test. Only the source of
provenance-filebecomes parameterized.This verifies four things for
publishConfig:publishConfig["provenance-file"]is flattened intoopts.provenanceFile.sigstore.attest()is never called.