Skip to content
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

Mask URL credentials in the build log #1238

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

alewmf
Copy link

@alewmf alewmf commented Jan 10, 2025

This PR allows credentials in URLs written to the build log by the Git CLI client to be masked. The JGit client is not affected. The functionality is controlled by a system property, org.jenkinsci.plugins.gitclient.CliGitAPIImpl.maskUrlCredentials, and is disabled by default. When enabled, the first occurrence of a URL with credentials will have the credentials replaced by xxxxx before being written to the build log. URLs that appear in error messages are not masked to aid in pipeline troubleshooting.

For example, a URL of https://foo:[email protected]/git/my-repo.git will be written to the build log as https://[email protected]/git/my-repo.git.

Testing done

Unit tests were added to cover new and modified code, confirmed by the Jacoco report.
The change was manually tested using a pipeline that:

  • has a password parameter, used in the URL for SCM operations
  • retrieves a Jenkinsfile from SCM
  • performs a declarative checkout
  • retrieves a shared library

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@alewmf alewmf requested a review from a team as a code owner January 10, 2025 20:29
@github-actions github-actions bot added documentation Improvements or additions to documentation tests Automated test addition or improvement labels Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation tests Automated test addition or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant