-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Fix] Line number issue for custom detector #3997
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
[Fix] Line number issue for custom detector #3997
Conversation
@kashifkhan0771 do we have any examples of what this looks like in the output? Can we write some tests for this? |
Currently, I did not print those secrets in the output. Instead, I stored them in the result and use them to identify the exact line number. I can add some test cases for the custom detector where we use this approach for multi-pattern. |
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.
approving the six lines of this that are owned by the scanning team
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.
Awesome job @kashifkhan0771 ! This looks great.
* main: (121 commits) Fixed Grafana detector (trufflesecurity#4166) Reduce verbosity of chunk trace logging (trufflesecurity#4161) Increase postman logging verbosity (trufflesecurity#4160) Change github file extension log message verbosity (trufflesecurity#4159) docs: fix typos (trufflesecurity#4158) fix(twitch): Update Twitch detector to handle new RawV2 field and adjust test expectations (trufflesecurity#4150) Add a bunch of Postman logging (trufflesecurity#4154) Added DataBricks Analyzer (trufflesecurity#4135) fixed shopify detector line number (trufflesecurity#4149) chore: run setup-go after checkout (trufflesecurity#4143) Add per-chunk detection logging (trufflesecurity#4152) [Feat] Added Dropbox API OAuth2 Token Analyzer (trufflesecurity#4080) Updated Github Source Validate method (trufflesecurity#4144) replace anthropic reference with groq (trufflesecurity#4147) [Fix] Line number issue for custom detector (trufflesecurity#3997) fix(postman): prevent infinite recursion in variable substitution (trufflesecurity#4145) Add metrics to the Postman source (trufflesecurity#4142) [Feat] Implementation of Posthog Analyzer (trufflesecurity#4103) [Feat] Added Mux API Analyzer (trufflesecurity#4128) fixed name of netlify analyzer in cli output (trufflesecurity#4140) ... # Conflicts: # pkg/pb/detectorspb/detectors.pb.go # proto/detectors.proto
Description:
This PR resolves the incorrect line number issue for custom detectors with multiple regex patterns. It introduces a new configuration field that allows selecting one pattern as the primary. Matches from this primary regex will be used to determine the line number.
This is also helpful for detectors that append multiple matches to the RAW field. To specify a primary secret for a detector, simply add:
The engine will then use this primary secret to determine the line number. If a primary secret is not set, the engine will fall back to using the RAW field to locate the line number, as it currently does.
Related Ticket: CSM-864 | OSS-139
Checklist:
make test-community
)?make lint
this requires golangci-lint)?