Skip to content

Commit 655a8b1

Browse files
authored
security(trivy): add trivy to supply chain (#793)
1 parent d36f973 commit 655a8b1

File tree

4 files changed

+89
-17
lines changed

4 files changed

+89
-17
lines changed

.github/workflows/build_and_deploy.yml

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
name: Build and deploy
1+
name: Build, scan images and deploy
22

33
on:
44
push:
55
branches:
66
- main
77
release:
8-
types:
8+
types:
99
- published
1010
- edited
11-
workflow_dispatch: # Add this to allow manual triggering
11+
workflow_dispatch:
1212

1313
jobs:
14-
build-api:
14+
build-opengatellm-api:
1515
name: Build and push OpenGateLLM API image
1616
runs-on: ubuntu-latest
1717
env:
@@ -112,7 +112,7 @@ jobs:
112112
tags: ${{ env.GITHUB_PLAYGROUND_IMAGE_NAME }}:${{ env.IMAGE_TAG }}
113113
cache-from: type=registry,ref=${{ env.GITHUB_PLAYGROUND_IMAGE_NAME }}:cache
114114
cache-to: type=registry,ref=${{ env.GITHUB_PLAYGROUND_IMAGE_NAME }}:cache,mode=max
115-
115+
116116
build-albert-playground:
117117
name: Build and push Albert playground image
118118
runs-on: ubuntu-latest
@@ -123,13 +123,12 @@ jobs:
123123
matrix:
124124
environment: [dev, staging, prod]
125125
include:
126-
- environment: prod
127-
url: https://albert.playground.etalab.gouv.fr
128-
- environment: staging
129-
url: https://albert.playground.staging.etalab.gouv.fr
130126
- environment: dev
131127
url: https://albert.playground.dev.etalab.gouv.fr
132-
128+
- environment: staging
129+
url: https://albert.playground.staging.etalab.gouv.fr
130+
- environment: prod
131+
url: https://albert.playground.etalab.gouv.fr
133132
steps:
134133
- name: Checkout repository
135134
uses: actions/checkout@v4
@@ -160,18 +159,47 @@ jobs:
160159
tags: ${{ env.GITLAB_PLAYGROUND_IMAGE_NAME }}/${{ matrix.environment }}:${{ env.IMAGE_TAG }}
161160
cache-from: type=registry,ref=${{ env.GITHUB_PLAYGROUND_IMAGE_NAME }}:cache
162161

162+
trivy-scan-api:
163+
name: Trivy scan — API
164+
needs: build-opengatellm-api
165+
uses: ./.github/workflows/trivy-scan.yml
166+
with:
167+
image-name: ghcr.io/etalab-ia/opengatellm/api
168+
image-tag: ${{ github.event_name == 'release' && github.event.release.tag_name || 'latest' }}
169+
170+
trivy-scan-playground:
171+
name: Trivy scan — Playground
172+
needs: build-opengatellm-playground
173+
uses: ./.github/workflows/trivy-scan.yml
174+
with:
175+
image-name: ghcr.io/etalab-ia/opengatellm/playground
176+
image-tag: ${{ github.event_name == 'release' && github.event.release.tag_name || 'latest' }}
177+
178+
trivy-scan-worker:
179+
name: Trivy scan — Worker
180+
needs: build-opengatellm-worker
181+
uses: ./.github/workflows/trivy-scan.yml
182+
with:
183+
image-name: ghcr.io/etalab-ia/opengatellm/worker
184+
image-tag: ${{ github.event_name == 'release' && github.event.release.tag_name || 'latest' }}
185+
163186
deploy-dev:
164187
if: github.event_name == 'push' # Only deploy on push to main
165188
name: Deploy from ${{ github.ref_name }}/${{ github.sha }}
166189
runs-on: ubuntu-latest
167-
needs: [build-api, build-opengatellm-playground, build-albert-playground]
190+
needs:
191+
- build-opengatellm-api
192+
- trivy-scan-api
193+
- build-opengatellm-playground
194+
- trivy-scan-playground
195+
- build-albert-playground
168196
steps:
169197
- name: Trigger dev deployment
170198
run: |
171199
RESPONSE="$(curl --request POST \
172200
--form token=${{ secrets.GITLAB_CI_TOKEN }} \
173201
--form ref=main \
174-
--form 'variables[pipeline_name]=${{ github.event.repository.name }} - ${{ needs.build-api.outputs.commit_title }}' \
202+
--form 'variables[pipeline_name]=${{ github.event.repository.name }} - ${{ needs.build-opengatellm-api.outputs.commit_title }}' \
175203
--form 'variables[docker_image_tag]=latest' \
176204
--form 'variables[application_to_deploy]=albert-api' \
177205
--form 'variables[deployment_environment]=dev' \

.github/workflows/semgrep.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ jobs:
3939
--config auto \
4040
--config p/default \
4141
--config p/secrets \
42-
--config p/security-audit
43-
--config .github/semgrep.yaml
44-
--severity WARNING
42+
--config p/security-audit \
43+
--config .github/semgrep-rules.yml \
44+
--severity WARNING \
4545
exit 0 # Never block this job
4646
4747
- name: Run Semgrep (ERROR severity only)
@@ -50,7 +50,7 @@ jobs:
5050
--config auto \
5151
--config p/default \
5252
--config p/secrets \
53-
--config p/security-audit
54-
--config .github/semgrep.yaml
53+
--config p/security-audit \
54+
--config .github/semgrep-rules.yml \
5555
--severity ERROR \
5656
--error

.github/workflows/trivy-scan.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Trivy Scan
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
image-name:
7+
description: "Full image name (ex: ghcr.io/org/repo/api)"
8+
required: true
9+
type: string
10+
image-tag:
11+
description: "Image tag to scan"
12+
required: true
13+
type: string
14+
15+
jobs:
16+
trivy-scan:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
- name: Log in to GitHub Container Registry
23+
uses: docker/login-action@v3
24+
with:
25+
registry: ghcr.io
26+
username: ${{ github.actor }}
27+
password: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Trivy scan (HIGH — warning)
30+
uses: aquasecurity/trivy-action@v0.35.0
31+
with:
32+
image-ref: ${{ inputs.image-name }}:${{ inputs.image-tag }}
33+
format: 'table'
34+
severity: 'HIGH'
35+
exit-code: "0"
36+
37+
# CRITICAL → bloque le pipeline
38+
- name: Trivy scan (CRITICAL — blocking)
39+
uses: aquasecurity/trivy-action@v0.35.0
40+
with:
41+
image-ref: ${{ inputs.image-name }}:${{ inputs.image-tag }}
42+
format: 'table'
43+
severity: 'CRITICAL'
44+
exit-code: "1"

0 commit comments

Comments
 (0)