fix(postgres): honor ignore tags for default port URLs#4968
fix(postgres): honor ignore tags for default port URLs#4968Dawn-Fighter wants to merge 3 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
Medium Risk
Changes how the Postgres detector populates the result’s primary secret value so engine ignore-tag/line-offset matching uses the exact source text; this could affect matching behavior for Postgres URI findings but is narrowly scoped and covered by new tests.
Overview
Fixes Postgres URI findings where
trufflehog:ignorecould fail when the detector normalizes URLs by adding the default:5432port.The Postgres detector now preserves the original matched URI as
Result’s primary secret value (while keepingRaw/RawV2normalized), and URI parsing returns both the extracted params and the raw URI. Adds regression tests inpostgres_test.goandengine_test.goto ensure ignore tags work for port-omitted Postgres URLs.Reviewed by Cursor Bugbot for commit 40fcaa5. Bugbot is set up for automated code reviews on this repo. Configure here.