Skip to content

Commit

Permalink
fix: guard for locations < 1 in alpmdb parse (#1366)
Browse files Browse the repository at this point in the history
  • Loading branch information
spiffcs committed Nov 28, 2022
1 parent b290a44 commit 0cbd0cc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions syft/pkg/cataloger/alpm/parse_alpm_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ func parseAlpmDB(resolver source.FileResolver, env *generic.Environment, reader
if err != nil {
return nil, nil, err
}

pkgFiles, err := parseMtree(r)
if err != nil {
return nil, nil, err
}

// The replace the files found the the pacman database with the files from the mtree These contain more metadata and
// thus more useful.
metadata.Files = pkgFiles
Expand Down Expand Up @@ -106,6 +108,10 @@ func getFileReader(path string, resolver source.FileResolver) (io.Reader, error)
if err != nil {
return nil, err
}

if len(locs) == 0 {
return nil, fmt.Errorf("could not find file: %s", path)
}
// TODO: Should we maybe check if we found the file
dbContentReader, err := resolver.FileContentsByLocation(locs[0])
if err != nil {
Expand Down

0 comments on commit 0cbd0cc

Please sign in to comment.