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

gitleaks ignores default config and doesn't merge configs #876

Closed
adamdecaf opened this issue May 25, 2022 · 22 comments
Closed

gitleaks ignores default config and doesn't merge configs #876

adamdecaf opened this issue May 25, 2022 · 22 comments

Comments

@adamdecaf
Copy link
Contributor

Describe the bug
If I have a config like the following zero secrets are detected. I'm unable to specify a few allow directives.

[allowlist]
paths = ["testdata/malformed_key.pem"]

gitleaks reports no secrets, but there are some. This is likely due to gitleaks thinking --config should replace the default config, but that's not what I want.

gitleaks version: 8.8.5

    ○
    │╲
    │ ○
    ○ ░
    ░    gitleaks 

9:39AM INF scan completed in 4.701718ms
9:39AM INF no leaks found
finished gitleaks check

Expected behavior
It would be nice to have a way to allow a few entries as many projects require dummy keys.

Basic Info (please complete the following information):

  • OS: macOS 12.x
  • Gitleaks Version: 8.8.5

cc @zricethezav

@adamdecaf adamdecaf added the bug Something isn't working label May 25, 2022
@zricethezav zricethezav removed the bug Something isn't working label May 25, 2022
@zricethezav
Copy link
Collaborator

Hi @adamdecaf, this isn't a bug as --config replaces the default config by design. I am considering ways to extend the default config in the future.

@adamdecaf
Copy link
Contributor Author

That would be great. I've got ~100 repositories to manage and while we do template codebases I was hoping to rely on the default config. Having overrides would be a big help to us.

@electriquo
Copy link
Contributor

electriquo commented May 25, 2022

relates to #741, #596

@Dingjie-Daniel-Yang
Copy link

Dingjie-Daniel-Yang commented May 27, 2022

@zricethezav, I am echoing with @adamdecaf. It will be great if there is a separate config to allow users to customize the global allowlists without overwriting the default config.

@zricethezav
Copy link
Collaborator

zricethezav commented Jun 1, 2022

Thanks, I hear you guys. I'm thinking of ways to introduce this. In the meantime if you want this feature expedited consider reaching out to me for a maintenance and support agreement https://gitleaks.io/products.html

Some design restrictions I want to impose:

  • no cli arguments, everything should be defined within the config
  • resource authentication should be kept to a minimum if none at all. I,e. if the base config is pointing to a url, that url should be publicly available without authentication or maybe a bearer token... still undecided on whether or not I want to support authentication
  • no merging, only extending the config

So a config might look something like

title = "repo foo gitleaks config"

[extends]
  url = "https://github.com/zricethezav/gitleaks/config/baseconfig.toml"
  # path = "path/to/base/config.toml" 
  # useDefault = true

Only one url, path, or useDefault should be specified. useDefault would extend the repo config with the default gitleaks config

cc @adamdecaf

@adamdecaf
Copy link
Contributor Author

That would work for us! I can help out on a PR if you're interested.

@zricethezav
Copy link
Collaborator

@adamdecaf certainly, if you're up for it. I probably won't be able to get to this for at least another week or two

@wolfch-elsevier
Copy link

wolfch-elsevier commented Jun 6, 2022

Can you tell us how to access/list the default config so we can create a custom config based on the default?
I briefly combed through the source code and didn't find anything obvious.

@electriquo
Copy link
Contributor

@wolfch-elsevier https://github.com/zricethezav/gitleaks/blob/master/config/gitleaks.toml

@very-doge-wow
Copy link
Contributor

What's the current status on this? I'm undecided wether or not to implement a workaround as long as extending configs is not yet available.

@mazlum
Copy link

mazlum commented Jul 12, 2022

Hello,
Are there any updates?

@zricethezav
Copy link
Collaborator

I have a branch I'm working on locally and still deciding on the design of this. Next month or two probably, or maybe next week. idk

@zricethezav
Copy link
Collaborator

https://github.com/zricethezav/gitleaks/tree/extend-config wip

@zricethezav
Copy link
Collaborator

@adamdecaf @very-doge-wow @foolioo @wolfch-elsevier I just merged #926. Check out the updated https://github.com/zricethezav/gitleaks#configuration section for instructions on how to use this new feature. Feel free to pull down master and try it out before I release it sometime this week with 8.9.0

@very-doge-wow
Copy link
Contributor

@zricethezav Awesome, thanks! Will test it out.

@very-doge-wow
Copy link
Contributor

very-doge-wow commented Jul 25, 2022

@zricethezav Is there a way to extend from a default config which is hosted somewhere else than GitHub? The reason being that I'm running gitleaks inside an isolated CI/CD environment which doesn't have access to GitHub directly, but only to a generic GitHub mirror inside an Artifactory server. Meaning: I would need to be able to use something like this:

[extend]
path = "https://some.artifactory.internal/artifactory/some-repo/gitleaks-config.toml"

@zricethezav
Copy link
Collaborator

@very-doge-wow not at the moment. What I recommend is pulling in https://some.artifactory.internal/artifactory/some-repo/gitleaks-config.toml prior to running gitleaks in your CI/CD and adding includeDefault=true to that config

@very-doge-wow
Copy link
Contributor

@very-doge-wow not at the moment. What I recommend is pulling in https://some.artifactory.internal/artifactory/some-repo/gitleaks-config.toml prior to running gitleaks in your CI/CD and adding includeDefault=true to that config

But won't includeDefault=true try and download the default config from GitHub? Because that's exactly the problem, there's no access to public GitHub repositories. The Artifactory repository is a mirror of GitHub. That's why I wanted to use path instead and simply supply a reference to the remote default config inside Artifactory. Sorry if I didn't explain that clearly 😄

@zricethezav
Copy link
Collaborator

zricethezav commented Jul 25, 2022

But won't includeDefault=true try and download the default config from GitHub?

@very-doge-wow, nope. includeDefault will use what is already baked into the binary

https://github.com/zricethezav/gitleaks/blob/master/config/config.go#L186-L206

https://github.com/zricethezav/gitleaks/blob/master/config/config.go#L13-L14

@very-doge-wow
Copy link
Contributor

Okay perfect. Then that solves my problem! Thanks. 🏅

@maltemorgenstern
Copy link
Contributor

@zricethezav awesome!
We just tested this feature and it is working just as expected/hoped 🥇

Looking forward to upgrading to a new version with this feature included 😄

@zricethezav
Copy link
Collaborator

With the release of https://github.com/zricethezav/gitleaks/releases/tag/v8.9.0 I'm gonna close out this issue. Thanks for being patient and hope you get some value out of the new feature. Feel free to re-open or continue the discussion 👍🏻

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

No branches or pull requests

8 participants