You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 80aa305
Browse filesBrowse the repository at this point in the historyBrowse files
fix(age): make RotateKeys atomic via backup+restore (closes#159)
Address branch-review blocker: the previous fix for #151 introduced
a data-loss window between os.Remove(talm.key) and the final
WriteFile of the re-encrypted secrets. Any crash in that window
left the operator with an encrypted secrets file paired against
either a missing key (unrecoverable) or a fresh-but-empty key
(which cannot decrypt the still-old ciphertext).
New shape:
Phase 1 — read encrypted file, decrypt with old key, all in mem.
Phase 2 — generate new identity, encrypt new ciphertext, all in mem.
Phase 3 — atomic-rename originals aside as *.rotation-backup.
Phase 4 — write new key + encrypted file via secureperm.WriteFile
(atomic temp-then-rename, mode 0o600). Any failure
here triggers a restore() helper that puts the backups
back and returns an error citing the failure stage.
Phase 5 — remove backups on success.
Refuse to start if leftover backups from a previous interrupted
run are present — the operator must inspect them before another
rotation runs, otherwise the recovery state would be silently
overwritten.
Adjacent fix in the same function: secrets.encrypted.yaml is now
written via secureperm.WriteFile so it lands at mode 0o600 (was
0o644 — pre-existing world-readable, defense-in-depth).
Extracted formatKeyFile() helper so RotateKeys produces the same
canonical age keygen layout as GenerateKey.
New tests in pkg/age/contract_test.go:
- BothFilesMode0600 — both files end up 0o600 after rotation.
- NoLeftoverBackups — successful rotation removes both backup
files, no clutter.
- RefusesOnLeftoverBackup — second rotation refuses with a precise
error pointing at the leftover path; the leftover is preserved
for manual inspection.
Existing ReplacesKeyAndPreservesPlaintext continues to pin the
core invariant (oldPub != newPub AND plaintext round-trips).
Closes#159 in addition to #151.
Also picks up the docstring follow-up on normalizeEndpoint —
adds IPv6 examples to the function comment so the contract is
visible in godoc, not just in the implementation comment.
Signed-off-by: Aleksei Sviridkin <[email protected]>
Copy file name to clipboardExpand all lines: pkg/commands/talosctl_wrapper.go
+13-5Lines changed: 13 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -216,12 +216,20 @@ func init() {
216
216
}
217
217
}
218
218
219
-
// normalizeEndpoint normalizes an endpoint by removing any existing port and protocol, then adding https:// and :6443
219
+
// normalizeEndpoint normalizes an endpoint by removing any existing
220
+
// port and protocol, then adding https:// and :6443. IPv6 literals
221
+
// are bracketed per RFC 3986 §3.2.2 (the assembly uses
222
+
// net.JoinHostPort which auto-bracket-wraps any host that contains
0 commit comments