diff --git a/.gitea/workflows/trivy-registry-image.yml b/.gitea/workflows/trivy-registry-image.yml new file mode 100644 index 0000000..105c13a --- /dev/null +++ b/.gitea/workflows/trivy-registry-image.yml @@ -0,0 +1,41 @@ +--- +# Trivy — scan image conteneur publiée sur le registre Gitea (git.ccado.fr) +# Déclencheur : package (type container) publié / lié au dépôt. +# NB Gitea 1.27 : l'événement registry_package ne supporte QUE `published` +# (le type `updated` n'existe pas — cf. modules/actions/workflows.go). +name: trivy-registry-image +on: + registry_package: + types: [published] + workflow_dispatch: + +concurrency: + group: trivy-image-${{ gitea.ref_name }} + cancel-in-progress: true + +jobs: + scan-image: + # Ne scanner que les images conteneur du registre lié à ce dépôt + if: gitea.event.package.type == 'container' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Scan Trivy — image publiée (auth registre via GITEA_TOKEN) + uses: aquasecurity/trivy-action@v0.36.0 + with: + image-ref: git.ccado.fr/${{ gitea.event.package.name }}:${{ gitea.event.package.version }} + format: table + exit-code: 1 # échoue sur HIGH/CRITICAL + severity: HIGH,CRITICAL + ignore-unfixed: true # vulns sans fix dispo = bruit + timeout: 15m + env: + TRIVY_CACHE_DIR: /tmp/.trivy + TRIVY_USERNAME: ${{ github.actor }} + TRIVY_PASSWORD: ${{ secrets.GITEA_TOKEN }} + + - name: Résultat + if: failure() + run: echo "::warning::Vulnérabilités HIGH/CRITICAL détectées sur l'image ${{ gitea.event.package.name }}:${{ gitea.event.package.version }}" \ No newline at end of file diff --git a/.gitea/workflows/trivy-repo-weekly.yml b/.gitea/workflows/trivy-repo-weekly.yml new file mode 100644 index 0000000..f877c08 --- /dev/null +++ b/.gitea/workflows/trivy-repo-weekly.yml @@ -0,0 +1,36 @@ +--- +# Trivy — scan hebdomadaire du dépôt (lockfiles : package-lock.json, go.sum, +# requirements*.txt, Gemfile.lock, ...). Lundi 06:00 + dispatch manuel. +name: trivy-repo-weekly +on: + schedule: + - cron: '0 6 * * 1' # lundi 06:00 Europe/Paris (fuseau runner) + workflow_dispatch: + +concurrency: + group: trivy-repo-weekly + cancel-in-progress: false + +jobs: + scan-fs: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Scan Trivy — lockfiles du dépôt + uses: aquasecurity/trivy-action@v0.36.0 + with: + scan-type: fs + scan-ref: . + format: table + exit-code: 1 # échoue sur HIGH/CRITICAL + severity: HIGH,CRITICAL + ignore-unfixed: true + timeout: 15m + env: + TRIVY_CACHE_DIR: /tmp/.trivy + + - name: Résultat + if: failure() + run: echo "::warning::Vulnérabilités HIGH/CRITICAL dans les dépendances du dépôt (voir logs ci-dessus)" \ No newline at end of file