mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 20:54:22 +01:00
detect: skip binary files with --no-git (#810)
This commit is contained in:
1 parent
ba9e089e35
commit
0cabbf8ca8
3 files changed
+13
No files matched your search
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user