diff --git a/pkg/parallel/walk.go b/pkg/parallel/walk.go index 3759c7459eba..e1bd8796a76c 100644 --- a/pkg/parallel/walk.go +++ b/pkg/parallel/walk.go @@ -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) @@ -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():