Skip to content

Commit

Permalink
fix: os-packages missing-installed files
Browse files Browse the repository at this point in the history
Signed-off-by: chenk <[email protected]>
  • Loading branch information
chen-keinan committed Jan 2, 2024
1 parent 3f6354f commit 90c579c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pkg/fanal/applier/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,20 @@ func ApplyLayers(layers []types.BlobInfo) types.ArtifactDetail {
nestedMap.SetByString(key, sep, pkgInfo)
continue
}

if existPpkgInfo, ok := value.(types.PackageInfo); ok {
mapPkgs := lo.KeyBy(existPpkgInfo.Packages, func(pkg types.Package) string {
return pkg.ID
})

newPackages := make(types.Packages, 0)
for _, pkg := range pkgInfo.Packages {
if pkg, ok := mapPkgs[pkg.ID]; ok {
pkg.InstalledFiles = append(pkg.InstalledFiles, pkg.InstalledFiles...)
newPackages = append(newPackages, pkg)
continue
lo.ForEach(pkgInfo.Packages, func(pkg types.Package, _ int) {
if mPkg, ok := mapPkgs[pkg.ID]; ok {
pkg.InstalledFiles = lo.Uniq(append(pkg.InstalledFiles, mPkg.InstalledFiles...))
}
newPackages = append(newPackages, pkg)
}
})

nestedMap.SetByString(key, sep, types.PackageInfo{
FilePath: pkgInfo.FilePath,
Packages: newPackages,
Expand Down

0 comments on commit 90c579c

Please sign in to comment.