From e8dbe610e959cbf6b44f679bbf0a5f16d117c3b9 Mon Sep 17 00:00:00 2001 From: knqyf263 Date: Fri, 11 Oct 2024 10:50:03 +0400 Subject: [PATCH] test https://github.com/aquasecurity/trivy-action/pull/399#issuecomment-2404995222 Signed-off-by: knqyf263 --- .github/workflows/test.yaml | 26 +++++++ .github/workflows/trivy_markdown_template.tpl | 77 +++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 .github/workflows/test.yaml create mode 100644 .github/workflows/trivy_markdown_template.tpl diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..1057691 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,26 @@ +name: Scan image +on: + workflow_dispatch: +jobs: + build-and-push-image: + runs-on: ubuntu-latest + # These permissions are needed to interact with GitHub's OIDC Token endpoint. + permissions: + id-token: write + contents: read + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Vulnerability scan (fixed and non-fixed) + uses: aquasecurity/trivy-action@0.25.0 + env: + TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2 + with: + image-ref: 'alpine:3.20.0' + format: 'template' + # Manually downloaded the template from the Trivy GitHub repo since it is somehow not found by default + template: '@/github/workspace/.github/workflows/trivy_html_template.tpl' + output: 'report.html' + severity: 'HIGH,CRITICAL' + timeout: '12m' diff --git a/.github/workflows/trivy_markdown_template.tpl b/.github/workflows/trivy_markdown_template.tpl new file mode 100644 index 0000000..ca3978c --- /dev/null +++ b/.github/workflows/trivy_markdown_template.tpl @@ -0,0 +1,77 @@ +{{- if . }} +{{- range . }} +

Target {{ escapeXML .Target }}

+{{- if (and (eq (len .Vulnerabilities) 0) (eq (len .Misconfigurations) 0) (eq (len .Secrets) 0)) }} +

Nothing found

+{{- else }} +{{- if (gt (len .Vulnerabilities) 0) }} +

Vulnerabilities ({{ len .Vulnerabilities }})

+ + + + + + + + + {{- range .Vulnerabilities }} + + + + + + + + {{- end }} +
PackageIDSeverityInstalled VersionFixed Version
{{ escapeXML .PkgName }}{{ escapeXML .VulnerabilityID }}{{ escapeXML .Severity }}{{ escapeXML .InstalledVersion }}{{ escapeXML .FixedVersion }}
+{{- end }} +{{- if (gt (len .Misconfigurations ) 0) }} +

Misconfigurations ({{ len .Misconfigurations }})

+ + + + + + + + + {{- range .Misconfigurations }} + + + + + + + + {{- end }} +
TypeIDCheckSeverityMessage
{{ escapeXML .Type }}{{ escapeXML .ID }}{{ escapeXML .Title }}{{ escapeXML .Severity }} + {{ escapeXML .Message }} +
{{ escapeXML .PrimaryURL }}
+
+{{- end }} +{{- if (gt (len .Secrets ) 0) }} +

Secrets ({{ len .Secrets }})

+ + + + + + + + + {{- range .Secrets }} + + + + + + + + {{- end }} +
TypeIDSeverityLinesMatch
{{ escapeXML (toString .Category) }}{{ escapeXML .RuleID }}{{ escapeXML .Severity }}{{ escapeXML (toString .StartLine) }}-{{ escapeXML (toString .EndLine) }}{{ escapeXML .Match }}
+{{- end }} +{{- end }} +{{- end }} +{{- else }} +

Trivy Returned Empty Report

+{{- end }}