Repository navigation
Add: verify_running_containers.py -- runtime secret drift audit (#9355) - #9541
Merged
Merged
Conversation
…9355 rotation gap) Closes #9355 partial: render_envs.py --check is a STATIC gate (file-vs-file). A running container still holds the credential it was launched with until the next docker compose restart, so a rotated master.env value can look 'in sync' on disk while the running service still answers with the OLD key. This script closes that blind spot by reading the actual container env via 'docker inspect --format {{json .Config.Env}}' and comparing each centralized auth var (WHISPER_API_KEY/.. -> API_KEY, COMFYUI_*-TOKEN -> same, plus the other renamed pairs) against master.env on the live system. One-shot exit code: 0 if every running container matches master; 1 on DRIFT; NOT_RUNNING / MASTER_MISSING (intentionally non-centralized keys like COMFYUI_BEARER_TOKEN per secrets-hygiene.md) are informational and do NOT trigger exit 1. Secret values are masked (last 4 chars only) in both human and --json modes, consistent with render_envs.py convention. Recipe for #9355 on any worker post-pull: python scripts/secrets/verify_running_containers.py # If DRIFT reported for a service -> docker compose restart that service. 59/59 secrets tests pass (41 existing render_envs + 18 new). Verified live on this machine: whisper-api (post-rotation aligned), tts-api (aligned), comfyui-video (aligned), 6 services NOT_RUNNING (informational), comfyui-qwen COMFYUI_BEARER_TOKEN MASTER_MISSING (per-instance password, by design). Co-Authored-By: Claude-Code <noreply@anthropic.com>
jsboige
added a commit
that referenced
this pull request
Aug 5, 2026
…ing (#9548) Grain: MED/lean — lane myia-ai-01:CoursIA — prev: DEEP/lean #9539 #9536 rewrote ceilLog2 via Nat.log 2 in MacroCell.lean (FR) but left the _en sibling on the old WellFounded recursion — an i18n DRIFT that turned 'Scripts Tests (CPU)' red on main for every PR (seen on #9541/#9543). - Port def ceilLog2 + ceilLog2_spec proof to the EN sibling (byte-identical code, EN docstrings/comments per sibling-pair Pattern A). - lake build Conway.Life.MacroCell_en: SUCCESS (2947 jobs), EXIT=0. - check_i18n_siblings.py --all: 177/179 byte-identical, 0 drift, 0 orphan. Co-authored-by: Claude-Code <noreply@anthropic.com>
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.
Grain: MED/tooling — lane myia-po-2023:CoursIA-2 — prev: MED/tooling #9354
Add: verify_running_containers.py — runtime secret drift audit (post #9355 rotation gap)
Branch :
feature/9355-runtime-secret-drift-auditbased onorigin/main@502b33fd5.See : #9355 (partial — runtime verification side), #9351 (mechanism side, PR #9354 MERGED).
Contexte
render_envs.py --checkest une porte statique : elle comparemaster.envà chaque.envsur disque. C'est nécessaire mais pas suffisant. Un conteneur déjà lancé détient la valeur qu'il avait au moment dedocker compose up; il la garde jusqu'au prochain restart. Donc unmaster.envnouvellement rotaté peut apparaître « in sync » sur disque pendant que le service répond encore avec l'ancienne clé.Cette PR ferme ce trou en lisant l'env réel du conteneur via
docker inspect --format {{json .Config.Env}}et en comparant chaque variable d'auth centralisée (WHISPER_API_KEY→API_KEY,COMFYUI_*_TOKEN→ même nom, plus les autres paires renommées) àmaster.envsur le système vivant.Recette #9355 (chaque worker post-pull)
Diagnostic dérive (règle C.4 — PR review §D.5)
Cause (a) — conception originelle :
--checkne regardait que les fichiers sur disque. La course « rotate master.env → écrire.env→ redéployer conteneur » a 3 étapes, et le--checkn'en couvre que 2. La 3ème (le conteneur tenant l'ancienne valeur jusqu'auup -d) était silencieusement hors-périmètre.Cause (b) — fausse confiance à l'opérateur : un
render_envs.py --checkqui passe incite à croire que tout est aligné ; l'opérateur n'a aucune raison de relancer le conteneur si--checkdit[OK]. Donc la rotation « réussit sur disque, échoue en pratique » pendant une fenêtre non bornée.Verdict :
CAUSE_FIXED(côté script). Le nouveauverify_running_containers.pyrend la 3ème étape visible : tout drift runtime remonte en exit 1 avec le nom du service + la clé qui diverge. Un cron quotidien peut l'invoquer comme garde-fou.Fichiers
scripts/secrets/verify_running_containers.py(272 lignes) — argparse + audit par service, modes humain/JSON, masque 4 derniers chars cohérent avecrender_envs.py.scripts/secrets/tests/test_verify_running_containers.py(243 lignes) — 18 tests :_mask,_read_master_env,_detect_auth_vars,audit_service(5 statuts : OK / DRIFT / NOT_RUNNING / MASTER_MISSING / CONTAINER_MISSING),mainexit codes.Note L948 ★★ + secrets-hygiene.md règle 6 : tous les fixtures de test sont des chaînes explicitement fake (
fixture-whisper-XXXX-1234,hf_fixtureABCDEF1234567890,sk-test-fixture-value). Les vraies valeurs vivent uniquement dans.secrets/master.env(gitignored). Sans cette précaution, GitHub push protection rejette le push comme « Hugging Face User Access Token ».Vérification firsthand
python -m pytest scripts/secrets/tests/→ 59/59 PASS (41 render_envs existants + 18 nouveaux).gh pr list --state all --search "verify_running OR bootstrap-missing"→ 0 PR concurrente sur ce chemin.COURSE_CATALOG.generated.{json,md}byte-identique àmain(touché zéro fichier catalogue).Leçon c.9355-L1 ★★ (NEW)
La rotation de secrets a 3 étapes, pas 2. Le réflexe « master.env + render + --check » oublie la 3ème : le conteneur qui tient la valeur stale jusqu'au
up -d. Sans une vérification runtime dédiée, cette 3ème étape est invisible à l'opérateur et le service répond avec l'ancienne clé sans que rien dans--checkne le signale.Pattern : après un outil de cohérence fichier-à-fichier (
--check), ajouter systématiquement un outil de cohérence runtime (state vivant = conteneurs, kernels, caches d'agent, fichiers mmapés, etc.). Le runtime ne s'aligne pas tout seul sur le disque — la seule porte est « restart the thing that holds the state ».Liens
--bootstrap-missing)fix(secrets,#9351): render_envs.py --bootstrap-missing closes .env blind spot(MERGED 2026-08-05)scripts/secrets/render_envs.pydocstring §MODES — référence les 4 modes.claude/rules/secrets-hygiene.md— règle 6 (no-cell-output-scrubbing) + centralisation master.envdocs/genai/secrets-management.md— discipline rotation (master.env + render + restart)