mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
clarify default collection value + fix appending conffiles location
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
parent
c56690fc52
commit
0511972dfa
@ -117,7 +117,7 @@ loopNewFiles:
|
||||
}
|
||||
|
||||
func getAdditionalFileListing(resolver source.FileResolver, dbLocation source.Location, p *pkg.Package) ([]pkg.DpkgFileRecord, []source.Location) {
|
||||
// ensure the file list is an empty collection (not nil)
|
||||
// ensure the default value for a collection is never nil since this may be shown as JSON
|
||||
var files = make([]pkg.DpkgFileRecord, 0)
|
||||
var locations []source.Location
|
||||
|
||||
@ -140,7 +140,7 @@ func getAdditionalFileListing(resolver source.FileResolver, dbLocation source.Lo
|
||||
files = append(files, parseDpkgConffileInfo(md5Reader)...)
|
||||
|
||||
// keep a record of the file where this was discovered
|
||||
if md5Location != nil {
|
||||
if conffilesLocation != nil {
|
||||
locations = append(locations, *conffilesLocation)
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,7 +61,10 @@ func parseDpkgStatusEntry(reader *bufio.Reader) (pkg.DpkgMetadata, error) {
|
||||
retErr = err
|
||||
}
|
||||
|
||||
var entry pkg.DpkgMetadata
|
||||
entry := pkg.DpkgMetadata{
|
||||
// ensure the default value for a collection is never nil since this may be shown as JSON
|
||||
Files: make([]pkg.DpkgFileRecord, 0),
|
||||
}
|
||||
err = mapstructure.Decode(dpkgFields, &entry)
|
||||
if err != nil {
|
||||
return pkg.DpkgMetadata{}, err
|
||||
@ -80,11 +83,6 @@ func parseDpkgStatusEntry(reader *bufio.Reader) (pkg.DpkgMetadata, error) {
|
||||
}
|
||||
}
|
||||
|
||||
if entry.Files == nil {
|
||||
// ensure that the collection is always allocated
|
||||
entry.Files = make([]pkg.DpkgFileRecord, 0)
|
||||
}
|
||||
|
||||
return entry, retErr
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user