-
-
Notifications
You must be signed in to change notification settings - Fork 935
Replace password in URI by stars if present to avoid leaking secrets in logs #1198
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
Byron
merged 8 commits into
gitpython-developers:master
from
RyaxTech:replace-password-in-uri-by-stars
Mar 19, 2021
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3a4fc6a
Replace password in URI by stars if present + test
mickours 1d43a75
Use format instead of f-string
mickours b650c4f
Better assert message
mickours f7180d5
Use urllib instead of custom parsing
mickours f7968d1
Put remove password in the utils and use it also in cmd.execute
mickours 50cbafc
Add more test and remove password also from error logs
mickours ffddedf
Use copy and not inplace remove password + working case test
mickours d283c83
Use continue instead of raising error
mickours 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -238,6 +238,21 @@ def test_clone_from_with_path_contains_unicode(self): | |
except UnicodeEncodeError: | ||
self.fail('Raised UnicodeEncodeError') | ||
|
||
@with_rw_directory | ||
def test_leaking_password_in_clone_logs(self, rw_dir): | ||
password = "fakepassword1234" | ||
try: | ||
Repo.clone_from( | ||
url="https://fakeuser:{}@fakerepo.example.com/testrepo".format( | ||
password), | ||
to_path=rw_dir) | ||
except GitCommandError as err: | ||
assert password not in str(err), "The error message '%s' should not contain the password" % err | ||
# Working example from a blank private project | ||
Repo.clone_from( | ||
url="https://gitlab+deploy-token-392045:[email protected]/mercierm/test_git_python", | ||
to_path=rw_dir) | ||
|
||
@with_rw_repo('HEAD') | ||
def test_max_chunk_size(self, repo): | ||
class TestOutputStream(TestBase): | ||
|
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a danger as it breaks the self-isolation even more (after all, GitPythons test rely on its own repository already), but I think it's OK to go with it and fix it when it breaks.
Maybe it never does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree! I simply did not find another way to test the working use case. Maybe we can use a deploy token with the GitPython repository on Github but I think it is not available for public repo. Maybe you can create a private repo inside the
gitpython-developers
account in order to keep the responsibility in the same place?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about that too and will do that when it breaks. It's certainly the lazy way of doing things and it's basically a mine that is primed to blow sometime in the future, but… it's going to be okay ;).
While writing this I thought to myself that I don't want to be that lazy and took a look at the github ways of doing this. It turns out it only supports repository deploy keys, which indeed are full blown ssh keys that I don't want to deal with right now. This makes your account one of the pillars of the happiness of GitPython's CI, something not everyone can say about themselves :D.