Skip to content

Commit

Permalink
SBOM file generation.
Browse files Browse the repository at this point in the history
Adds new steps in the build and release workflow to generate, sign and
publish a SBOM file for Policy Server.
  • Loading branch information
jvanz committed Aug 31, 2022
1 parent 965b714 commit 6b2a01e
Show file tree
Hide file tree
Showing 9 changed files with 89,269 additions and 17 deletions.
34 changes: 31 additions & 3 deletions .github/workflows/container-image.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build container image
name: Build policy server
on:
push:
branches:
Expand Down Expand Up @@ -28,6 +28,9 @@ jobs:
needs:
- ci
steps:
- name: Install cosign
uses: sigstore/cosign-installer@main

- name: Configure Ubuntu repositories
run: |
sudo dpkg --add-architecture arm64
Expand Down Expand Up @@ -82,11 +85,36 @@ jobs:
cargo build --release --target ${{ matrix.targetarch }}-unknown-linux-musl
mv target/${{ matrix.targetarch }}-unknown-linux-musl/release/policy-server policy-server-${{ matrix.targetarch }}
- name: Upload policy-server
- name: Generate SBOM
run: |
make sbom
# SBOM files should have "sbom" in the name due the CLO monitor
# https://clomonitor.io/docs/topics/checks/#software-bill-of-materials-sbom
cp bom-cargo.json policy-server-${{ matrix.targetarch }}-sbom.spdx.json
- name: Sign BOM file
run: |
cosign sign-blob --output-certificate policy-server-${{ matrix.targetarch }}-sbom.spdx.cert \
--output-signature policy-server-${{ matrix.targetarch }}-sbom.spdx.sig \
policy-server-${{ matrix.targetarch }}-sbom.spdx.json
env:
COSIGN_EXPERIMENTAL: 1

- name: Upload policy-server binary
uses: actions/upload-artifact@v2
with:
name: policy-server-${{ matrix.targetarch }}
path: policy-server-${{ matrix.targetarch }}
path: |
policy-server-${{ matrix.targetarch }}
- name: Upload policy-server SBOM files
uses: actions/upload-artifact@v2
with:
name: policy-server-${{ matrix.targetarch }}-sbom
path: |
policy-server-${{ matrix.targetarch }}-sbom.spdx.json
policy-server-${{ matrix.targetarch }}-sbom.spdx.cert
policy-server-${{ matrix.targetarch }}-sbom.spdx.sig
build-container-image:
name: Build policy server container image
Expand Down
50 changes: 38 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,49 @@
name: policy-server release
name: Release policy server
on:
push:
tags:
- 'v*'
workflow_run:
workflows: ["Build policy server"]
types:
- completed
branches:
- "v*"
jobs:
ci:
uses: kubewarden/policy-server/.github/workflows/tests.yml@main
release:
name: Create release
runs-on: ubuntu-latest
needs:
- ci
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Download build artifacts
uses: actions/github-script@v6
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
const matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name.startsWith("policy-server")
});
for (const artifact of matchArtifact) {
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifact.id,
archive_format: 'zip',
});
let fs = require('fs');
file_path = `${process.env.GITHUB_WORKSPACE}/${artifact.name}.zip`;
fs.writeFileSync(file_path, Buffer.from(download.data));
}
- name: Create release
uses: actions/create-release@v1
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release policy-server ${{ github.ref }}
tag_name: ${{ github.event.workflow_run.head_branch }}
name: Release policy-server ${{ github.event.workflow_run.head_branch }}
draft: false
prerelease: ${{ contains(github.ref, '-alpha') || contains(github.ref, '-beta') || contains(github.ref, '-rc') }}
prerelease: ${{ contains(github.event.workflow_run.head_branch, '-alpha') || contains(github.event.workflow_run.head_branch, '-beta') || contains(github.event.workflow_run.head_branch, '-rc') }}
files: |
policy-server*
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/target
/target
spdx-sbom-generator*
bom-cargo.json
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
name = "policy-server"
version = "1.1.2"
authors = [
"Kubewarden",
"Flavio Castelli <fcastelli@suse.com>",
"Rafael Fernández López <rfernandezlopez@suse.com>",
"Víctor Cuadrado Juan <vcuadradojuan@suse.de>"
"Víctor Cuadrado Juan <vcuadradojuan@suse.de>",
"José Guilherme Vanz <jguilhermevanz@suse.com>"
]
edition = "2018"

Expand Down
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,12 @@ tag:
.PHONY: docker-build
docker-build: test ## Build docker image with the manager.
docker build -t ${IMG} .

spdx-sbom-generator:
curl -L -O https://github.com/opensbom-generator/spdx-sbom-generator/releases/download/v0.0.15/spdx-sbom-generator-v0.0.15-linux-amd64.tar.gz
tar -xf spdx-sbom-generator-v0.0.15-linux-amd64.tar.gz


.PHONY: sbom-generator
sbom: spdx-sbom-generator
./spdx-sbom-generator -f json
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,10 @@ Alternatively, the `policy-server` binary can be built in this way:
```shell
$ make build
```

# Software bill of materials

Policy server has its software bill of materials (SBOM) published every release.
It follows the [SPDX](https://spdx.dev/) version 2.2 format and it can be found
together with the signature and certificate used to signed it in the
[release assets](https://github.com/kubewarden/policy-server/releases)
Loading

0 comments on commit 6b2a01e

Please sign in to comment.