detect: skip binary files with --no-git (#810)

This commit is contained in:
Adam Shannon authored and GitHub committed 2022-03-22 14:32:47 -05:00
1 parent ba9e089e35
commit 0cabbf8ca8
3 files changed
+13

No files matched your search

+10
View File
@@ -15,6 +15,7 @@ import (
"github.com/fatih/semgroup"
"github.com/gitleaks/go-gitdiff/gitdiff"
"github.com/h2non/filetype"
"github.com/rs/zerolog/log"
"github.com/spf13/viper"
)
@@ -322,6 +323,15 @@ func (d *Detector) DetectFiles(source string) ([]report.Finding, error) {
if err != nil {
return err
}
mimetype, err := filetype.Match(b)
if err != nil {
return err
}
if mimetype.MIME.Type == "application" {
return nil // skip binary files
}
fragment := Fragment{
Raw: string(b),
FilePath: p,