Compare commits
18
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b519ad2c33 | ||
|
|
61e9135070 | ||
|
|
161b6828e3 | ||
|
|
f68ddc6dc6 | ||
|
|
57285aeb17 | ||
|
|
339bdc2280 | ||
|
|
a5e1e3e206 | ||
|
|
d1a92299ec | ||
|
|
f1c39eaae2 | ||
|
|
a52b4baddc | ||
|
|
dc9fd58f66 | ||
|
|
65a6c50fec | ||
|
|
e6d2eee9ea | ||
|
|
24e08fca4f | ||
|
|
ac1b35b1d9 | ||
|
|
24afa9a8e8 | ||
|
|
2ee7decbfd | ||
|
|
e38a3df248 |
No files matched your search
@@ -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 }}"
|
||||||
@@ -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)"
|
||||||
Executable
+81
@@ -0,0 +1,81 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
RED='\033[0;31m'
|
||||||
|
NC='\033[0m'
|
||||||
|
|
||||||
|
detected=false
|
||||||
|
|
||||||
|
check_file() {
|
||||||
|
while IFS=: read -r file score; do
|
||||||
|
[ -z "$file" ] && continue
|
||||||
|
detected=true
|
||||||
|
done <<EOF
|
||||||
|
$(git diff --cached --name-only | while read -r f; do
|
||||||
|
[ ! -f "$f" ] && continue
|
||||||
|
case "$f" in
|
||||||
|
.env|.env.*)
|
||||||
|
[ "$f" = ".env.example" ] && continue
|
||||||
|
echo "$f|1"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
case "$(basename "$f")" in
|
||||||
|
.env|.env.*)
|
||||||
|
[ "$f" = ".env.example" ] && continue
|
||||||
|
echo "$f|1"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done)
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
check_diff() {
|
||||||
|
content=$(git diff --cached --diff-filter=ACM -- "$@" 2>/dev/null)
|
||||||
|
[ -z "$content" ] && return
|
||||||
|
|
||||||
|
patterns='VITE_SUPABASE_SERVICE_ROLE_KEY|SUPABASE_SERVICE_ROLE|eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9|ghp_[0-9a-zA-Z]{36}|gho_[0-9a-zA-Z]{36}|sk_live_|sk_test_|AKIA[0-9A-Z]{16}|-----BEGIN[ A-Z]*PRIVATE KEY-----'
|
||||||
|
|
||||||
|
echo "$content" | while read -r line; do
|
||||||
|
case "$line" in
|
||||||
|
*VITE_SUPABASE_SERVICE_ROLE_KEY*)
|
||||||
|
printf "${RED}⛔ Secret détecté : VITE_SUPABASE_SERVICE_ROLE_KEY (clé admin Supabase)${NC}\n"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
*eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9*)
|
||||||
|
printf "${RED}⛔ Secret détecté : JWT token (eyJ...) dans le diff${NC}\n"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
*ghp_*|*gho_*)
|
||||||
|
printf "${RED}⛔ Secret détecté : GitHub token (ghp_/gho_)${NC}\n"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
*sk_live_*|*sk_test_*)
|
||||||
|
printf "${RED}⛔ Secret détecté : clé Stripe${NC}\n"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
*AKIA[0-9A-Z]*)
|
||||||
|
printf "${RED}⛔ Secret détecté : clé AWS (AKIA)${NC}\n"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
*-----BEGIN*PRIVATE*KEY*-----*)
|
||||||
|
printf "${RED}⛔ Secret détecté : clé privée RSA/EC${NC}\n"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
check_file
|
||||||
|
|
||||||
|
for f in $(git diff --cached --name-only); do
|
||||||
|
case "$f" in .githooks/*) continue ;; esac
|
||||||
|
check_diff "$f"
|
||||||
|
[ $? -eq 1 ] && detected=true
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$detected" = true ]; then
|
||||||
|
printf "${RED}⛔ Commit bloqué : secret(s) détecté(s) dans les fichiers indexés.${NC}\n"
|
||||||
|
printf " Vérifie le contenu et utilise 'git rm --cached' si nécessaire.\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
Reference in new issue
Block a user