Pass logging context to Detector.FromData
#2228
Closed
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.
Description:
This PR touches a lot of files, however, the sole change is replacing
import ... "context"
withimport ... "github.com/trufflesecurity/trufflehog/v3/pkg/context"
.Why?
While the logging context is not used in any detectors (as far as I'm aware), it is incredibly useful for local debugging, similar to #2191. Right now it is difficult to figure out what specific chunk triggered a detector, and in many instances logging is just done with
fmt.Printf
which is devoid of any context. Perhaps there is an easier or better way to accomplish this — let me know.An alternative is to change
Detector.FromData
toDetector.FromChunk
(#1517). However, that's a larger change that could be accomplished via less invasive means (#1741).Checklist:
make test-community
)?make lint
this requires golangci-lint)?