fix: restrict downloaded file permissions - #107
Conversation
There was a problem hiding this comment.
Pull request overview
This PR tightens default filesystem permissions for downloaded output artifacts created by the CLI, ensuring newly created files are owner-only readable/writable while preserving existing overwrite behavior and filename-collision handling.
Changes:
- Create explicit output files (when
--outputis a path) with0600permissions instead of0644. - Create server-suggested download filenames (via
Content-Disposition) with0600permissions when the file is newly created. - Expand download-related tests to assert permissions, validate overwrite-mode preservation, and cover traversal/symlink/collision/concurrency scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/cmd/cmdutil.go | Switch new output/download file creation modes from 0644 to 0600 for tighter default permissions. |
| pkg/cmd/cmdutil_test.go | Add/extend tests to verify permission behavior and robustness across overwrite, traversal, symlink, and concurrent download cases. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
HAYDEN-OAI
left a comment
There was a problem hiding this comment.
Independent security review of the exact requested commit: no introduced P1/P2 findings. Verified owner-only file creation, preserved overwrite behavior, collision and traversal protections, stdout, failure paths, and concurrent downloads with direct base-versus-HEAD reproductions.
Summary
Verification
000,022, and077.go test -race ./pkg/cmd -run '^(TestWriteBinaryResponse|TestCreateDownloadFile)$' -count=5./scripts/lint,go vet ./..., and formatting checks.