From ed65b65095eb699c614aa5ac058f6724539fb03f Mon Sep 17 00:00:00 2001 From: bplaxco Date: Fri, 24 Oct 2025 13:30:33 -0400 Subject: [PATCH] Add trace log for skipped archive file when not enabled (#1961) rh-pre-commit.version: 2.3.2 rh-pre-commit.check-secrets: ENABLED --- sources/file.go | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/sources/file.go b/sources/file.go index 3b1d7a92..42865287 100644 --- a/sources/file.go +++ b/sources/file.go @@ -12,6 +12,7 @@ import ( "github.com/h2non/filetype" "github.com/mholt/archives" + "github.com/rs/zerolog" "github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/logging" @@ -56,14 +57,21 @@ func (s *File) Fragments(ctx context.Context, yield FragmentsFunc) error { // decide what to do with it. if err == nil && format != nil { if s.archiveDepth+1 > s.MaxArchiveDepth { - // Only warn when the feature is enabled + var event *zerolog.Event + + // Warn if the feature is enabled; else emit a trace log. if s.MaxArchiveDepth != 0 { - logging.Warn().Str( - "path", s.FullPath(), - ).Int( - "max_archive_depth", s.MaxArchiveDepth, - ).Msg("skipping archive: exceeds max archive depth") + event = logging.Warn() + } else { + event = logging.Trace() } + + event.Str( + "path", s.FullPath(), + ).Int( + "max_archive_depth", s.MaxArchiveDepth, + ).Msg("skipping archive: exceeds max archive depth") + return nil } if extractor, ok := format.(archives.Extractor); ok {