[6.16.z] Replace hardcoded temp file path with tempfile in tests/test_config.py - #1320
Merged
ogajduse merged 1 commit intoAug 11, 2025
Conversation
#1316) * Initial plan * Replace hardcoded temp file with tempfile.NamedTemporaryFile Co-authored-by: JacobCallahan <6618303+JacobCallahan@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: JacobCallahan <6618303+JacobCallahan@users.noreply.github.com> (cherry picked from commit 0e97758)
ogajduse
approved these changes
Aug 11, 2025
ogajduse
deleted the
cherry-pick-6.16.z-0e977584beb3625d9322e999354266ef2b59259b
branch
August 11, 2025 11:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherrypick of PR: #1316
This PR addresses a security best practice issue by replacing the hardcoded temporary file path
/tmp/bogus.jsonwith Python's standardtempfilemodule.Changes
import tempfileto the importsFILE_PATH = '/tmp/bogus.json' # noqa: S108withFILE_PATH = tempfile.NamedTemporaryFile(suffix='.json', delete=False).name# noqa: S108comment since the hardcoded temp file issue is now resolvedWhy this change?
The original code used a hardcoded path
/tmp/bogus.jsonwhich violates security best practices (ruff rule S108 - hardcoded-temp-file). While the tests use mocked file operations and don't actually access the filesystem, using proper temporary file generation is the recommended approach.Testing
# noqa: S108suppressionThe change is minimal and safe since all file operations in the tests are mocked with
mock_open, so the actual file path value doesn't affect test behavior.Fixes #982.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.