#!/usr/bin/env bash # ============================================================================ # guard_constraints.sh · OTO Enterprise OS DTP # ---------------------------------------------------------------------------- # Enforce les contraintes NON-NÉGOCIABLES de CLAUDE.md dans la CI. # Objectif : empêcher qu'un commit introduise un outil/plateforme interdit # ou une pratique proscrite. Gate qualité DevOps (roadmap Sprint 1). # # Principe de robustesse (zéro faux positif sur le texte de politique) : # - On détecte l'USAGE d'un terme interdit, PAS sa simple mention. # - Une ligne qui contient un MARQUEUR DE PROHIBITION (jamais, ❌, only, # pas de, interdit, SEUL...) est un rappel de la règle → on l'ignore. # - Escape hatch explicite : une ligne contenant « ci-allow » est ignorée. # # Sortie : exit 0 si conforme, exit 1 sinon (liste des violations). # Dépendances : bash, git, grep. Aucun réseau requis. # ============================================================================ set -uo pipefail # shellcheck source=ci/lib.sh source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" || exit 3 cd_repo_root # racine du dépôt, ou ROUGE honnête si hors arbre git (cf. lib.sh) # Marqueur de prohibition : si présent sur la ligne, c'est un rappel de règle. PROHIBITION='jamais|JAMAIS|Jamais|❌|SEUL|Seul|only|Only|ONLY|pas de|pas d|\(pas |NON-|non-|[Ii]nterdit|INTERDIT|forbidden|proscrit|éliminer' # ci-allow : échappatoire manuel documenté. ALLOW='ci-allow' FAIL=0 report() { printf ' \033[31m✗\033[0m %s\n' "$1"; FAIL=1; } ok() { printf ' \033[32m✓\033[0m %s\n' "$1"; } # Fichiers suivis (exclut ce script lui-même : il liste les termes interdits). tracked_files() { git ls-files -- . \ ':(exclude)ci/guard_constraints.sh' \ ':(exclude).gitea/workflows/*.yml' } # scan_forbidden