Skip to content

Commit bc223b2

Browse files
[CI] Add linter workflow for Dockerfiles: Trivy
1 parent c860b3a commit bc223b2

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

.github/workflows/trivy.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Runs linter for Docker files
2+
name: Trivy
3+
4+
# Due to lower score on Scorecard we're running this separately from
5+
# "PR/push" workflow. For some reason permissions weren't properly set
6+
# or recognized (by Scorecard). If Scorecard changes its behavior we can
7+
# use 'workflow_call' trigger.
8+
on:
9+
push:
10+
pull_request:
11+
paths:
12+
- '.github/docker/*Dockerfile'
13+
- '.github/workflows/trivy.yml'
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
17+
cancel-in-progress: true
18+
19+
permissions:
20+
contents: read
21+
22+
jobs:
23+
trivy:
24+
name: Trivy
25+
runs-on: ubuntu-latest
26+
permissions:
27+
security-events: write
28+
29+
steps:
30+
- name: Clone the git repo
31+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
32+
33+
- name: Run Trivy
34+
uses: aquasecurity/trivy-action@84384bd6e777ef152729993b8145ea352e9dd3ef # v0.17.0
35+
with:
36+
scan-type: 'config'
37+
hide-progress: false
38+
format: 'sarif'
39+
output: 'trivy-results.sarif'
40+
exit-code: 1 # Fail if issue found
41+
# See .trivyignore file with suppressions
42+
43+
- name: Upload results
44+
uses: github/codeql-action/upload-sarif@e8893c57a1f3a2b659b6b55564fdfdbbd2982911 # v3.24.0
45+
with:
46+
sarif_file: 'trivy-results.sarif'

.trivyignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Docs: https://aquasecurity.github.io/trivy/latest/docs/configuration/filtering/#trivyignore
2+
3+
# In docker files:
4+
# non-root user is always created within docker, but we switch it only in CI workflows;
5+
# not enforcing non-root user makes it easier for developers to use their own users in local container
6+
AVD-DS-0002
7+
8+
# In docker files:
9+
# HEALTHCHECK is not required for development, nor in CI (failed docker = failed CI)
10+
AVD-DS-0026

0 commit comments

Comments
 (0)