Skip to content

ci: attest provenance/SBOM and Grype-scan the built rock - #80

Merged
tonyandrewmeyer merged 5 commits into
canonical:masterfrom
tonyandrewmeyer:feat/attest-and-scan-rock
Jul 14, 2026
Merged

ci: attest provenance/SBOM and Grype-scan the built rock#80
tonyandrewmeyer merged 5 commits into
canonical:masterfrom
tonyandrewmeyer:feat/attest-and-scan-rock

Conversation

@tonyandrewmeyer

@tonyandrewmeyer tonyandrewmeyer commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

This PR resolves the SSDLC requirement for SBOM generation and vulnerability scanning of artefacts, by adding a new attest-and-scan job between test and upload-ghcr in the tag-triggered publish pipeline:

  • Syft (anchore/sbom-action) generates an SPDX SBOM from the OCI archive produced by oci-factory Build-Rock.
  • actions/attest emits a signed SLSA build-provenance attestation for the rock (auto-generated predicate, provenance mode).
  • actions/attest emits a signed SBOM attestation with the SPDX predicate against the same rock subject.
  • Grype (anchore/scan-action) scans the SBOM and fails the build on vulnerabilities of severity high or above.

upload-ghcr now depends on attest-and-scan, so a rock that fails scanning is not pushed to GHCR and no attestations are orphaned.

Syft and Grype are the tools recommended in the security team's "How to secure a repo" guide, as well as Trivy, but we've decided to not use Trivy in Charm Tech.

tonyandrewmeyer and others added 3 commits July 8, 2026 15:37
Adds a new `attest-and-scan` job between test and upload-ghcr in the
tag-triggered publish pipeline:

- Syft (anchore/sbom-action) generates an SPDX SBOM from the OCI
  archive produced by oci-factory Build-Rock.
- actions/attest emits a signed SLSA build-provenance attestation for
  the rock (auto-generated predicate — provenance mode).
- actions/attest emits a signed SBOM attestation with the SPDX
  predicate against the same rock subject.
- Grype (anchore/scan-action) scans the SBOM and fails the build on
  vulnerabilities of severity high or above.

Notes:

- Uses actions/attest@v4 directly rather than the attest-build-provenance
  wrapper — per the v4 release note, new implementations should use
  actions/attest. Provenance and SBOM attestations are two invocations
  of the same action distinguished by mode auto-detection (no predicate
  inputs → provenance; sbom-path → SBOM).
- upload-ghcr now depends on attest-and-scan, so a rock that fails
  scanning is not pushed to GHCR and no attestations are orphaned.
- The corresponding CRA allowlist entries (`anchore/sbom-action@*`,
  `anchore/scan-action@*`) ride on the api_demo_server per-repo hunk
  in canonical/canonical-repo-automation#952. `actions/attest` is
  covered by the github-owned flag.
- Grype's check name will be added to api_demo_server's required
  status checks in CRA once this workflow is green on master.
@tonyandrewmeyer
tonyandrewmeyer marked this pull request as ready for review July 14, 2026 02:38
@tonyandrewmeyer
tonyandrewmeyer requested a review from dwilding July 14, 2026 02:38

@dwilding dwilding left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks!

Would you mind merging from master and bumping the package & rock version to 2.1.1? After the PR merges I'll push a tag to check this all works as expected.

with:
sbom: ./sbom.spdx.json
fail-build: true
severity-cutoff: high

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this cutoff a recommendation of our SSDLC?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes (§Mandatory escalation and §Pre-release blocking).

- name: Scan rock (Grype)
uses: anchore/scan-action@e1165082ffb1fe366ebaf02d8526e7c4989ea9d2 # v7.4.0
with:
sbom: ./sbom.spdx.json

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It seems that Grype can scan OCIs directly (with image). Presumably we separately need the SBOM, so it makes sense to scan the SBOM here too. Is one approach stronger/weaker than the other?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Both work. Scanning the SBOM keeps a single source of truth: the SBOM is the one we attest and publish, so a green Grype run against it means "the artefact whose SBOM we signed has no high+ vulnerabilities". There's no risk of the direct-image scan and the attested SBOM disagreeing.

The theoretical advantage of scanning the image directly is that Grype re-catalogues from scratch, so it might spot something Syft missed (like an unmanaged binary). For this rock that gap doesn't really exist, so I'd stay with the SBOM scan. If we ever add content Syft can't catalogue, it's worth switching to image: or running both.

tonyandrewmeyer and others added 2 commits July 14, 2026 18:24
@tonyandrewmeyer
tonyandrewmeyer merged commit fcf62f6 into canonical:master Jul 14, 2026
7 checks passed
@tonyandrewmeyer
tonyandrewmeyer deleted the feat/attest-and-scan-rock branch July 14, 2026 07:58
@dwilding

Copy link
Copy Markdown
Collaborator

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.

2 participants