-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Add a reusable SBOM scan workflow * ci: Update usage of local reusable workflows and actions
- Loading branch information
Showing
10 changed files
with
104 additions
and
4 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
name: Create & Scan SBOM | ||
on: | ||
workflow_call: | ||
jobs: | ||
create-and-scan-sbom: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
security-events: write | ||
contents: write | ||
id-token: write | ||
attestations: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: x # any version | ||
- name: Create lockfile | ||
run: | | ||
pip install poetry | ||
poetry lock | ||
- name: Create SBOM | ||
uses: anchore/sbom-action@v0 | ||
with: | ||
format: spdx-json | ||
output-file: ${{ github.event.repository.name }}-sbom.spdx.json | ||
- uses: actions/attest-build-provenance@v1 | ||
if: ${{ !(github.event.pull_request.head.repo.fork || github.event.workflow_call.pull_request.head.repo.fork) && github.actor != 'dependabot[bot]' }} | ||
with: | ||
subject-path: ${{ github.event.repository.name }}-sbom.spdx.json | ||
- name: Scan SBOM | ||
uses: anchore/scan-action@v4 | ||
id: scan | ||
with: | ||
sbom: ${{ github.event.repository.name }}-sbom.spdx.json | ||
fail-build: true | ||
severity-cutoff: low | ||
- name: Upload SBOM scan SARIF report as a workflow artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: sarif_artifact | ||
path: ${{ steps.scan.outputs.sarif }} | ||
if-no-files-found: error | ||
- name: Upload SBOM scan SARIF report to GitHub UI Security tab | ||
if: ${{ github.event_name != 'pull_request' }} | ||
uses: github/codeql-action/upload-sarif@v3 | ||
with: | ||
sarif_file: ${{ steps.scan.outputs.sarif }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
name: Create & Scan SBOM | ||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
release: | ||
types: [published] | ||
jobs: | ||
sbom-scan: | ||
uses: ./.github/workflows/_reusable-sbom-scan.yml | ||
permissions: | ||
security-events: write | ||
contents: write | ||
id-token: write | ||
attestations: write |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# sbom-scan.yml | ||
|
||
This workflow will create a Software Bill of Materials (SBOM) for the repository using the | ||
[`anchore/sbom-action`](https://github.com/anchore/sbom-action) Action and then scan the SBOM | ||
using the [`anchore/scan-action`](https://github.com/anchore/scan-action) Action. | ||
|
||
In order to use this workflow, the Python package must be using the | ||
[Poetry package manager](https://python-poetry.org/). When calling the reusable workflow, the | ||
following permissions must be set to `write`: `security-events`, `contents`, `id-token`, and | ||
`attestations`. | ||
|
||
## Example | ||
|
||
```yaml | ||
name: Create & Scan SBOM | ||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
release: | ||
types: [published] | ||
jobs: | ||
sbom-scan: | ||
uses: tektronix/python-package-ci-cd/.github/workflows/_reusable-sbom-scan.yml@main # it is recommended to use the latest release tag instead of `main` | ||
permissions: | ||
security-events: write | ||
contents: write | ||
id-token: write | ||
attestations: write | ||
``` |