Skip to content

Commit 5bce83e

Browse files
committed
ci: test few more things to verify if we are getting more info
Signed-off-by: Sonu Saha <[email protected]>
1 parent e72a6fe commit 5bce83e

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

Diff for: .github/workflows/sbom.yml

+30-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
name: Download SBOM from Insights and Convert to CSV
22

3-
# on:
4-
# workflow_dispatch:
5-
6-
73
# # 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
4+
# on:
5+
# push:
6+
# branches:
7+
# - main
128

139
on:
1410
pull_request:
@@ -47,14 +43,38 @@ jobs:
4743
4844
- name: Convert SBOM to CSV using jq
4945
run: |
46+
echo "name,SPDXID,versionInfo,downloadLocation,externalRefs,license,source_code_url,vendor" > "${FILE_PREFIX}-sbom.csv"
5047
jq -r '
5148
.sbom.packages[] | [
5249
.name,
5350
.SPDXID,
5451
.versionInfo,
5552
.downloadLocation,
56-
( .externalRefs[]? | .referenceLocator )
57-
] | @csv' "${FILE_PREFIX}-sbom.json" > "${FILE_PREFIX}-sbom.csv"
53+
( .externalRefs[]? | .referenceLocator ),
54+
"None", "None", "None"
55+
] | @csv' "${FILE_PREFIX}-sbom.json" >> "${FILE_PREFIX}-sbom.csv"
56+
57+
- name: Enrich SBOM CSV with RubyGems Data
58+
run: |
59+
TEMP_CSV="${FILE_PREFIX}-sbom-temp.csv"
60+
echo "name,SPDXID,versionInfo,downloadLocation,externalRefs,license,source_code_url,vendor" > "$TEMP_CSV"
61+
tail -n +2 "${FILE_PREFIX}-sbom.csv" | while IFS=, read -r name SPDXID versionInfo downloadLocation externalRefs license source_code_url vendor; do
62+
if [[ "$downloadLocation" == *"rubygems.org"* ]]; then
63+
gem_name=$(echo "$name" | tr -d '"')
64+
version=$(echo "$versionInfo" | tr -d '"')
65+
api_url="https://rubygems.org/api/v2/rubygems/${gem_name}/versions/${version}.json"
66+
response=$(curl -s "$api_url")
67+
new_license=$(echo "$response" | jq -r '.licenses[0] // "None"')
68+
new_source_code_url=$(echo "$response" | jq -r '.source_code_uri // "None"')
69+
new_vendor=$(echo "$response" | jq -r '.authors // "None"')
70+
else
71+
new_license="None"
72+
new_source_code_url="None"
73+
new_vendor="None"
74+
fi
75+
echo "$name,$SPDXID,$versionInfo,$downloadLocation,$externalRefs,$new_license,$new_source_code_url,$new_vendor" >> "$TEMP_CSV"
76+
done
77+
mv "$TEMP_CSV" "${FILE_PREFIX}-sbom.csv"
5878
5979
- name: Verify SBOM CSV File
6080
run: |

0 commit comments

Comments
 (0)