Skip to content

fix: set 0644 permissions on uploaded asset files#1160

Merged
perber merged 2 commits into
mainfrom
fix/asset-upload-permissions
Jun 14, 2026
Merged

fix: set 0644 permissions on uploaded asset files#1160
perber merged 2 commits into
mainfrom
fix/asset-upload-permissions

Conversation

@perber

@perber perber commented Jun 13, 2026

Copy link
Copy Markdown
Owner

os.CreateTemp defaults to 0600, so uploaded files kept owner-only permissions after the atomic rename. Add a perm parameter to WriteStreamAtomic (mirroring WriteFileAtomic) and call Chmod before writing, so assets and branding files land with world-readable 0644.

Fixes #1158

os.CreateTemp defaults to 0600, so uploaded files kept owner-only
permissions after the atomic rename. Add a perm parameter to
WriteStreamAtomic (mirroring WriteFileAtomic) and call Chmod before
writing, so assets and branding files land with world-readable 0644.

Fixes #1158
Copilot AI review requested due to automatic review settings June 13, 2026 23:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #1158 by ensuring uploaded asset and branding files end up with consistent, world-readable permissions (0644) after being written via an atomic temp-file + rename flow (since os.CreateTemp defaults to 0600).

Changes:

  • Extend shared.WriteStreamAtomic to accept a perm os.FileMode and apply it to the temp file used for atomic writes.
  • Update asset upload and branding upload paths to pass 0o644.
  • Extend WriteStreamAtomic unit test to assert the resulting file permissions.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
internal/core/shared/utils.go Adds a perm parameter to WriteStreamAtomic and applies Chmod to the temp file used for atomic writes.
internal/core/shared/utils_test.go Updates WriteStreamAtomic test to pass 0o644 and assert resulting permissions.
internal/core/assets/assets_service.go Ensures uploaded page assets are written with 0o644.
internal/branding/branding_service.go Ensures uploaded branding logo and favicon are written with 0o644.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/core/shared/utils.go Outdated
Comment thread internal/core/shared/utils_test.go
Move Chmod to after CopyWithLimit+Sync so partial uploads stay at 0600
until fully written. Skip the Mode().Perm() assertion on Windows where
Unix permission bits are not reliably represented.
@perber
perber merged commit 80199c8 into main Jun 14, 2026
9 checks passed
@perber
perber deleted the fix/asset-upload-permissions branch June 14, 2026 00:16
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.

Permissions of assets/* different from the rest

2 participants