fix: restrict permissions before writing pulled secrets

FE
2mo ago
+47-3

insta secrets pull writes branch credentials into files readable by other local users under a normal umask, including when overwriting an existing output file.

Create new output with mode 0600. For an existing output, intersect its permissions with owner read/write on the opened file descriptor before truncating or writing credentials. This retains stricter modes and existing symlink/inode behavior while keeping permission changes and writes on the same file.

Closes #240 (also covers the permission defect consolidated from #273).

Validation: reproduced new/existing/symlink output at 0644 before the fix; typecheck and 1,999 tests across 101 files pass. Independent review mutation checks catch missing chmod, widened existing permissions, and missing truncation. Repository has no separate lint/formatter command; diff whitespace and existing TypeScript style checked. Linux and Windows CI required before merge; POSIX mode semantics do not represent Windows ACL enforcement.

First push: 2 files, +47/-3. No command or flag changes.


Summary by cubic

Fixes insta secrets pull so pulled secrets are no longer written readable by other local users under a normal umask.

  • New output files are created with mode 0600; existing files retain stricter modes by intersecting permissions with owner read/write on the opened descriptor before truncating and writing.
  • Preserves existing symlink/inode behavior and adds tests for new, existing, write-only, and symlink output files. Closes #240 (also covers the permission defect consolidated from #273).