Skip to content

Commit

Permalink
move github vulnerability report
Browse files Browse the repository at this point in the history
  • Loading branch information
clay-lake committed Dec 20, 2024
1 parent 3539269 commit 41d506a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/Test-Rock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,35 @@ jobs:
name: ${{ steps.configure-trivy.outputs.report-name }}
path: ${{ steps.configure-trivy.outputs.report-name}}


# We have to walk through the vulnerabilities since trivy does not support outputting the results as Markdown
- name: Create markdown content
id: create-markdown
run: |
set -x
vulnerabilities="$(jq -r -c '[
try(.scanner.result.Results[])
| .Target as $target
| .Vulnerabilities
| select(. != null)
| .[]
| {Target: $target, LastModifiedDate: .LastModifiedDate, VulnerabilityID: .VulnerabilityID,
PkgName: .PkgName, Severity: .Severity}
]' < ${{ steps.configure-trivy.outputs.report-name }})"
num_vulns=$(echo '$vulnerabilities' | jq -r 'length')
if [[ $num_vulns -gt 0 ]]; then
echo "# Vulnerabilities found for ${{ inputs.oci-archive-name }}" >> $GITHUB_STEP_SUMMARY
title="Vulnerabilities found for ${{ inputs.oci-archive-name }}"
echo "## $title" >> $GITHUB_STEP_SUMMARY
echo "| ID | Target | Severity | Package |" >> $GITHUB_STEP_SUMMARY
echo "| -- | ----- | -------- | ------- |" >> $GITHUB_STEP_SUMMARY
echo '$vulnerabilities' | jq -r '.[] | "| \(.VulnerabilityID) | /\(.Target) | \(.Severity) | \(.PkgName) |"' >> $GITHUB_STEP_SUMMARY
fi
test-malware:
runs-on: ubuntu-22.04
name: "test-malware ${{ inputs.oci-archive-name != '' && format('| {0}', inputs.oci-archive-name) || ' '}}"
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/Vulnerability-Scan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,6 @@ jobs:
echo "issue-body-file=issue.md" >> "$GITHUB_OUTPUT"
fi
- name: Write to summary
if: ${{ !inputs.create-issue && steps.create-markdown.outputs.vulnerability-exists == 'true' }}
run: |
echo "# Vulnerabilities found for ${{ inputs.oci-image-name }}" >> $GITHUB_STEP_SUMMARY
cat ${{ steps.create-markdown.outputs.issue-body-file }} | tail -n +2 >> $GITHUB_STEP_SUMMARY
- id: issue-exists
if: ${{ inputs.create-issue}}
run: |
Expand Down

0 comments on commit 41d506a

Please sign in to comment.