feat(repo): add flags to pass credentials to any git hosting platform - #11043
Open
HarshitDhaduk wants to merge 1 commit into
Open
feat(repo): add flags to pass credentials to any git hosting platform#11043HarshitDhaduk wants to merge 1 commit into
HarshitDhaduk wants to merge 1 commit into
Conversation
Scanning a private repository only worked for GitHub and GitLab, through the GITHUB_TOKEN and GITLAB_TOKEN environment variables. Repositories on Bitbucket, GitHub Enterprise, Gitea or a self-hosted server had no way to authenticate other than embedding the credentials in the URL, which leaks them into the process list and shell history. Add --git-username and --git-password to the repository command, also settable as TRIVY_GIT_USERNAME and TRIVY_GIT_PASSWORD. When a password is supplied it takes precedence over the token environment variables. The username falls back to the existing dummy user, so token-based authentication works with --git-password alone.
|
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Scanning a private repository only worked for GitHub and GitLab, through the
GITHUB_TOKENandGITLAB_TOKENenvironment variables. Repositories on Bitbucket, GitHub Enterprise, Gitea or a self-hosted server had no way to authenticate other than embedding credentials in the clone URL, which leaks them into the process list and shell history.This adds
--git-usernameand--git-passwordto therepositorycommand, also settable asTRIVY_GIT_USERNAME/TRIVY_GIT_PASSWORD. Explicit credentials take precedence over the token env vars. The username falls back to the existingfanal-aquasecurity-scandummy user, so token-based authentication works with--git-passwordalone.The flags are
git-prefixed because--username/--passwordalready belong to the registry flag group, which therepositorycommand also includes.Before
There was no flag or environment variable that could authenticate this.
After
or, with an explicit username:
Resolves #6833
Checklist