Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an sbom workflow #6251

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions .github/workflows/anchore-syft.yml

This file was deleted.

81 changes: 81 additions & 0 deletions .github/workflows/sbom.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: SBOM Generator

on:
push:
branches: [master]
pull_request:
branches: [master]

workflow_dispatch:

permissions: write-all

jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
check-latest: true
cache: 'yarn'

- name: Install Microsoft SBOM Tool
run: |
curl -Lo /tmp/sbom-tool https://github.com/microsoft/sbom-tool/releases/latest/download/sbom-tool-linux-x64
chmod +x /tmp/sbom-tool

- name: Install project dependencies
run: yarn install --frozen-lockfile --production

- name: sbomtool expects a directory to exist to place results in
run: |
mkdir -p /tmp/sbomtool/directory
mkdir -p /tmp/sbomtool/image

- name: sbomtool directory spdx
if: always()
run: /tmp/sbom-tool generate -b . -bc . -li true -pm true -m /tmp/sbomtool/directory -pn Heimdall2 -pv 2.10.19 -ps MITRE -nsb https://saf.mitre.org -V Verbose

- name: bug in cyclonedxcli spdx converter causes a valid field to throw an error, applying a workaround
if: always()
run: sed 's/PACKAGE-MANAGER/PACKAGE_MANAGER/g' /tmp/sbomtool/directory/_manifest/spdx_2.2/manifest.spdx.json > /tmp/sbomtool/directory/_manifest/spdx_2.2/manifest_fixed.spdx.json

- run: tree /tmp/sbomtool

- run: chmod 777 /tmp/sbomtool/directory/_manifest/spdx_2.2/manifest_fixed.spdx.json

- run: ls -lah /tmp/sbomtool/directory/_manifest/spdx_2.2/manifest_fixed.spdx.json

- name: sbomtool check permissions in container
if: always()
run: docker run -t -v /tmp/sbomtool/directory/_manifest/spdx_2.2/manifest_fixed.spdx.json:/tmp/sbomtool_directory.spdx.json -v /tmp/sbomtool/directory.cdx.json:/tmp/sbomtool_directory.cdx.json --entrypoint /bin/bash cyclonedx/cyclonedx-cli:latest -- /bin/ls -lah /tmp

- name: sbomtool directory spdx converted
if: always()
run: docker run -t -v /tmp/sbomtool/directory/_manifest/spdx_2.2/manifest_fixed.spdx.json:/tmp/sbomtool_directory.spdx.json -v /tmp/sbomtool/directory.cdx.json:/tmp/sbomtool_directory.cdx.json cyclonedx/cyclonedx-cli:latest convert --input-file /tmp/sbomtool_directory.spdx.json --output-file /tmp/sbomtool_directory.cdx.json --input-format spdxjson --output-format json

- name: Build the Docker image
if: always()
run: docker build -f Dockerfile -t mitre/heimdall2:throwaway .

- name: sbomtool image spdx
if: always()
run: /tmp/sbom-tool generate -di mitre/heimdall2:throwaway -li true -pm true -m /tmp/sbomtool/image -pn Heimdall2 -pv 2.10.19 -ps MITRE -nsb https://saf.mitre.org -V Verbose

- name: bug in cyclonedxcli spdx converter causes a valid field to throw an error, applying a workaround
if: always()
run: sed 's/PACKAGE-MANAGER/PACKAGE_MANAGER/g' /tmp/sbomtool/image/_manifest/spdx_2.2/manifest.spdx.json > /tmp/sbomtool/image/_manifest/spdx_2.2/manifest_fixed.spdx.json

- name: sbomtool image spdx converted
if: always()
run: docker run -t -v /tmp/sbomtool/image/_manifest/spdx_2.2/manifest_fixed.spdx.json:/tmp/sbomtool_image.spdx.json -v /tmp/sbomtool/image.cdx.json:/tmp/sbomtool_image.cdx.json cyclonedx/cyclonedx-cli:latest convert --input-file /tmp/sbomtool_image.spdx.json --output-file /tmp/sbomtool_image.cdx.json --input-format spdxjson --output-format json

- uses: actions/upload-artifact@v4
if: always()
with:
path: /tmp/sbomtool
name: "MS SBOM Tool experiments"
Loading