Skip to content

Commit 791512e

Browse files
fix(ci): improve markdown formatting in scheduled trivy scan output
- Use heredoc for DESCRIPTION to eliminate leading whitespace that caused markdown to render as code blocks - Add table headers per vulnerability section in vuln_summary so each section renders as a proper markdown table - Replace plain text counts with a summary table for better readability - Remove orphaned table header that was separated from data rows by section headings
1 parent d7f95fa commit 791512e

1 file changed

Lines changed: 20 additions & 14 deletions

File tree

.github/workflows/scheduled-trivy-scan.yml

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,17 @@ jobs:
134134
if [ "$IMAGE_VULNS" -gt 0 ]; then
135135
echo "### Docker Image Vulnerabilities ($IMAGE_VULNS)"
136136
echo ""
137+
echo "| Severity | Package | Installed | Fixed | CVE |"
138+
echo "|----------|---------|-----------|-------|-----|"
137139
jq -r '.Results[]?.Vulnerabilities[]? | select(.Severity == "CRITICAL" or .Severity == "HIGH") | "| \(.Severity) | \(.PkgName) | \(.InstalledVersion) | \(.FixedVersion // "N/A") | \(.VulnerabilityID) |"' trivy-image.json | sort -t'|' -k2,2 | head -50
138140
echo ""
139141
fi
140142
141143
if [ "$DEPS_VULNS" -gt 0 ]; then
142144
echo "### Dependency Vulnerabilities ($DEPS_VULNS)"
143145
echo ""
146+
echo "| Severity | Package | Installed | Fixed | CVE |"
147+
echo "|----------|---------|-----------|-------|-----|"
144148
jq -r '.Results[]?.Vulnerabilities[]? | select(.Severity == "CRITICAL" or .Severity == "HIGH") | "| \(.Severity) | \(.PkgName) | \(.InstalledVersion) | \(.FixedVersion // "N/A") | \(.VulnerabilityID) |"' trivy-deps.json | sort -t'|' -k2,2 | head -50
145149
echo ""
146150
fi
@@ -205,26 +209,28 @@ jobs:
205209
206210
TITLE="[Security] $SERVICE — $TOTAL_VULNS CRITICAL,HIGH vulnerabilities ($DATE)"
207211
208-
DESCRIPTION="## Scheduled Trivy Scan Results
212+
read -r -d '' DESCRIPTION << DESC_EOF || true
213+
## Scheduled Trivy Scan Results
209214

210-
**Service:** $SERVICE
211-
**Repository:** [$REPO](${{ github.server_url }}/${{ github.repository }})
212-
**Scan date:** $DATE
213-
**Workflow run:** [View logs]($RUN_URL)
215+
**Service:** $SERVICE
216+
**Repository:** [$REPO](${{ github.server_url }}/${{ github.repository }})
217+
**Scan date:** $DATE
218+
**Workflow run:** [View logs]($RUN_URL)
214219

215-
---
220+
---
216221

217-
**Image vulnerabilities:** $IMAGE_VULNS
218-
**Dependency vulnerabilities:** $DEPS_VULNS
219-
**Total:** $TOTAL_VULNS
222+
| Metric | Count |
223+
|--------|-------|
224+
| Image vulnerabilities | $IMAGE_VULNS |
225+
| Dependency vulnerabilities | $DEPS_VULNS |
226+
| **Total** | **$TOTAL_VULNS** |
220227

221-
| Severity | Package | Installed | Fixed | CVE |
222-
|----------|---------|-----------|-------|-----|
223-
$VULN_SUMMARY
228+
$VULN_SUMMARY
224229

225-
---
230+
---
226231

227-
*This ticket was automatically created by the scheduled Trivy scan workflow.*"
232+
*This ticket was automatically created by the scheduled Trivy scan workflow.*
233+
DESC_EOF
228234

229235
# Build GraphQL mutation
230236
MUTATION=$(jq -n \

0 commit comments

Comments
 (0)