Git Product home page Git Product logo

attest-demo's Introduction

attest-demo

This repository demonstrates the use of the actions/attest-build-provenance and actions/attest-sbom actions to generate attestations for software artifacts built with GitHub Actions.

We use a trivial Python project to show what a typical workflow might look like (see .github/workflows/build.yml).

Artifact Attestation

First, we need to ensure that we have the proper permissions set for our workflow:

permissions:
  contents: read
  id-token: write
  attestations: write

Developers are probably already familiar with contents: read as this is necessary for the workflow to clone the repository.

The id-token: write permision is necessary for the creation of the attestation. The attest-* actions will request an OIDC token from the GitHub Actions runtime -- the identity information present in the OIDC token is embedded in the generated attestation and provides the verifiable papertrail that allows us to assert that the built artifact originated from this workflow.

The attestations: write permission is necessary to write the attestation to the GitHub API and associate it with the current repository.

With the proper permissions set, we can build our Python project:

- name: Install dependencies
  run: python -m pip install -r requirements.txt
- name: Build package
  run: python -m build .

The result of the build step will be a Python wheel package in the dist/ directory.

With our artifact built, we use the actions/attest-build-provenance action to generate a build provenance attestation which refers to the Python package.

- name: Attest build provenance
  uses: actions/attest-build-provenance@v1
  with:
    subject-path: "dist/*.whl"

See an example of a build provenance attestation here.

Developers may also wish to generate an Sofware Bill of Materials (SBOM) for their project and then attest that SBOM in order to link it to this workflow run. There are a number of tools which can be used to generate SBOMs for a project -- in our example we use the anchore/sbom-action:

- name: Generate SBOM
  uses: anchore/[email protected]
  with:
    format: "spdx-json"
    output-file: "sbom.spdx.json"

This will scan the project directory and produce an inventory of all the referenced dependencies. In this case, we're asking for an SBOM in the SPDX format.

Once the SBOM has been generated, we can use the attest-sbom action to wrap the SBOM in a verifiable attestation:

- name: Attest SBOM
  uses: actions/attest-sbom@v1
  with:
    subject-path: "dist/*.whl"
    sbom-path: "sbom.spdx.json"

Note that The subject used for the SBOM attestation is the same that was used for the build provenance attestation. In both cases, we're binding the attestation to the build artifact generated in this workflow.

See an example of an SBOM attestation here.

Attestation Verification

The "verify" job in the workflow shows an example of using the gh CLI to verify the attestations which were generated for the build artifact:

- name: Verify build artifact
  env:
    GH_TOKEN: ${{ github.token }}
    run: ./bin/gh attestation verify *.whl --owner github

The output will look something like the following, showing both the build provenance and SBOM attestations:

github/attest-demo	https://spdx.dev/Document/v2.3	.github/workflows/build.yml@refs/heads/main
github/attest-demo	https://slsa.dev/provenance/v1	.github/workflows/build.yml@refs/heads/main

attest-demo's People

Contributors

bdehamer avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.