Repository navigation
fix(talos): save-secrets.sh encrypts atomically and fails loudly (#6554) - #8000
Conversation
Encrypt to same-directory temp files and rename over secrets.enc only after sops exits 0 with non-empty output, so a failed encryption leaves the previous secrets.enc byte-identical instead of truncating it to zero bytes. set -Eeuo pipefail plus an EXIT trap clean up plaintext-bearing temps (including stale legacy secrets.tmp) without touching the live ciphertext, and a tar/sops failure now exits non-zero so init-talos.sh stops instead of bootstrapping on unsaved secrets.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 42 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Fixes #6554.
Defect (verified at current main):
infra/talos/01b.us/save-secrets.shredirectedsops --encryptstraight intosecrets.enc, so the shell truncated the sole encrypted copy before sops ran; with noset -e, a failed encryption leftsecrets.encat 0 bytes while the script exited 0 (reproduced with a stub sops exiting 1: exit 0, 25 bytes -> 0 bytes, md5-identical script).Fix:
set -Eeuo pipefail(house style) so tar/sops failures exit non-zero andinit-talos.shstops.mktempfiles;mvoversecrets.enconly after sops exits 0 and the temp ciphertext is non-empty.EXITtrap removes plaintext/ciphertext temps (plus stale legacysecrets.tmp) without touching the livesecrets.enc.Probes (stub sops, /tmp):
secrets.encsha256-identical, no leftover temps, stalesecrets.tmpcleaned.secrets.encunchanged.load-secrets.shround-trip of a saved artifact extracts byte-identicalsecrets/.shellcheck --severity=warningclean;shfmt -dclean.Out of scope: #6536 (dns/save.sh counterpart),
load-secrets.shhardening.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.