Skip to content

internal/driver: create temp files with owner-only permissions - #1048

Open
ubeddulla wants to merge 3 commits into
google:mainfrom
ubeddulla:tempfile-0600-perms
Open

ubeddulla wants to merge 3 commits into
google:mainfrom
ubeddulla:tempfile-0600-perms

Conversation

@ubeddulla

Copy link
Copy Markdown

newTempFile opens temporary files with mode 0666, so with the usual umask they land as 0644 and are readable by other local users. The files hold fetched and converted profile data and the generated report output (svg/pdf) under shared directories like os.TempDir(), so another user on the machine can read a profile that isn't theirs. Open them with 0600 so only the owner has access, as os.CreateTemp does. Added a test that checks the created file has no group or other access.

newTempFile opened files with mode 0666, so after the usual umask they
end up world- or group-readable (0644) in shared directories such as
os.TempDir(). The files hold fetched and converted profile data and the
generated report output, so on a multi-user host another local user can
read them. Open them with 0600 instead, matching os.CreateTemp.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request restricts the permissions of newly created temporary files from 0666 to 0600 to ensure they are only readable and writable by the owner. Additionally, a new unit test has been added to verify these file permissions on non-Windows platforms. There are no review comments, so I have no feedback to provide.

Comment thread internal/driver/tempfile_test.go Outdated
@codecov-commenter

codecov-commenter commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.42%. Comparing base (1facf8f) to head (d4feeb1).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1048   +/-   ##
=======================================
  Coverage   73.42%   73.42%           
=======================================
  Files          46       46           
  Lines        7936     7936           
=======================================
  Hits         5827     5827           
  Misses       2086     2086           
  Partials       23       23           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

3 participants