Skip to content

fix(dns): make save.sh encrypt tfstate atomically (#6536) - #8021

Merged
dezren39 merged 1 commit into
mainfrom
queue/14343-6536-dns-save-atomic
Nov 9, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/14343-6536-dns-save-atomic

Conversation

@dezren39

@dezren39 dezren39 commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Fixes #6536. save.sh now encrypts to a temp file in the same directory, verifies it is non-empty and decrypts back to exactly the plaintext state (which also proves lineage, mirroring plan.sh), preserves the existing .enc mode, and atomically renames it over terraform.tfstate.enc. A failed or interrupted sops run leaves the previous .enc byte-identical; the EXIT trap removes the temp file and the .lock exactly as before. Adds infra/dns/test_save_atomic.sh (stub identity-cipher sops; oracle: the previous .enc is the record): failing -e leaves .enc unchanged with non-zero exit and no temp/lock residue, succeeding -e installs the new ciphertext, already-current fast path still skips re-encryption - 9/9 checks pass on the laptop. load.sh assessment (recorded on #6536): its in-place decrypt write is safe-by-reconstruction - the plaintext target is fully re-derivable from the intact .enc, so a truncated plaintext is recovered by re-running load; it is documented rather than changed. Shellcheck reports only pre-existing style findings for save.sh. Queue task 14343, lane code-h.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 9, 2026 09:49
@dezren39
dezren39 merged commit 9a3e7b3 into main Nov 9, 2026
1 of 4 checks passed
@dezren39
dezren39 deleted the queue/14343-6536-dns-save-atomic branch November 9, 2026 10:28
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dns(save.sh): encrypting the tfstate of record is not atomic — a failed sops -e truncates terraform.tfstate.enc to zero bytes

1 participant