Repository navigation
Commit ef886b6
committed
fix(age): EncryptSecretsFile and EncryptYAMLFile also write mode 0600
Address review feedback from gemini-code-assist on
pkg/age/age.go:613: the same file (secrets.encrypted.yaml) is
written by three code paths (EncryptSecretsFile, RotateKeys,
EncryptYAMLFile). RotateKeys was switched to secureperm.WriteFile
(mode 0o600) earlier in this PR; the other two still used
os.WriteFile with 0o644, which made the on-disk mode depend on
which code path last touched the file.
Switch both to secureperm.WriteFile so every code path that writes
encrypted secrets material agrees on the same defense-in-depth
permission. Same rationale as the existing 0o600 on talm.key
itself.
Tests pin the mode invariant for all three paths:
- EncryptSecretsFile_Mode0600 (new)
- EncryptYAMLFile_Mode0600 (new)
- RotateKeys_BothFilesMode0600 (existing)
All three skip on Windows because NTFS does not honour Unix
permission bits; secureperm has a Windows-side DACL test that
covers the equivalent contract.
Signed-off-by: Aleksei Sviridkin <[email protected]>1 parent db2236d commit ef886b6
2 files changed
Lines changed: 61 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
230 | | - | |
231 | | - | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
232 | 237 | | |
233 | 238 | | |
234 | 239 | | |
| |||
713 | 718 | | |
714 | 719 | | |
715 | 720 | | |
716 | | - | |
717 | | - | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
718 | 726 | | |
719 | 727 | | |
720 | 728 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
483 | 483 | | |
484 | 484 | | |
485 | 485 | | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
486 | 535 | | |
487 | 536 | | |
488 | 537 | | |
| |||
0 commit comments