feat: add host, db and username to ExtraData for database detectors#4849
Open
mariocj89 wants to merge 1 commit intotrufflesecurity:mainfrom
Open
feat: add host, db and username to ExtraData for database detectors#4849mariocj89 wants to merge 1 commit intotrufflesecurity:mainfrom
mariocj89 wants to merge 1 commit intotrufflesecurity:mainfrom
Conversation
|
|
There was a problem hiding this comment.
Pull request overview
This PR enhances database connection string detectors by surfacing parsed connection metadata (host, username, database) via Result.ExtraData, improving downstream triage and identification of detected credentials.
Changes:
- Redis: populate
ExtraDatafrom the parsed Redis URL. - Postgres: add
host,username, anddatabaseintoExtraDatawhile preserving existingsslmode. - MongoDB + JDBC: expose parsed connection fields in
ExtraDataand add focused tests validating the new metadata.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/detectors/redis/redis.go | Adds ExtraData population from parsed Redis URLs via a helper. |
| pkg/detectors/redis/redis_test.go | Adds test coverage asserting host/username in ExtraData. |
| pkg/detectors/postgres/postgres.go | Extends existing ExtraData to include host/username/database alongside sslmode. |
| pkg/detectors/postgres/postgres_test.go | Adds tests validating new Postgres ExtraData fields and preserving sslmode. |
| pkg/detectors/mongodb/mongodb.go | Preserves rotation_guide and adds host/user/database fields into ExtraData. |
| pkg/detectors/mongodb/mongodb_test.go | Adds tests verifying MongoDB ExtraData fields are populated. |
| pkg/detectors/jdbc/jdbc.go | Parses JDBC connection info to populate ExtraData even when verify=false. |
| pkg/detectors/jdbc/jdbc_test.go | Adds tests covering ExtraData extraction and unsupported subprotocol behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f62c47e to
2ee0783
Compare
Populate ExtraData with parsed fields for all database connection string detectors (MongoDB, PostgreSQL, Redis, JDBC). This surfaces useful metadata about detected credentials. The parsing logic already existed in each detector — this change exposes the extracted values in the result's ExtraData map alongside any pre-existing fields (rotation_guide, sslmode, etc.).
2ee0783 to
252be3e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

First time contributing to trufflehog, let me know if I should do anything differently. Thanks for your work ^^.
Fixes #4754 and helps with general triaging and identification for other database connection types :).
Description:
Populate ExtraData with parsed fields for all database connection string detectors (MongoDB, PostgreSQL, Redis, JDBC). This surfaces useful metadata about detected credentials.
The parsing logic already existed in each detector — this change exposes the extracted values in the result's ExtraData map alongside any pre-existing fields (rotation_guide, sslmode, etc.).
Checklist:
make test-community)?make lintthis requires golangci-lint)?Manual test
Example file
Example output
Note
Low Risk
Low risk metadata-only change: adds parsed
host/username/databasefields to detector results and expands unit coverage. Minor behavioral nuance: JDBC now attempts parsing even when not verifying, but verification flow remains effectively the same when parsing fails.Overview
Adds parsed connection metadata to database detector findings by populating
Result.ExtraDatawithhost,username, and (when available)databasefor JDBC, MongoDB, Postgres, and Redis.JDBC now attempts to parse connection info even when
verify=false(to fillExtraData), while still skipping unsupported subprotocols only when verification is requested. Comprehensive new unit tests assertExtraDataextraction across common URI/connection-string formats and ensure existing fields like MongoDBrotation_guideand Postgressslmoderemain present.Written by Cursor Bugbot for commit 252be3e. This will update automatically on new commits. Configure here.