Skip to content

Commit 6a403af

Browse files
committed
ci: update gh workflow
Signed-off-by: Sonu Saha <[email protected]>
1 parent 8818fa9 commit 6a403af

File tree

1 file changed

+59
-16
lines changed

1 file changed

+59
-16
lines changed

Diff for: .github/workflows/bundler_audit.yml

+59-16
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,73 @@
1-
name: Bundler Audit / Vulnerability Scan
1+
name: Download SBOM from Insights and Convert to CSV
2+
3+
# on:
4+
# workflow_dispatch:
5+
6+
7+
# # NOTE: We would probably want to run this workflow on every push to main and not on pull requests
8+
# # on:
9+
# # push:
10+
# # branches:
11+
# # - main
212

313
on:
4-
schedule:
5-
- cron: '0 0 * * 0' # Weekly on Sundays at midnight
6-
push:
7-
branches:
8-
- main
914
pull_request:
1015
branches:
1116
- main
1217

1318
jobs:
14-
audit:
19+
convert-sbom:
1520
runs-on: ubuntu-latest
1621

1722
steps:
18-
- name: Checkout code
23+
- name: Checkout Code
1924
uses: actions/checkout@v3
2025

21-
- name: Set up Ruby
22-
uses: ruby/setup-ruby@v1
23-
with:
24-
ruby-version: 3.2
26+
- name: Set Timestamp and Unique Filename
27+
run: |
28+
FILE_PREFIX=$(echo "${{ github.repository }}" | sed 's|/|-|g')-$(date +%Y%m%d%H%M%S)
29+
echo "FILE_PREFIX=${FILE_PREFIX}" >> $GITHUB_ENV
30+
31+
- name: Download SBOM
32+
run: |
33+
curl -L \
34+
-H "Accept: application/vnd.github+json" \
35+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
36+
-H "X-GitHub-Api-Version: 2022-11-28" \
37+
https://api.github.com/repos/${{ github.repository }}/dependency-graph/sbom \
38+
-o "${FILE_PREFIX}-sbom.json"
2539
26-
- name: Install dependencies
27-
run: bundle install
40+
- name: Verify SBOM JSON File
41+
run: |
42+
ls -l "${FILE_PREFIX}-sbom.json"
2843
29-
- name: Run Bundler Audit
30-
run: bundle exec bundler-audit check --update
44+
- name: Preview SBOM JSON Content
45+
run: |
46+
head -n 20 "${FILE_PREFIX}-sbom.json"
47+
48+
- name: Convert SBOM to CSV using jq
49+
run: |
50+
jq -r '
51+
.sbom.packages[] | [
52+
.name,
53+
.SPDXID,
54+
.versionInfo,
55+
.downloadLocation,
56+
( .externalRefs[]? | .referenceLocator )
57+
] | @csv' "${FILE_PREFIX}-sbom.json" > "${FILE_PREFIX}-sbom.csv"
58+
59+
- name: Verify SBOM CSV File
60+
run: |
61+
ls -l "${FILE_PREFIX}-sbom.csv"
62+
63+
- name: Upload SBOM JSON as Artifact
64+
uses: actions/upload-artifact@v3
65+
with:
66+
name: sbom-json
67+
path: ${{ env.FILE_PREFIX }}-sbom.json
68+
69+
- name: Upload SBOM CSV as Artifact
70+
uses: actions/upload-artifact@v3
71+
with:
72+
name: sbom-csv
73+
path: ${{ env.FILE_PREFIX }}-sbom.csv

0 commit comments

Comments
 (0)