Skip to content

Commit 7457d5f

Browse files
authored
ci: add trivy image scan workflow (#1579)
Signed-off-by: Anish Ramasekar <[email protected]>
1 parent 10168bc commit 7457d5f

File tree

4 files changed

+49
-39
lines changed

4 files changed

+49
-39
lines changed

.github/workflows/scan-vulns.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,52 @@ jobs:
2828
go-version: "1.23"
2929
check-latest: true
3030
- uses: golang/govulncheck-action@3a32958c2706f7048305d5a2e53633d7e37e97d0 # v1.0.2
31+
32+
scan_vulnerabilities:
33+
name: "[Trivy] Scan for vulnerabilities"
34+
runs-on: ubuntu-22.04
35+
timeout-minutes: 15
36+
steps:
37+
- name: Harden Runner
38+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
39+
with:
40+
egress-policy: audit
41+
42+
- name: Check out code into the Go module directory
43+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
44+
45+
- name: Download trivy
46+
run: |
47+
pushd $(mktemp -d)
48+
wget https://github.com/aquasecurity/trivy/releases/download/v${{ env.TRIVY_VERSION }}/trivy_${{ env.TRIVY_VERSION }}_Linux-64bit.tar.gz
49+
tar zxvf trivy_${{ env.TRIVY_VERSION }}_Linux-64bit.tar.gz
50+
echo "$(pwd)" >> $GITHUB_PATH
51+
env:
52+
TRIVY_VERSION: "0.57.0"
53+
54+
- name: Download trivy db
55+
run: |
56+
trivy image \
57+
--download-db-only \
58+
--db-repository=ghcr.io/aquasecurity/trivy-db,public.ecr.aws/aquasecurity/trivy-db,docker.io/aquasec/trivy-db
59+
60+
- name: Run trivy on git repository
61+
run: |
62+
trivy fs --format table --ignore-unfixed --skip-dirs website --scanners vuln .
63+
64+
- name: Build docker images
65+
run: |
66+
make docker-build
67+
env:
68+
REGISTRY: e2e
69+
IMAGE_VERSION: test
70+
ALL_LINUX_ARCH: amd64 # build amd64 only to speed up PR gate
71+
OUTPUT_TYPE: type=docker
72+
73+
- name: Run trivy on images
74+
run: |
75+
exit_code=0
76+
for img in "e2e/proxy:test" "e2e/proxy-init:test" "e2e/webhook:test"; do
77+
trivy image --exit-code 1 --ignore-unfixed --severity MEDIUM,HIGH,CRITICAL --ignore-unfixed --pkg-types="os,library" "${img}" || exit_code=1
78+
done
79+
exit $exit_code

.pipelines/nightly.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ schedules:
1313
pool: staging-pool-amd64-mariner-2
1414

1515
jobs:
16-
- job: scan_images
17-
timeoutInMinutes: 30
18-
workspace:
19-
clean: all
20-
steps:
21-
- template: templates/scan-images.yaml
2216
- job: verify_deployment_yaml
2317
timeoutInMinutes: 30
2418
workspace:
@@ -62,7 +56,6 @@ jobs:
6256
- job:
6357
timeoutInMinutes: 60
6458
dependsOn:
65-
- scan_images
6659
- verify_deployment_yaml
6760
workspace:
6861
clean: all
@@ -97,7 +90,6 @@ jobs:
9790
- template: templates/upgrade.yaml
9891
parameters:
9992
dependsOn:
100-
- scan_images
10193
- verify_deployment_yaml
10294
matrix:
10395
upgrade_aks_windows:
@@ -112,7 +104,6 @@ jobs:
112104
- ImageOverride -equals azcu-agent-amd64-mariner-2-cgv2-img
113105
timeoutInMinutes: 60
114106
dependsOn:
115-
- scan_images
116107
- verify_deployment_yaml
117108
workspace:
118109
clean: all

.pipelines/pr.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ pr:
1818
pool: staging-pool-amd64-mariner-2
1919

2020
jobs:
21-
- job: scan_images
22-
timeoutInMinutes: 30
23-
workspace:
24-
clean: all
25-
steps:
26-
- template: templates/scan-images.yaml
2721
- job: lint
2822
timeoutInMinutes: 30
2923
workspace:
@@ -65,7 +59,6 @@ jobs:
6559
timeoutInMinutes: 60
6660
dependsOn:
6761
- lint
68-
- scan_images
6962
- shellcheck
7063
workspace:
7164
clean: all
@@ -112,7 +105,6 @@ jobs:
112105
- ImageOverride -equals azcu-agent-amd64-mariner-2-cgv2-img
113106
dependsOn:
114107
- lint
115-
- scan_images
116108
- shellcheck
117109
workspace:
118110
clean: all

.pipelines/templates/scan-images.yaml

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)