Skip to content

Commit

Permalink
refactor to a single task
Browse files Browse the repository at this point in the history
Signed-off-by: naveensrinivasan <[email protected]>
  • Loading branch information
naveensrinivasan committed Apr 3, 2024
1 parent 988bbc9 commit a66e357
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 27 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/scan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ jobs:


- name: Scan the repository for vulnerabilities - Upstream
env:
FLAVOR: upstream
run: |
uds run grype:install
uds run scan:upstream
uds run scan:scan
- name: Upload SARIF files - Upstream
uses: github/codeql-action/upload-sarif@1b1aada464948af03b950897e5eb522f92603cc2
Expand Down Expand Up @@ -73,6 +75,7 @@ jobs:
env:
GRYPE_USERNAME: ${{ secrets.IRON_BANK_ROBOT_USERNAME }}
GRYPE_PASSWORD: ${{ secrets.IRON_BANK_ROBOT_PASSWORD }}
FLAVOR: registry1

- name: Upload SARIF files - Registry1
uses: github/codeql-action/upload-sarif@1b1aada464948af03b950897e5eb522f92603cc2
Expand Down
29 changes: 3 additions & 26 deletions tasks/scan.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
tasks:
- name: upstream
description: Create a UDS package with upstream flavor, extract the SBOM, and analyze for vulnerabilities
- name: scan
description: Create a UDS package with specified flavor, extract the SBOM, and analyze for vulnerabilities
actions:
- cmd: |
bash -c '
flavor="upstream"
flavor="${FLAVOR}"
output_dir="sbom/$flavor"
mkdir -p "$output_dir"
uds zarf package create . --flavor="$flavor" --confirm --no-progress -o "$output_dir"
Expand All @@ -27,26 +27,3 @@ tasks:
echo "Updated SARIF file path to $sbom_base_name using yq for $sarif_file_name"
done
'
- name: registry1
description: Create a UDS package with registry1 flavor, extract the SBOM, and analyze for vulnerabilities
actions:
- cmd: |
bash -c '
flavor="registry1"
output_dir="sbom/$flavor"
mkdir -p "$output_dir"
uds zarf package create . --flavor="$flavor" --confirm --no-progress -o "$output_dir"
for file in "$output_dir"/*.zst; do
uds zarf package inspect "$file" --sbom-out "$output_dir" --no-progress
done
sarif_output_dir="./sarif"
mkdir -p "$sarif_output_dir"
find "sbom/$flavor" -type f -name "*.json" | while read -r json_file; do
sarif_file_name="${flavor}_$(basename "${json_file}").sarif"
echo "Processing $json_file"
echo "Outputting to $sarif_output_dir/$sarif_file_name"
grype sbom:"$json_file" -o sarif --file "$sarif_output_dir/$sarif_file_name"
echo "Grype analysis for $json_file exported to $sarif_output_dir/$sarif_file_name (errors ignored)"
done
'

0 comments on commit a66e357

Please sign in to comment.