-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding container image vulnerability scanning (Grype) GitHub Action (#…
…2113) Grype vulnerability scanning github action
- Loading branch information
1 parent
ea69bef
commit faee7f3
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: container vulnerability scanning | ||
on: [workflow_dispatch] | ||
jobs: | ||
vulnerability-scanner: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Create repo directory before checking out latest code | ||
run: mkdir -p repo | ||
- name: Checkout the latest code | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: master | ||
path: repo | ||
- name: Read JSON file | ||
id: valid-image-json | ||
run: | | ||
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | ||
echo "images_list<<$EOF" >> $GITHUB_OUTPUT | ||
cat repo/build/valid_images.json >> $GITHUB_OUTPUT | ||
echo "$EOF" >> $GITHUB_OUTPUT | ||
- name: Reading output variable | ||
run: echo ${{fromJson(steps.valid-image-json.outputs.images_list)}} | ||
outputs: | ||
valid_images: ${{steps.valid-image-json.outputs.images_list}} | ||
report-analysis: | ||
runs-on: ubuntu-20.04 | ||
needs: | ||
- vulnerability-scanner | ||
strategy: | ||
max-parallel: 3 | ||
fail-fast: false | ||
matrix: | ||
images: ${{fromJson(needs.vulnerability-scanner.outputs.valid_images).images}} | ||
steps: | ||
- name: Printing Image Registry | ||
id: image-registry | ||
run: echo "image_registry=${{fromJson(needs.vulnerability-scanner.outputs.valid_images).image_registry}}" >> "$GITHUB_ENV" | ||
- name: Printing Image Tag | ||
id: image-tag | ||
run: echo "image_tag=${{fromJson(needs.vulnerability-scanner.outputs.valid_images).tag}}" >> "$GITHUB_ENV" | ||
- name: Printing Image Path | ||
run: echo "image_path=${{env.image_registry}}/${{matrix.images}}:${{env.image_tag}}" >> "$GITHUB_ENV" | ||
- name: Running vulnerability scanner | ||
uses: anchore/scan-action@v3 | ||
id: vulnerability-scanning | ||
with: | ||
image: ${{env.image_path}} | ||
fail-build: false | ||
output-format: json | ||
only-fixed: true | ||
- name: Create repo directory before checking out latest code | ||
run: mkdir -p repo | ||
- name: Checkout the latest code | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: master | ||
path: repo | ||
- name: Parsing vulnerability scanner report | ||
run: go run repo/pkg/tools/grype_report_parser_tool.go -s "High,Critical" -p results.json | ||
|