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

Support capturing groups as a rule match value #280

Closed
avishnyakov opened this issue Nov 12, 2019 · 2 comments
Closed

Support capturing groups as a rule match value #280

avishnyakov opened this issue Nov 12, 2019 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@avishnyakov
Copy link

avishnyakov commented Nov 12, 2019

It seems that currently GitLeaks uses GoLang regex.FindString value as an outcome for rule match.

https://github.com/zricethezav/gitleaks/blob/f3360cbf66be167c29aaa55f08cb0c1a5ce4575a/src/utils.go#L119

That works well until we want to extract a very specific value for further processing (eg., classification, entropy calculation, etc)

Let's say we would like to handle all tokens in XML or html forms?

(?i:token)['"].*value\s*=\s*['"](.{5,})['"]{1}[\/ x]

More complex version of this regexp can handle multiple token prefixes, eg:

(?i:token|key|password)['"].*value\s*=\s*['"](.{5,})['"]{1}[\/ x]

And the data:

< name="csrf_token" value="{{ csrf_token() }}" />

Current approach with GitLeaks:
https://regex-golang.appspot.com/assets/html/index.html

Returns match:

token" value="{{ csrf_token() }}"

Not great. We were after "group match".
How can this be supported by GitLeaks?

image

@zricethezav
Copy link
Collaborator

This is something that should be pursued by an additional configuration entry reportGroup

@zricethezav zricethezav self-assigned this Nov 24, 2021
@zricethezav zricethezav added the enhancement New feature or request label Nov 24, 2021
@zricethezav zricethezav added this to To do in Issues to work on Nov 24, 2021
@zricethezav
Copy link
Collaborator

This is accomplished with secretGroup in https://github.com/zricethezav/gitleaks/releases/tag/v8.1.0

@zricethezav zricethezav moved this from To do to Done in Issues to work on Dec 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Development

No branches or pull requests

2 participants