Skip to content

fix: path traversal prevention auto-failure on windows#1016

Merged
codejedi365 merged 13 commits intomasterfrom
fix/windows-path-traversal-prevention
Sep 1, 2024
Merged

fix: path traversal prevention auto-failure on windows#1016
codejedi365 merged 13 commits intomasterfrom
fix/windows-path-traversal-prevention

Conversation

@codejedi365
Copy link
Copy Markdown
Contributor

@codejedi365 codejedi365 commented Sep 1, 2024

Purpose

Rationale

See #1014, and I did have to adjust the testing to accomidate windows for some weird compatibility bugs that caused tests to fail. (1) GitPython under the hood uses getpass.getuser() which will fail on windows unless the USERNAME variable is set in the environment. (2) The use of NamedTemporaryFile() for testing netrc was not compatible with Windows because it restricts the file to one reader at a time and we were leaving the file open (a second read is allowed on linux). (3) Some expected filepaths were hardcoded strings that represented linux only which were passed through Path() to auto-convert path separators.

Lastly, since the testing on windows takes around 10-15 minutes to complete, it was infeasible to integrate windows testing directly into the matrix testing as part of the PR. Instead, I have it testing the oldest version of python on windows and then matrix testing across all the versions before release. Trying to get the best of both worlds with a little bit of increased rigor.

How did you test?

I ran a bunch of pipelines on the windows platform. Then went through each error of the tests to evaluate why it was failing. Ultimately, I did not add any new tests but I did ensure that all test cases run on both windows and maintained compatibility on linux. This is demonstrated by the pipeline below.

How to Verify

Review the pipeline results below since we test both windows and linux now in the PR pipeline. This can still be replicated if you check out this pr and then run pytest locally.

@codejedi365 codejedi365 merged commit 16e6daa into master Sep 1, 2024
@codejedi365 codejedi365 deleted the fix/windows-path-traversal-prevention branch September 1, 2024 17:23
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.

Getting "Template directory must be inside of the repository directory." error when not specifying template_dir option.

1 participant