-
Notifications
You must be signed in to change notification settings - Fork 5
Security fixes: ZIP symlink traversal, absolute dst paths, SVN rev injection #1095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6184327
Security fixes: ZIP symlink traversal, absolute dst paths, SVN rev in…
claude 9e32972
Security: harden validate_destination, bound ZIP symlink read, tighte…
claude 39a443f
Security: harden root-relative Windows paths, fail-closed ZIP symlink…
claude fe8eae2
Security: fix Windows backslash traversal in symlink checks, rename c…
claude 593d363
Minor formatting changes
ben-edna 6eabd61
Reject rooted Windows targets, not just is_absolute() ones.
ben-edna 96694a8
Harden tests
ben-edna File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| """Unit tests for SvnRepo.export() argument safety.""" | ||
|
|
||
| from unittest.mock import patch | ||
|
|
||
| import pytest | ||
|
|
||
| from dfetch.vcs.svn import SvnRepo | ||
|
|
||
|
|
||
| def test_export_with_revision_passes_correct_args(): | ||
| """export() must produce the exact expected SVN command.""" | ||
| with patch("dfetch.vcs.svn.run_on_cmdline") as mock_run: | ||
| SvnRepo.export("svn://example.com/repo", rev="12345", dst="/tmp/out") | ||
| mock_run.assert_called_once() | ||
| assert mock_run.call_args[0][1] == [ | ||
| "svn", | ||
| "export", | ||
| "--non-interactive", | ||
| "--force", | ||
| "--revision", | ||
| "12345", | ||
| "svn://example.com/repo", | ||
| "/tmp/out", | ||
| ] | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| def test_export_without_revision_omits_revision_args(): | ||
| """export() with no revision must produce the exact expected SVN command.""" | ||
| with patch("dfetch.vcs.svn.run_on_cmdline") as mock_run: | ||
| SvnRepo.export("svn://example.com/repo", dst="/tmp/out") | ||
| mock_run.assert_called_once() | ||
| assert mock_run.call_args[0][1] == [ | ||
| "svn", | ||
| "export", | ||
| "--non-interactive", | ||
| "--force", | ||
| "svn://example.com/repo", | ||
| "/tmp/out", | ||
| ] | ||
|
|
||
|
|
||
| def test_export_rejects_non_digit_revision(): | ||
| """Space-containing or flag-like revision strings must raise ValueError. | ||
|
|
||
| Before the fix, passing rev='--revision 12345' would be split on spaces and | ||
| inject '--revision' and '12345' as separate SVN arguments, allowing option | ||
| injection by any caller that bypasses the digit-only validation in | ||
| svnsubproject.py. The subprocess must never be invoked for an invalid rev. | ||
| """ | ||
| with patch("dfetch.vcs.svn.run_on_cmdline") as mock_run: | ||
| with pytest.raises(ValueError): | ||
| SvnRepo.export("svn://example.com/repo", rev="--revision 12345") | ||
| mock_run.assert_not_called() | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.