feat: identify slow file (#1479)

This commit is contained in:
Richard Gomez authored and GitHub committed 2025-05-01 07:39:13 -05:00
1 parent 9609928c02
commit 88f56d3695
3 files changed
+25

No files matched your search

+11
View File
@@ -8,6 +8,7 @@ import (
"os/exec"
"regexp"
"strings"
"time"
"github.com/gitleaks/go-gitdiff/gitdiff"
@@ -63,9 +64,19 @@ func (d *Detector) DetectGit(cmd *sources.GitCmd, remote *RemoteInfo) ([]report.
FilePath: gitdiffFile.NewName,
}
timer := time.AfterFunc(SlowWarningThreshold, func() {
logging.Debug().
Str("commit", commitSHA[:7]).
Str("path", fragment.FilePath).
Msgf("Taking longer than %s to inspect fragment", SlowWarningThreshold.String())
})
for _, finding := range d.Detect(fragment) {
d.AddFinding(augmentGitFinding(remote, finding, textFragment, gitdiffFile))
}
if timer != nil {
timer.Stop()
timer = nil
}
}
return nil
})