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

Add SLSA provenance generator to release; closes #222 #223

Merged
merged 14 commits into from
Sep 29, 2022
Merged

Add SLSA provenance generator to release; closes #222 #223

merged 14 commits into from
Sep 29, 2022

Conversation

diogoteles08
Copy link
Contributor

@diogoteles08 diogoteles08 commented Sep 26, 2022

Summary

This pull request adds a provenance generator to the Github Action build workflow. It enhances the security of the end-user by allowing them to verify the integrity of the artifact they are consuming. Closes #222.

Also, this PRs divides the build workflow into different jobs, each of them with their specific permissions.

IMPORTANT: The new build flow was not able to be fully tested because I did not have the credentials to publish on PYPI and also could not upload the release on Github because I did not added tags. But until this point of the build, everything worked out fine.

Release Note

Documentation

I also changed the README to instruct the users on how to use the provenance to verify their artifacts.

…issions

Signed-off-by: Diogo Teles Sant'Anna <diogoteles08@gmail.com>
Signed-off-by: Diogo Teles Sant'Anna <diogoteles08@gmail.com>
Signed-off-by: Diogo Teles Sant'Anna <diogoteles08@gmail.com>
Signed-off-by: Diogo Teles Sant'Anna <diogoteles08@gmail.com>
…ild provenance

Signed-off-by: Diogo Teles Sant'Anna <diogoteles08@gmail.com>
Signed-off-by: Diogo Teles Sant'Anna <diogoteles08@gmail.com>
@di
Copy link
Member

di commented Sep 26, 2022

/gcbrun

@di di requested a review from woodruffw September 26, 2022 17:53
woodruffw
woodruffw previously approved these changes Sep 26, 2022
Copy link
Member

@woodruffw woodruffw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I can try doing a pre-release to shake things out once this is merged!

@diogoteles08
Copy link
Contributor Author

Great! Should I squash commits for you?

@di
Copy link
Member

di commented Sep 26, 2022

Not necessary, thanks!

contents: write # To add assets to a release.
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.2.0
with:
attestation-name: sigstore-python-provenance.intoto.jsonl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems arbitrary. Is it possible to make this based on the name of the artifact that the provenance is generated for? Also, how does this handle multiple artifacts? Are they all bundled in the same file?

E.g., could we make the provenance for sigstore-0.6.5.tar.gz be sigstore-0.6.5.tar.gz.intoto.jsonl, and so on?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on my local testings, you can use that unique provenance file to verify both artifacts. That's why I used an "arbitrary" name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could indeed separate the provenances, but AFAIK for that I would need to create and output two different hashes and then call the slsa-github-generator twice, which seems a bit redundant

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm personally okay with them being bundled together, although I also have a slight preference for the attestation filename having the version number in it somewhere (that way, someone who wants to pull down every attestation we've ever generated doesn't need to do the renaming on their own).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this is better as a feature request upstream for the generator. I think in the Python world, it makes more sense to have provenance be per-artifact instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand. I'll talk to someone that I know who works on SLSA project and ask if they have this feature in mind and possibly raise the issue.
In the meanwhile, I'll try to change the code to automatically fetch the release version and create the provenance with the name provenance-sigstore-{version number}.intoto.jsonl. Does it sound good?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just commited the proposed changes, please take a look

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, @laurentsimon from the upstream SLSA generator project.

The SLSA specs currently encourage the use of a single multiple.intoto.jsonl provenance covering all artifacts (see in-toto/attestation#107). Having a version is definitely good feedback for them, so I replied to the thread.

I think in the Python world, it makes more sense to have provenance be per-artifact instead.

Can you explain why it makes more sense?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not the case here, but when Python builds include native code, builds have to be run across multiple platforms and architectures. In a hypothetical future, we might have a project that needs to generate provenance from multiple discrete SLSA-compatible builders, for multiple artifacts. So, the first problem is: what we name that provenance, so at verification time, users know what to use with a given artifact?

Then, if we then want to distribute provenance along with the artifact, we have the same problem: on a repository like PyPI, we have distribution files, and then additional artifacts that directly relate to those files. So for example, if I was signing something with PGP, I would upload sigstore-0.6.5.tar.gz and sigstore-0.6.5.tar.gz.asc. I think we want to follow a similar pattern here.

Copy link
Contributor

@laurentsimon laurentsimon Sep 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. @diogoteles08 when you get to a project like the one @di describes, let me know. I think the builds use strategy matrix, so we could handle them similar to slsa-framework/slsa-github-generator#707

README.md Outdated Show resolved Hide resolved
On the instructions on how to verify the provenance, we were reffering
to the instructions on how to do so, but linking to the wrong URL.

Signed-off-by: Diogo Teles Sant'Anna <diogoteles08@gmail.com>
Signed-off-by: Diogo Teles Sant'Anna <diogoteles08@gmail.com>
@woodruffw
Copy link
Member

/gcbrun

.github/workflows/release.yml Outdated Show resolved Hide resolved
On release-pypi job on release workflow, the token-id permission was set
to "write", but it's not necessary and was removed.

Signed-off-by: Diogo Teles Sant'Anna <diogoteles08@gmail.com>
@di
Copy link
Member

di commented Sep 27, 2022

/gcbrun

Copy link
Member

@woodruffw woodruffw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small formatting/typo nits; I'll merge these using the GH web flow.

README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
Signed-off-by: William Woodruff <william@yossarian.net>
Signed-off-by: William Woodruff <william@yossarian.net>
@woodruffw
Copy link
Member

/gcbrun

actions: read # To read the workflow path.
id-token: write # To sign the provenance.
contents: write # To add assets to a release.
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.2.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nonblocking: for consistency with the other actions in this workflow, we should probably use a hash rev instead of a symbolic (tag) rev.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, let's update this.

Copy link
Contributor

@laurentsimon laurentsimon Sep 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hash is not supported for the builder, due to a lack of GH support to map a hash to a branch. This is an intentional design decision we have made. We aim to change that once the relevant GitHub support is there. See the reasoning at slsa-framework/slsa-verifier#12

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that it would maintain the consistency and also follow the best practice rules, but currently SLSA generator does not support hash pinning, although there already is an issue about that. More details here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However I think it would be a good idea to add a comment on code explaining this decision, because it's indeed contradictory and more people can question that. Will work on it

Copy link
Contributor

@laurentsimon laurentsimon Sep 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, with a link to the documentation. We can add a link to the tracking issue in the documentation of our repo.

woodruffw
woodruffw previously approved these changes Sep 27, 2022
di
di previously approved these changes Sep 28, 2022
Because of a demand of SLSA Generator, their action cannot be used through pinned hashing. As using tags goes agains the best practices, I'm letting explicit the reason why we are using them.

Signed-off-by: Diogo Teles Sant'Anna <diogoteles08@gmail.com>
@diogoteles08 diogoteles08 dismissed stale reviews from di and woodruffw via 5747562 September 28, 2022 16:24
@di
Copy link
Member

di commented Sep 29, 2022

/gcbrun

@di di enabled auto-merge (squash) September 29, 2022 14:40
@di di merged commit e5acd69 into sigstore:main Sep 29, 2022
di added a commit to di/sigstore-python that referenced this pull request Oct 5, 2022
di added a commit that referenced this pull request Oct 5, 2022
di added a commit to di/sigstore-python that referenced this pull request Oct 20, 2022
woodruffw pushed a commit that referenced this pull request Oct 20, 2022
* Revert "Revert "Add SLSA provenance generator to release; closes #222 (#223)" (#232)"

This reverts commit 2e438cd.

* Bump generator workflow version for new release
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integration with SLSA security framework
5 participants