Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
Log skipped files on debug level (#3383)
Richard Gomez23afcd77ee6d
diff --git a/pkg/engine/engine.go b/pkg/engine/engine.goindex 454330d52..4e0ee318d 100644--- a/pkg/engine/engine.go+++ b/pkg/engine/engine.go@@ -773,7 +773,7 @@ func (e *Engine) scannerWorker(ctx context.Context) {decodeLatency.WithLabelValues(decoder.Type().String(), chunk.SourceName).Observe(float64(decodeTime))if decoded == nil {- ctx.Logger().V(4).Info("decoder not applicable for chunk", "decoder", decoder.Type().String(), "chunk", chunk)+ ctx.Logger().V(5).Info("decoder not applicable for chunk", "decoder", decoder.Type().String(), "chunk", chunk)continue}diff --git a/pkg/handlers/archive.go b/pkg/handlers/archive.goindex d33329f76..f5777fa52 100644--- a/pkg/handlers/archive.go+++ b/pkg/handlers/archive.go@@ -154,10 +154,10 @@ func (h *archiveHandler) extractorHandler(archiveChan chan []byte) func(context."filename", file.Name(),"size", file.Size(),)- lCtx.Logger().V(5).Info("Handling extracted file.")+ lCtx.Logger().V(3).Info("Handling extracted file.")if file.IsDir() || file.LinkTarget != "" {- lCtx.Logger().V(5).Info("skipping directory or symlink")+ lCtx.Logger().V(3).Info("skipping directory or symlink")return nil}@@ -172,13 +172,13 @@ func (h *archiveHandler) extractorHandler(archiveChan chan []byte) func(context.fileSize := file.Size()if int(fileSize) > maxSize {- lCtx.Logger().V(3).Info("skipping file due to size", "size", fileSize)+ lCtx.Logger().V(2).Info("skipping file: size exceeds max allowed", "size", fileSize, "limit", maxSize)h.metrics.incFilesSkipped()return nil}if common.SkipFile(file.Name()) || common.IsBinary(file.Name()) {- lCtx.Logger().V(5).Info("skipping file")+ lCtx.Logger().V(2).Info("skipping file: extension is ignored")h.metrics.incFilesSkipped()return nil}diff --git a/pkg/handlers/default.go b/pkg/handlers/default.goindex 84e58f07b..31ebbf8b4 100644--- a/pkg/handlers/default.go+++ b/pkg/handlers/default.go@@ -76,7 +76,7 @@ func (h *defaultHandler) handleNonArchiveContent(ctx logContext.Context, readermimeExt := reader.mimeExtif common.SkipFile(mimeExt) || common.IsBinary(mimeExt) {- ctx.Logger().V(5).Info("skipping file", "ext", mimeExt)+ ctx.Logger().V(2).Info("skipping file: extension is ignored", "ext", mimeExt)h.metrics.incFilesSkipped()// Make sure we consume the reader to avoid potentially blocking indefinitely._, _ = io.Copy(io.Discard, reader)diff --git a/pkg/sources/docker/docker.go b/pkg/sources/docker/docker.goindex 88cc971a8..473131e0a 100644--- a/pkg/sources/docker/docker.go+++ b/pkg/sources/docker/docker.go@@ -345,7 +345,7 @@ type chunkProcessingInfo struct {func (s *Source) processChunk(ctx context.Context, info chunkProcessingInfo, chunksChan chan *sources.Chunk) error {const filesizeLimitBytes int64 = 50 * 1024 * 1024 // 50MBif info.size > filesizeLimitBytes {- ctx.Logger().V(4).Info("skipping large file", "file", info.name, "size", info.size)+ ctx.Logger().V(2).Info("skipping file: size exceeds max allowed", "file", info.name, "size", info.size, "limit", filesizeLimitBytes)return nil}diff --git a/pkg/sources/github/github.go b/pkg/sources/github/github.goindex 043df01c5..e3e492bba 100644--- a/pkg/sources/github/github.go+++ b/pkg/sources/github/github.go@@ -13,7 +13,6 @@ import ("sync/atomic""time"- "github.com/go-logr/logr""github.com/gobwas/glob""github.com/google/go-github/v63/github""golang.org/x/exp/rand"@@ -726,15 +725,6 @@ func (s *Source) cloneAndScanRepo(ctx context.Context, repoURL string, repoInfo// TODO: Can this be set once or does it need to be set on every iteration? Is |s.scanOptions| set every clone?s.setScanOptions(s.conn.Base, s.conn.Head)- // Repo size is not collected for wikis.- var logger logr.Logger- if !strings.HasSuffix(repoURL, ".wiki.git") && repoInfo.size > 0 {- logger = ctx.Logger().WithValues("repo_size_kb", repoInfo.size)- } else {- logger = ctx.Logger()- }- logger.V(2).Info("scanning repo")-start := time.Now()if err = s.git.ScanRepo(ctx, repo, path, s.scanOptions, reporter); err != nil {return duration, fmt.Errorf("error scanning repo %s: %w", repoURL, err)