fix(enroll): fifth audit hardening — guards, atomic writes, docker check#177
Merged
Conversation
- Guard DISK_FREE_KB with ^[0-9]+$ before integer arithmetic (malformed df output would cause a fatal arithmetic error with no diagnosis) - Guard HARMONIA_PUBKEY non-empty after reading harmonia-signing.pub (parallel to SIGNING_PUBKEY guard added in audit #4) - Guard KATELLO_PASSWORD non-empty after reading katello-admin-password (catches zero-byte write that can occur on a failed gen_password) - Write secrets.yaml atomically: sops output goes to a mktemp in /etc/sourceos/ then mv — avoids empty-file poisoning on sops failure - Write nix-cache-info atomically: cat > .tmp then mv — same pattern - Write enroll.nix atomically: cat > .tmp then mv — broken Nix syntax from a partial write would silently poison the next nixos-rebuild - Verify katello containers actually running after docker compose up -d: compose exits 0 even when containers crash-loop; count via docker ps
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.
Summary
[[ "${DISK_FREE_KB}" =~ ^[0-9]+$ ]]before integer arithmetic — malformeddfoutput on a remounted/tmpfs partition would previously cause a fatal(( ))arithmetic error with no diagnosisharmonia-signing.pub, parallel to the SIGNING_PUBKEY guard added in audit workstation: wire shell spine into install.sh #4katello-admin-password— catches zero-byte file from a failedgen_passwordpipesecrets.yamlis written viamktempin/etc/sourceos/thenmv; previouslysops > ${SECRETS_YAML}would truncate the file before sops ran, leaving an empty ciphertext on failurenix-cache-infowrite:cat > .tmpthenmv— prevents nginx from serving a partial file during the writewrite_enroll_nix: writesenroll.nixvia.tmp+mv— a partial write leaving broken Nix syntax would silently poison the nextnixos-rebuildwith an obscure parse errordocker ps --filter name=katelloaftercompose up -d; compose exits 0 even when containers crash-loop immediately, so the previous code could proceed to a 20-minute Foreman wait with zero containers runningTest plan
bash -n scripts/enroll.sh— no syntax errorsdfreturning"N/A"→ exits with parse error messageharmonia-signing.pubto empty → exits with diagnosiskatello-admin-password→ exits with re-enroll instructionssecrets.yamlunchanged (old ciphertext preserved)compose up -dwith no containers → exits with diagnostic before 20-min wait