Skip to content

Commit

Permalink
fix(java): skip empty files for jar post analyzer (#3832)
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyLewen authored Mar 14, 2023
1 parent 3987a67 commit ee51835
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/parallel/walk.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"golang.org/x/xerrors"

dio "github.com/aquasecurity/go-dep-parser/pkg/io"
"github.com/aquasecurity/trivy/pkg/log"
)

type onFile[T any] func(string, fs.FileInfo, dio.ReadSeekerAt) (T, error)
Expand All @@ -28,6 +29,15 @@ func WalkDir[T any](ctx context.Context, fsys fs.FS, root string, slow bool,
return nil
}

// check if file is empty
info, err := d.Info()
if err != nil {
return err
} else if info.Size() == 0 {
log.Logger.Debugf("%s is empty, skip this file", path)
return nil
}

select {
case paths <- path:
case <-ctx.Done():
Expand Down

0 comments on commit ee51835

Please sign in to comment.