mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-26 19:30:55 +01:00
Add trace log for skipped archive file when not enabled (#1961)
rh-pre-commit.version: 2.3.2 rh-pre-commit.check-secrets: ENABLED
This commit is contained in:
1 parent
c5ccbb9468
commit
ed65b65095
1 file changed
+14
-6
+14
-6
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user