Skip to content

feat(repo): add --git-username and --git-password flags - #11671

Open
cvas22 wants to merge 1 commit into
aquasecurity:mainfrom
cvas22:feat/git-credentials-6833
Open

cvas22 wants to merge 1 commit into
aquasecurity:mainfrom
cvas22:feat/git-credentials-6833

Conversation

@cvas22

@cvas22 cvas22 commented Nov 18, 2026

Copy link
Copy Markdown

Description

Right now trivy repo can only authenticate with GITHUB_TOKEN / GITLAB_TOKEN, so private repos on Bitbucket, Gitea, GHE or a self-hosted server need creds baked into the URL. I added --git-username and --git-password (config: repository.username / repository.password, env: TRIVY_GIT_USERNAME / TRIVY_GIT_PASSWORD). They're used as basic auth for the clone and win over the token env vars. If only the password is set it falls back to the same placeholder username Trivy already sends with GITHUB_TOKEN, so plain access tokens work.

Before:

$ trivy repo https://bitbucket.org/acme/private-repo
... repository clone error: git clone error: authentication required

After:

$ export TRIVY_GIT_USERNAME=me TRIVY_GIT_PASSWORD=<app password>
$ trivy repo https://bitbucket.org/acme/private-repo
... scans as usual

Related issues

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

Notes

This picks up where #11043 left off after it went stale. I used the git- prefix since --username / --password already belong to the registry flags on this command. Setting a username without a password just logs a warning and is ignored. Happy to rename things if you'd prefer something else.

@CLAassistant

CLAassistant commented Nov 18, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Lets people scan private repos on Bitbucket, Gitea, GHE or self-hosted
git servers without putting credentials in the URL.
@cvas22
cvas22 force-pushed the feat/git-credentials-6833 branch from cd07c46 to e67908f Compare November 27, 2026 04:47

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add flag to pass credentials to different Git hosting platforms

2 participants