Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
Polish logging around git and archives to reduce noise (#4034)
Charlie Gunyonb5e657fca679
diff --git a/pkg/handlers/archive.go b/pkg/handlers/archive.goindex 042629396..6d20d95bb 100644--- a/pkg/handlers/archive.go+++ b/pkg/handlers/archive.go@@ -174,22 +174,21 @@ func (h *archiveHandler) openArchive(// to handle nested archives or to continue processing based on the file's content and depth in the archive structure.func (h *archiveHandler) extractorHandler(dataOrErrChan chan DataOrErr) func(context.Context, archives.FileInfo) error {return func(ctx context.Context, file archives.FileInfo) error {+ if common.IsDone(ctx) {+ return ctx.Err()+ }+lCtx := logContext.WithValues(logContext.AddLogger(ctx),"filename", file.Name(),"size", file.Size(),)- lCtx.Logger().V(3).Info("Handling extracted file.")if file.IsDir() || file.LinkTarget != "" {- lCtx.Logger().V(3).Info("skipping directory or symlink")+ lCtx.Logger().V(4).Info("skipping directory or symlink")return nil}- if common.IsDone(ctx) {- return ctx.Err()- }-depth := 0if ctxDepth, ok := ctx.Value(depthKey).(int); ok {depth = ctxDepth@@ -243,7 +242,7 @@ func (h *archiveHandler) extractorHandler(dataOrErrChan chan DataOrErr) func(conh.metrics.incFilesProcessed()h.metrics.observeFileSize(fileSize)- lCtx.Logger().V(4).Info("Processed file successfully", "filename", file.Name(), "size", file.Size())+ lCtx.Logger().V(4).Info("Opened file successfully", "filename", file.Name(), "size", file.Size())return h.openArchive(lCtx, depth, rdr, dataOrErrChan)}}diff --git a/pkg/sources/git/git.go b/pkg/sources/git/git.goindex b3614cdba..39909f573 100644--- a/pkg/sources/git/git.go+++ b/pkg/sources/git/git.go@@ -1296,9 +1296,11 @@ func HandleBinary()}- ctx.Logger().V(3).Info(- "HandleFile did not consume all stdout data; excess discarded",- "bytes_discarded", n)+ if n > 0 {+ ctx.Logger().V(3).Info(+ "HandleFile did not consume all stdout data; excess discarded",+ "bytes_discarded", n)+ }// Wait for the command to finish and handle any errors.waitErr := cmd.Wait()