Skip to content

Commit defaaaa

Browse files
committed
feat: [#251] implement basic trivy scanning workflow
1 parent e59c4a7 commit defaaaa

File tree

2 files changed

+90
-1
lines changed

2 files changed

+90
-1
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Docker Security Scan
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
paths:
9+
- "docker/**"
10+
- "templates/docker-compose/**"
11+
- ".github/workflows/docker-security-scan.yml"
12+
pull_request:
13+
paths:
14+
- "docker/**"
15+
- "templates/docker-compose/**"
16+
- ".github/workflows/docker-security-scan.yml"
17+
schedule:
18+
- cron: "0 6 * * *" # Daily at 6 AM UTC
19+
workflow_dispatch: # Allow manual triggering
20+
21+
jobs:
22+
scan-project-images:
23+
name: Scan Project-Built Docker Images
24+
runs-on: ubuntu-latest
25+
timeout-minutes: 15
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
image:
30+
- dockerfile: docker/provisioned-instance/Dockerfile
31+
context: docker/provisioned-instance
32+
name: provisioned-instance
33+
- dockerfile: docker/ssh-server/Dockerfile
34+
context: docker/ssh-server
35+
name: ssh-server
36+
steps:
37+
- name: Checkout code
38+
uses: actions/checkout@v4
39+
40+
- name: Build Docker image
41+
run: |
42+
docker build -t torrust-tracker-deployer/${{ matrix.image.name }}:latest \
43+
-f ${{ matrix.image.dockerfile }} \
44+
${{ matrix.image.context }}
45+
46+
- name: Run Trivy vulnerability scanner
47+
uses: aquasecurity/trivy-action@master
48+
with:
49+
image-ref: torrust-tracker-deployer/${{ matrix.image.name }}:latest
50+
format: "sarif"
51+
output: "trivy-results-${{ matrix.image.name }}.sarif"
52+
severity: "HIGH,CRITICAL"
53+
exit-code: "1"
54+
55+
- name: Upload Trivy results to GitHub Security
56+
uses: github/codeql-action/upload-sarif@v3
57+
if: always()
58+
with:
59+
sarif_file: "trivy-results-${{ matrix.image.name }}.sarif"
60+
61+
scan-third-party-images:
62+
name: Scan Third-Party Docker Images
63+
runs-on: ubuntu-latest
64+
timeout-minutes: 15
65+
strategy:
66+
fail-fast: false
67+
matrix:
68+
# NOTE: These images must match the ones used in templates/docker-compose/docker-compose.yml.tera
69+
# TODO: Automate image detection from docker-compose templates - see https://github.com/torrust/torrust-tracker-deployer/issues/252
70+
image:
71+
- torrust/tracker:develop
72+
- mysql:8.0
73+
- grafana/grafana:11.4.0
74+
- prom/prometheus:v3.0.1
75+
steps:
76+
- name: Run Trivy vulnerability scanner
77+
uses: aquasecurity/trivy-action@master
78+
with:
79+
image-ref: ${{ matrix.image }}
80+
format: "sarif"
81+
output: "trivy-results.sarif"
82+
severity: "HIGH,CRITICAL"
83+
exit-code: "1"
84+
85+
- name: Upload Trivy results to GitHub Security
86+
uses: github/codeql-action/upload-sarif@v3
87+
if: always()
88+
with:
89+
sarif_file: "trivy-results.sarif"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Linting](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/linting.yml/badge.svg)](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/linting.yml) [![Testing](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/testing.yml/badge.svg)](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/testing.yml) [![E2E Infrastructure Tests](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/test-e2e-infrastructure.yml/badge.svg)](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/test-e2e-infrastructure.yml) [![E2E Deployment Tests](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/test-e2e-deployment.yml/badge.svg)](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/test-e2e-deployment.yml) [![Test LXD Container Provisioning](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/test-lxd-provision.yml/badge.svg)](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/test-lxd-provision.yml) [![Coverage](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/coverage.yml/badge.svg)](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/coverage.yml)
1+
[![Linting](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/linting.yml/badge.svg)](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/linting.yml) [![Testing](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/testing.yml/badge.svg)](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/testing.yml) [![E2E Infrastructure Tests](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/test-e2e-infrastructure.yml/badge.svg)](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/test-e2e-infrastructure.yml) [![E2E Deployment Tests](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/test-e2e-deployment.yml/badge.svg)](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/test-e2e-deployment.yml) [![Test LXD Container Provisioning](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/test-lxd-provision.yml/badge.svg)](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/test-lxd-provision.yml) [![Coverage](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/coverage.yml/badge.svg)](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/coverage.yml) [![Docker Security Scan](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/docker-security-scan.yml/badge.svg)](https://github.com/torrust/torrust-tracker-deployer/actions/workflows/docker-security-scan.yml)
22

33
# Torrust Tracker Deployer
44

0 commit comments

Comments
 (0)