Skip to content

Add a custom BuildKit SBOM generator for extension images - #92

Open
ardentperf wants to merge 24 commits into
cnpg-extensions:mainfrom
ardentperf:x-ai/ardentperf/cnpg-sbom-generator
Open

ardentperf wants to merge 24 commits into
cnpg-extensions:mainfrom
ardentperf:x-ai/ardentperf/cnpg-sbom-generator

Conversation

@ardentperf

Copy link
Copy Markdown
Member

Summary

This PR adds a BuildKit SBOM generator for CNPG extension images. It produces
platform-specific SPDX SBOMs for the shipped extension payload while retaining
package ownership, license findings, and optional downstream metadata hooks.

Changes

  • Add the cnpg-sbom-generator container and its Python generator, SPDX
    composer, optional augmentation hook, and regression tests.
  • Publish the generator as
    ghcr.io/cnpg-extensions/cnpg-sbom-generator.
  • Integrate the generator with the extension Bake workflow and expose the
    builder stage required for package and license evidence.
  • Use BuildKit's native type=sbom attestation when sbom_generator is not
    configured; use the custom generator when an image reference is supplied.
  • Split large license files at License: sections before ScanCode runs, then
    normalize the results back to their original paths.
  • Document the generator protocol, downstream hook, attestation layout, and
    verification workflow.
  • Add a Trivy SBOM example for the pgagent bookworm image.

Validation

  • python3 -m unittest discover -s sbom-generator/tests -p 'test_*.py'
    — 15 tests passed.
  • Ran the SBOM generator workflow locally with nektos/act and pushed the
    renamed generator image to a local registry.
  • Ran the h3 extension Bake job locally with nektos/act; the bookworm and
    trixie builds completed successfully using the renamed generator image.
  • Verified the Bake definition renders both the native type=sbom fallback
    and the custom type=sbom,generator=... form.
  • Captured Trivy vulnerability and license output for pgagent bookworm in
    examples/trivy-sbom-examples.txt.

GitHub-only OIDC, signing, and hosted-runner attestation steps were not run in
the local environment. The temporary Act/local-registry workflow overrides
used for testing are not included in this PR.

Add a workflow_dispatch publish input so the generator image can be pushed to GHCR on demand. Keep pull-request builds non-publishing and preserve local registry testing.

Use the custom generator only on main or in explicit local mode so feature-branch extension CI does not depend on an unpublished image.
Keep the workflow_dispatch publish switch for explicit GHCR testing, but remove the local registry, single-platform, network, and skipped-side-effect paths that were only needed by local Act runs.
Identify the generator with its version and source repository, and emit phase timing plus scanner heartbeats so slow BuildKit SBOM runs are diagnosable.
Keep the existing executable bit when synchronizing the signed agent-branch update.
@ardentperf
ardentperf force-pushed the x-ai/ardentperf/cnpg-sbom-generator branch from 524c602 to 7b4ac37 Compare September 15, 2026 19:28
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.

1 participant