Skip to content

Commit c754bc1

Browse files
Display scan vulnerabilities in Actions summary on failure (#76)
1 parent 51c455c commit c754bc1

3 files changed

Lines changed: 28 additions & 5 deletions

File tree

.github/workflows/build-scan-push.yml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,32 @@ jobs:
139139
- name: Fail build if scans failed
140140
if: ${{ (steps.grype-scan.outcome == 'failure' || steps.trivy-scan.outcome == 'failure') && matrix.target == 'production' && github.ref != 'refs/heads/main' }}
141141
run: |
142-
echo "One or more scans failed. Failing the build."
143-
echo "Grype scan outcome: ${{ steps.grype-scan.outcome }}"
144-
echo "Trivy scan outcome: ${{ steps.trivy-scan.outcome }}"
142+
echo "## Scan Results" >> $GITHUB_STEP_SUMMARY
143+
144+
if [ "${{ steps.grype-scan.outcome }}" == "failure" ]; then
145+
echo "### Grype Vulnerabilities" >> $GITHUB_STEP_SUMMARY
146+
echo "| Severity | CVE | Package | Details |" >> $GITHUB_STEP_SUMMARY
147+
echo "|----------|-----|---------|---------|" >> $GITHUB_STEP_SUMMARY
148+
jq -r '.runs[].results[] | "| \(.level) | \(.ruleId) | \(.message.text | split("\n")[0]) | \(.message.text | split("\n")[1:3] | join(", ")) |"' \
149+
"${{ steps.grype-scan.outputs.sarif }}" >> $GITHUB_STEP_SUMMARY
150+
echo "::group::Grype Vulnerabilities"
151+
jq -r '.runs[].results[] | "\(.level)\t\(.ruleId)\t\(.message.text)"' \
152+
"${{ steps.grype-scan.outputs.sarif }}"
153+
echo "::endgroup::"
154+
fi
155+
156+
if [ "${{ steps.trivy-scan.outcome }}" == "failure" ]; then
157+
echo "### Trivy Vulnerabilities" >> $GITHUB_STEP_SUMMARY
158+
echo "| Severity | CVE | Package | Details |" >> $GITHUB_STEP_SUMMARY
159+
echo "|----------|-----|---------|---------|" >> $GITHUB_STEP_SUMMARY
160+
jq -r '.runs[].results[] | "| \(.level) | \(.ruleId) | \(.message.text | split("\n")[0]) | \(.message.text | split("\n")[1:3] | join(", ")) |"' \
161+
"trivy-reports-dotnet-${{ matrix.image.netVersion }}" >> $GITHUB_STEP_SUMMARY
162+
echo "::group::Trivy Vulnerabilities"
163+
jq -r '.runs[].results[] | "\(.level)\t\(.ruleId)\t\(.message.text)"' \
164+
"trivy-reports-dotnet-${{ matrix.image.netVersion }}"
165+
echo "::endgroup::"
166+
fi
167+
145168
exit 1
146169
147170
- name: Login to DockerHub

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Set default values for build arguments
2-
ARG DEFRA_VERSION=2.0.8
2+
ARG DEFRA_VERSION=2.0.9
33
ARG BASE_VERSION=10.0-alpine3.23
44

55
# Extend Alpine variant of ASP.NET base image for small image size

JOB.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
DEFRA_VERSION=2.0.8
1+
DEFRA_VERSION=2.0.9
22
IMAGE_NAME=dotnetcore

0 commit comments

Comments
 (0)