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

Improvement: PrefixRegex Function #25

Open
ankushgoel27 opened this issue Dec 11, 2024 · 3 comments
Open

Improvement: PrefixRegex Function #25

ankushgoel27 opened this issue Dec 11, 2024 · 3 comments
Labels

Comments

@ankushgoel27
Copy link

currently the prefixregex function matches 40 chars before the occurrence of the token. It would be nice to also match after the presence of the token. I have seen instances where the keyword appeared after the token and not before.

func PrefixRegex(keywords []string) string {
pre := (?i)(?:
middle := strings.Join(keywords, "|")
post := )(?:.|[\n\r]){0,40}
return pre + middle + post
}

@rgmz
Copy link
Owner

rgmz commented Dec 11, 2024

This is something I've wanted to do for a long time. Basic patterns like below are not sufficiently detected with the existing code.

curl -H "Authorization: token abcd...." https://api.github.com

It requires creating a new match group, which is complicated due to trufflesecurity#2746. Hopefully that can be merged now that they've added rudimentary unit tests to most detectors...

@rgmz rgmz added kind/enhancement New feature or request area/detectors labels Dec 11, 2024
@ankushgoel27
Copy link
Author

hopefully if they dont merge, we can have this feature in our fork

@rgmz
Copy link
Owner

rgmz commented Dec 15, 2024

It's doable, however there will be an increased risk of merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants