Skip to content

Commit 61846ce

Browse files
committed
Add initial sbom generation support
1 parent 31282b2 commit 61846ce

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

.github/actions/shared-steps/action.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,26 @@ runs:
356356
# Install ansible
357357
sudo ${{ env.runner_os == 'ubuntu' && 'apt-get' || 'dnf -q' }} -y install ansible
358358
359+
- name: Clone SBOM tools
360+
shell: bash
361+
run: |
362+
rm -rf sbom-tools
363+
git clone --depth=1 https://github.com/javihernandez/cloud-images-sbom-tools.git sbom-tools
364+
365+
- name: Set up Python and install generator deps
366+
uses: actions/setup-python@v5
367+
with:
368+
python-version: '3.11'
369+
cache: 'pip'
370+
cache-dependency-path: sbom-tools/requirements.txt
371+
372+
- name: Create venv and install
373+
shell: bash
374+
run: |
375+
python -m venv .venv-sbom
376+
. .venv-sbom/bin/activate
377+
pip install -r sbom-tools/requirements.txt
378+
359379
- name: Initialize packer
360380
shell: bash
361381
run: sudo /usr/bin/packer init -upgrade .
@@ -380,6 +400,18 @@ runs:
380400
echo "IMAGE_FILE=${image_file}" >> $GITHUB_ENV
381401
echo "IMAGE_NAME=$(basename ${image_file})" >> $GITHUB_ENV
382402
403+
# TODO
404+
- name: Generate SBOM
405+
shell: bash
406+
run: |
407+
. ./.venv-sbom/bin/activate
408+
mkdir -p sbom
409+
shopt -s nullglob
410+
for f in sbom-data/sbom-data*.json; do
411+
base=$(basename "$f" .json)
412+
python3 sbom-tools/sbom_generator.py "${base}" "$f" "${base}.spdx.json" -v
413+
done
414+
383415
# - name: Setup tmate session
384416
# uses: mxschmitt/action-tmate@v3
385417

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
---
22
cleanup_ssh_host_keys: true
3+
collect_sbom_data: true

ansible/roles/cleanup_vm/tasks/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
---
2+
- name: Include sbom_data role for SBOM data collection
3+
include_role:
4+
name: sbom_data
5+
when: collect_sbom_data | bool
6+
27
- name: Remove older versions kernel and other packages
38
ansible.builtin.command: dnf -y remove --oldinstallonly
49
register: removeoldoutput

0 commit comments

Comments
 (0)