chore: log skipped symlinks (#1591)

This commit is contained in:
Richard Gomez authored and GitHub committed 2024-10-22 08:23:10 -05:00
1 parent d03d6c401b
commit 5407c44e0c
2 files changed
+16 -9

No files matched your search

+9 -7
View File
@@ -13,10 +13,10 @@ import (
func (d *Detector) DetectFiles(paths <-chan sources.ScanTarget) ([]report.Finding, error) {
for pa := range paths {
p := pa
d.Sema.Go(func() error {
f, err := os.Open(p.Path)
logger := log.With().Str("path", pa.Path).Logger()
log.Trace().Msgf("Scanning path: %s", pa)
f, err := os.Open(pa.Path)
if err != nil {
return err
}
@@ -31,7 +31,9 @@ func (d *Detector) DetectFiles(paths <-chan sources.ScanTarget) ([]report.Findin
if d.MaxTargetMegaBytes > 0 {
rawLength := fileSize / 1000000
if rawLength > int64(d.MaxTargetMegaBytes) {
log.Debug().Msgf("skipping file: %s scan due to size: %d", p.Path, rawLength)
logger.Debug().
Int64("size", rawLength).
Msgf("Skipping file: exceeds --max-target-megabytes")
return nil
}
}
@@ -62,10 +64,10 @@ func (d *Detector) DetectFiles(paths <-chan sources.ScanTarget) ([]report.Findin
totalLines += linesInChunk
fragment := Fragment{
Raw: string(buf[:n]),
FilePath: p.Path,
FilePath: pa.Path,
}
if p.Symlink != "" {
fragment.SymlinkFile = p.Symlink
if pa.Symlink != "" {
fragment.SymlinkFile = pa.Symlink
}
for _, finding := range d.Detect(fragment) {
// need to add 1 since line counting starts at 1