Skip to content

Commit f628c6d

Browse files
committed
update
1 parent c26762b commit f628c6d

File tree

3 files changed

+84
-5
lines changed

3 files changed

+84
-5
lines changed

.github/workflows/trivy.yaml

+61-5
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,72 @@ jobs:
1212
- name: Checkout code
1313
uses: actions/checkout@v4
1414

15+
- name: Build Docker Image 1 (Vulnerable - Ubuntu)
16+
run: |
17+
docker build -t vulnerable-image-ubuntu -f Dockerfile1 .
1518
16-
- name: Run Trivy vulnerability scanner in fs mode
19+
- name: Build Docker Image 3 (Non-vulnerable)
20+
run: |
21+
docker build -t non-vulnerable-image -f Dockerfile3 .
22+
23+
- name: "Run Trivy vulnerability scanner: image"
24+
uses: aquasecurity/[email protected]
25+
with:
26+
image-ref: 'vulnerable-image-ubuntu'
27+
scan-type: 'image'
28+
vuln-type: 'os'
29+
format: 'sarif'
30+
output: 'trivy-results-image1.sarif'
31+
32+
- name: Upload Trivy scan results to GitHub Security tab
33+
uses: github/codeql-action/upload-sarif@v3
34+
with:
35+
sarif_file: 'trivy-results-image1.sarif'
36+
category: 'image'
37+
38+
- name: "Run Trivy vulnerability scanner: image"
39+
uses: aquasecurity/[email protected]
40+
with:
41+
image-ref: 'non-vulnerable-image'
42+
scan-type: 'image'
43+
vuln-type: 'os'
44+
format: 'sarif'
45+
output: 'trivy-results-image2.sarif'
46+
47+
- name: Upload Trivy scan results to GitHub Security tab
48+
uses: github/codeql-action/upload-sarif@v3
49+
with:
50+
sarif_file: 'trivy-results-image2.sarif'
51+
category: 'image'
52+
53+
- name: "Run Trivy vulnerability scanner: image"
54+
uses: aquasecurity/[email protected]
55+
with:
56+
image-ref: 'vulnerable-image-ubuntu'
57+
scan-type: 'image'
58+
scanners: 'vuln,secret'
59+
vuln-type: 'os'
60+
format: 'sarif'
61+
output: 'trivy-results-image1.sarif'
62+
63+
- name: Upload Trivy scan results to GitHub Security tab
64+
uses: github/codeql-action/upload-sarif@v3
65+
with:
66+
sarif_file: 'trivy-results-image1.sarif'
67+
category: 'image'
68+
69+
- name: "Run Trivy vulnerability scanner: image"
1770
uses: aquasecurity/[email protected]
1871
with:
19-
scan-type: 'fs'
20-
scan-ref: '.'
72+
image-ref: 'non-vulnerable-image'
73+
scan-type: 'image'
74+
scanners: 'vuln,secret'
75+
vuln-type: 'os'
2176
format: 'sarif'
22-
output: 'trivy-results.sarif'
77+
output: 'trivy-results-image2.sarif'
2378

2479
- name: Upload Trivy scan results to GitHub Security tab
2580
uses: github/codeql-action/upload-sarif@v3
2681
with:
27-
sarif_file: 'trivy-results.sarif'
82+
sarif_file: 'trivy-results-image2.sarif'
83+
category: 'image'

Dockerfile1

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Dockerfile 1 (Vulnerable)
2+
FROM ubuntu:18.04
3+
4+
RUN apt-get update && \
5+
apt-get install -y \
6+
openssl \
7+
curl
8+
9+
# Deliberately using an old version of OpenSSL with known vulnerabilities
10+
RUN apt-get install -y openssl=1.1.0g-2ubuntu4.3
11+
12+
# Adding a fake AWS secret key
13+
RUN echo "AWS_SECRET_ACCESS_KEY=AKIAIOSFODNN7EXAMPLE" > /root/.aws/credentials

Dockerfile3

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Dockerfile 3 (Non-vulnerable)
2+
FROM ubuntu:20.04
3+
4+
RUN apt-get update && \
5+
apt-get install -y \
6+
openssl \
7+
curl
8+
9+
# Using the latest versions with no known vulnerabilities
10+
RUN apt-get install -y openssl

0 commit comments

Comments
 (0)