fix(postgres): honor ignore tags for default port URLs#4968
fix(postgres): honor ignore tags for default port URLs#4968Dawn-Fighter wants to merge 4 commits into
Conversation
|
Fix is correct and well-scoped. The root cause is clear: findUriMatches was normalizing the URI (adding :5432) before returning it, so the raw text used for ignore-tag line matching no longer corresponded to what was in the source file. |
|
Thank you for the review will do and commit again |
|
i have commit again with your comment in mind .. please review and respond @gugacyber |
|
The new TestPostgres_RawVsPrimarySecret test addresses exactly the concern I raised — it explicitly asserts that Raw/RawV2 hold the normalized form while GetPrimarySecretValue() returns the original source text, and the comment in the code explains the design decision clearly. |
|
Thank you .. |
Summary
trufflehog:ignoreon Postgres URLs that omit the explicit port and are normalized to:5432.Tests
go test ./pkg/detectors/postgres ./pkg/enginemake test-communitymake lintgo run ./hack/checksecretparts -fail ./pkg/detectorsmake man && git diff --exit-code docs/man/trufflehog.1Addresses #4962.
Note
Low Risk
Localized detector and test changes; behavior improves ignore/line matching without altering verification or connection logic.
Overview
The Postgres detector now keeps the exact URI substring from the scanned file as the primary secret, while
Raw/RawV2stay in the normalized connection form (including default port:5432). That aligns Postgres with how other detectors use primary secrets so the engine can find the right line and honortrufflehog:ignoreon the text that actually appears in the source.findUriMatchesreturns a smalluriMatchwrapper (parsed params plusrawURI) instead of only parameter maps. Regression tests cover primary vs normalized values and an engine case where ignoring a URL without an explicit port still works after normalization.Reviewed by Cursor Bugbot for commit ddd94fc. Bugbot is set up for automated code reviews on this repo. Configure here.