mirror of
https://github.com/trufflesecurity/trufflehog.git
synced 2024-11-10 15:14:38 +00:00
Only scan regular files (#87)
* Only scan regular files * Remove IsDirectory func
This commit is contained in:
parent
deabded54b
commit
5ab5c6f9d9
1 changed files with 2 additions and 10 deletions
|
@ -77,15 +77,6 @@ func (s *Source) Init(aCtx context.Context, name string, jobId, sourceId int64,
|
|||
return nil
|
||||
}
|
||||
|
||||
func isDirectory(path string) (bool, error) {
|
||||
fileInfo, err := os.Stat(path)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return fileInfo.IsDir(), err
|
||||
}
|
||||
|
||||
// Chunks emits chunks of bytes over a channel.
|
||||
func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk) error {
|
||||
for i, path := range s.paths {
|
||||
|
@ -105,7 +96,8 @@ func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk) err
|
|||
|
||||
path := filepath.Join(cleanPath, relativePath)
|
||||
|
||||
if ok, _ := isDirectory(path); ok {
|
||||
fileStat, _ := os.Stat(path)
|
||||
if !fileStat.Mode().IsRegular() {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue