harden-dockerfile
Skill0 starsChanged 56 days agoMITView on GitHub
Durcir un Dockerfile selon les 4 principes (minimal, non-root, pinned, scanned), avec preuve Trivy avant/après et vérification que l'application tourne toujours. À utiliser quand l'utilisateur demande de sécuriser une image, corriger des CVE d'image, ou avant de publier une image sur un registry.
- Reads credentials
In this repository5 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- dependency-checkSkill
- incident-reportSkill
- security-reviewSkill
- threat-modelSkill
The file
Files
/harden-dockerfile — Durcir une image
Étapes
- Baseline :
docker build -t app:before .puistrivy image --severity HIGH,CRITICAL app:before | tee docs/security/trivy-before.txt;docker run --rm app:before whoami;docker history app:before(repérerCOPY . ., secrets, couches inutiles). Noter taille (docker images app:before). - Diagnostic contre les 4 principes :
- Minimal : base
-slim/alpine/distroless adaptée ; pas d'outils de build dans l'image finale (multi-stage). - Non-root :
USERavec UID fixe ≥ 10000 ; fichiers--chown. - Pinned : tag précis (ou digest) pour la base, versions épinglées des dépendances, pas de
latest. - Scanned : Trivy en CI avec
exit-code: 1sur CRITICAL. Plus :.dockerignore(.git,.env, tests, docs,*.db), pas de secret enARG/ENV,--no-cache-dir,HEALTHCHECKsi pertinent.
- Minimal : base
- Appliquer les corrections (déléguer à
pipeline-hardenersi le changement est large), avec un commentaire par choix non évident. - Prouver :
docker build -t app:after .;trivy image --severity HIGH,CRITICAL app:after | tee docs/security/trivy-after.txt;docker run --rm app:after whoami(≠ root) ; démarrer l'app et appeler son endpoint de santé ; si possibledocker run --read-only --cap-drop ALLet vérifier qu'elle répond. - Résumer : tableau avant/après (taille, nb CRITICAL/HIGH, utilisateur), CVE restantes sans correctif upstream (à accepter explicitement), et rappel d'ajouter/garder le job
image-scanbloquant en CI.
Interdits
Ne pas ignorer une CVE via un fichier d'exclusion sans justification écrite. Ne pas casser l'application pour faire baisser le score : chaque durcissement est vérifié par un démarrage réel.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

