Hook pre-commit : barriere effective (actionlint + gitleaks)#6
Merged
Conversation
Le hook utilisait `set -uo pipefail` sans `-e` : un echec actionlint ou gitleaks n'interrompait pas le script (il affichait "OK" et sortait en 0). Seul le controle de structure bloquait vraiment. - actionlint : echec -> message rouge + exit 1. - gitleaks : capture du code retour sur les trois branches (detect/protect/ stdin, fallback via process substitution) -> message rouge + exit 1 si secret. - Message du controle de structure remis avec ses accents (texte exact du sujet). Barriere Shift-Left desormais effective sur les trois controles (verifie en local).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problème
Le hook
scripts/pre-commit.shutilisaitset -uo pipefailsans-e. Commeactionlintetgitleaksne reposent que sur leur code de sortie, un échec étaitignoré : le hook affichait « OK » et sortait en
0. Seul le contrôle de structure(
.env/.pem/.key, avecexit 1) bloquait réellement. La barrière Shift-Left exigéepar le sujet (« valider séquentiellement actionlint + gitleaks ») était donc incomplète.
Correctif
if ! …; then message rouge; exit 1; fi.|| gitleaks_status=$?) sur les trois branches(
detect --staged,protect --staged, fallbackstdin), le fallback passe enprocess substitution pour ne pas perdre le code retour dans un sous-shell →
exit 1si un secret est trouvé.
« Sécurité : … Opération annulée. »).
Tests locaux (tous conformes)
exit 0✅.keystagedexit 1+ message accentué ✅SECWALLET_…stagedexit 1✅exit 1✅