-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Updated custom detector setup docs #3913
base: main
Are you sure you want to change the base?
Updated custom detector setup docs #3913
Conversation
### Go | ||
```go | ||
package main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this only makes the concept of a "verification server" more confusing. The documentation needs to explain what it does and why you need it; examples in different languages doesn't provide clarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The explanation is provided above in verify
section where we link verification server examples. Shall I add more details there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's any benefit in having multiple bare-bones examples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, providing the example in the language TruffleHog is written in is beneficial.
keywords: | ||
- custom | ||
regex: | ||
token: 'token-[a-zA-Z0-9]{16}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example doesn't do a good job of relating keyword
and regex
.
unsafe: true | ||
headers: | ||
- "Authorization: super secret authorization header" | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if we could cover the features demonstrated in the generic_with_filter.yml config: https://github.com/trufflesecurity/trufflehog/blob/main/examples/generic_with_filters.yml
- exclude_regexes_capture
- entropy
- exclude_regexes_match
- exclude_words
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I explained these parameters as per my understanding. If I added a wrong explanation for any of these do let me know.
**Explanation**: | ||
- **`name`**: A unique identifier for your custom detector. | ||
- **`keywords`**: An array of strings that, when found, trigger the regex search. If multiple keywords are specified, the presence of any one of them will initiate the regex search. | ||
- **`regex`**: Defines the patterns to identify potential secrets. You can specify one or more named regular expressions. For a detection to be successful, each named regex must find a match. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should include a sentence or two about how capture groups function here
- **`keywords`**: An array of strings that, when found, trigger the regex search. If multiple keywords are specified, the presence of any one of them will initiate the regex search. | ||
- **`regex`**: Defines the patterns to identify potential secrets. You can specify one or more named regular expressions. For a detection to be successful, each named regex must find a match. | ||
- **`verify`**: An optional section to validate detected secrets. If you want to verify or unverify detected secrets, this section needs to be configured. If not configured, all detected secrets will be marked as unverified. Read [verification server examples](#verification-server-examples) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add explanations of the missing features:
exclude_regexes_capture
entropy
exclude_regexes_match
exclude_words
3f1aa4e
to
a410e76
Compare
keywords: | ||
- hog | ||
regex: | ||
token: '[^A-Za-z0-9+\/]{0,1}([A-Za-z0-9+\/]{40})[^A-Za-z0-9+\/]{0,1}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose to use a single regular expression to keep the example straightforward for beginners learning about custom detectors. Using two regexps makes the basic example complex to understand.
Description:
This PR separate out the custom regex detectors documentation from main README.md to
CUSTOM_DETECTOR.md
incustom_detectors
package with more details. Also add golang verification server example.Checklist:
make test-community
)?make lint
this requires golangci-lint)?