Skip to content

Uses tmp library to ensure more secure tmp file creation#91

Merged
sgoedecke merged 4 commits intoactions:mainfrom
JessRudder:secure-tmp-files
Aug 13, 2025
Merged

Uses tmp library to ensure more secure tmp file creation#91
sgoedecke merged 4 commits intoactions:mainfrom
JessRudder:secure-tmp-files

Conversation

@JessRudder
Copy link
Contributor

@JessRudder JessRudder commented Aug 12, 2025

Currently this action creates temporary files using os.tmpdir() with predictable filenames which results in files that could be readable by other system users.

This PR replaces manual temporary file creation with the tmp library which automatically implements the following security best practices:

Automatic restrictive file permissions (0600 on Unix systems)
Secure temporary directory selection
Random filename generation

This change eliminates the information exposure risk while maintaining the same functionality.

Note: The tmp library uses an MIT license. Not sure what to do to get the license check to pass.

Copilot AI review requested due to automatic review settings August 12, 2025 20:57
@JessRudder JessRudder requested a review from a team as a code owner August 12, 2025 20:57
Copy link
Contributor

Copilot AI left a comment

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 enhances the security of temporary file creation by replacing manual temporary file handling with the tmp library. The change addresses a security vulnerability where temporary files were created with predictable filenames and potentially unsafe permissions.

  • Replaces manual temporary file creation using os.tmpdir() with the secure tmp library
  • Removes the hardcoded filename constant and helper function for temporary directory handling
  • Updates test expectations to match the new random filename pattern

Reviewed Changes

Copilot reviewed 3 out of 6 changed files in this pull request and generated 1 comment.

File Description
src/main.ts Replaces manual temp file creation with secure tmp.fileSync() call and removes helper function
package.json Adds tmp library and its TypeScript definitions as dependencies
tests/main.test.ts Updates test expectation to match new random filename pattern

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@sgoedecke
Copy link
Contributor

@JessRudder Try running licensed cache, that should pull in the new license.

@sgoedecke sgoedecke merged commit f347eae into actions:main Aug 13, 2025
6 checks passed
@JessRudder JessRudder deleted the secure-tmp-files branch August 14, 2025 13:57
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