-
Notifications
You must be signed in to change notification settings - Fork 183
[SCM-1028] Fix clear password logging vulnerability #237
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
Conversation
|
Fixed issue with @see in JavaDoc of GitUtil.java by recent force push. |
...ons/src/main/java/org/apache/maven/scm/provider/git/repository/GitScmProviderRepository.java
Outdated
Show resolved
Hide resolved
...n-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/util/GitUtil.java
Outdated
Show resolved
Hide resolved
|
fixed spotless violations |
- GitUtil.java:
- add method maskPasswordInUrl(String urlWithCredentials)
- implementation taken from AnonymousCommandLine.java
- improve regex pattern to be more precise
- replace wrapped with delimiters ':' and '@' to avoid replacing
the password within probable other places of the URL
to avoid password guessing by using e.g. redundant URL parameters
- AnonymousCommandLine.java:
- move current password masking implementation to GitUtil
- use implementation from GitUtil
- GitScmProviderRepository.java:
- add method getFetchUrlWithMaskedPassword()
- add method getPushUrlWithMaskedPassword()
- toString():
- BREAKING change: provide URL content with masked password
to reduce risk of usage within logs or exceptions
with showing passwords by that
- JGitUtils.java:
- method prepareSession(Git git, GitScmProviderRepository repository):
- log using methods:
- GitScmProviderRepository.getFetchUrlWithMaskedPassword()
- GitScmProviderRepository.getPushUrlWithMaskedPassword()
- GitRemoteInfoCommand.java:
- use GitScmProviderRepository.getFetchUrlWithMaskedPassword()
for exception message
- Update JUnit tests accordingly:
- GitScmProviderRepositoryTest.java
- GitCommandLineUtilsTest.java
|
@michael-o Update according to resolved conversations above. |
...n-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/util/GitUtil.java
Show resolved
Hide resolved
...n-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/util/GitUtil.java
Show resolved
Hide resolved
mhoffrog
left a comment
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.
@michael-o Many thanks for your review! Please find my answers accordingly and let me know if / what should be changed or improved.
...n-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/util/GitUtil.java
Show resolved
Hide resolved
...n-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/util/GitUtil.java
Show resolved
Hide resolved
| public String toString() { | ||
| String output = super.toString(); | ||
| final Matcher passwordMatcher = passwordPattern.matcher(output); | ||
| if (passwordMatcher.find()) { |
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.
@michael-o This is the place where the find() did have been taken from - did not want to touch this.
|
@michael-o Please let me know if there anything missing or is to be improved from my end. |
|
@michael-o - Please take account that PR with status 'closed' will be not reported by release drafter. So we will not have it in release notes. |
|
please look ar draft release notes - https://github.com/apache/maven-scm/releases |
|
|
@slawekjaranowski @michael-o @hboutemy shouldn't we ask INFRA to mark the PR merged instead of closed. maybe instead this should be not sure if supported by INFRA tooling though |
|
but yeah nice release notes generated automatically is important too :P |
@olly-cb If this is not possible or too complicated I could file another PR with the same JIRA reference and description providing a simple change - additionally addressing one of the review comments e.g. fix that "asterisk" phrasing or the regex |
|
I'm trying to understand the issue and where we should look for solution any idea about what is different between the current PR and #151? |
For the past 5+ years I have been rebasing, amending with a ref to the actual PR upstreaming to master. Worked like a charm. |
|
writing down the factual differences:
|
|
any idea from anybody on what magic was adding the "asfgit merged commit" step? |
|
searching for pointers, I see Jena project seems to have clearly documented the PR merge process via GH or via GitBas = https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=75968211#CommitWorkflowforGithubASF-Process(viagitbox.apache.org) |
This is basically what I have been doing: |
And such comment "closes" issues/PRs as requested. If merged "correctly" - there would be no reason to add such comment. With merge being fast-forwarded or squashed or done with merge commit, in GitHub or externally to GitHub - there are many possibilities to be considered. |
Technically not necessary, but for reference helpful. |
|
@michael-o it seems @pzygielo 's explanation is right, and it was the case 4 years ago: see #120 so it does not seem GitBox/GH behaviour changed, BUT we now do care about PR's not seen as merged by GH but only closed... I don't know if it is a limitation known to other projects: for example, Jena does not seem to have seen it and to work on a solution: I don't know by which magic GH PR merge works when it reworks the commit(s) = what GitBox should mimic I suppose |
|
@hboutemy I could reset my PRs branch to commit 8b44e4f of the current master and force push my branch. Maybe GitHub would recognize it on this PR and mark the PR as merged. Please let me know if I should give it a try? (I guess it cannot get worse as it currently is.) Edited 23-May-2025: |
Try yourself and we will see. |
Done - but it does not work this way. |
I can't either. It has been terminally closed. |
|
Did file PR #244 hoping that GH would close it as merged after force pushing it to commit 8b44e4f - but that did not work either. @michael-o It looks that the remaining option to get it listed by the release notes is to manually edit release notes for the next release. |
|
yes, we'll have to update release notes by hand for the current PR: that's life it's for future cases like that that we need to find a good way to avoid that manual overhead |
|
Lessons learned - rules for PR merging:
|
|
Resolve #1254 |




JIRA
SCM-1028 Vulnerability: Clear text password is logged by JGit provider and by gitexe remoteinfo on a ls-remote failure
Changes
GitUtil.java:
AnonymousCommandLine.java:
GitScmProviderRepository.java:
JGitUtils.java:
GitRemoteInfoCommand.java:
Update JUnit tests accordingly:
Test result