hide digests for rpm dirs

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
Alex Goodman 2022-04-08 08:57:59 -04:00
parent e415bb21e7
commit 1c2254f5cf
No known key found for this signature in database
GPG Key ID: 5CB45AE22BAB7EA7
2 changed files with 12 additions and 7 deletions

View File

@ -97,14 +97,19 @@ func extractRpmdbFileRecords(resolver source.FilePathResolver, entry *rpmdb.Pack
for _, record := range entry.Files { for _, record := range entry.Files {
// only persist RPMDB file records which exist in the image/directory, otherwise ignore them // only persist RPMDB file records which exist in the image/directory, otherwise ignore them
if resolver.HasPath(record.Path) { if resolver.HasPath(record.Path) {
records = append(records, pkg.RpmdbFileRecord{ var digest *file.Digest
Path: record.Path, if record.Digest != "" {
Mode: pkg.RpmdbFileMode(record.Mode), digest = &file.Digest{
Size: int(record.Size),
Digest: file.Digest{
Value: record.Digest, Value: record.Digest,
Algorithm: entry.DigestAlgorithm.String(), Algorithm: entry.DigestAlgorithm.String(),
}, }
}
records = append(records, pkg.RpmdbFileRecord{
Path: record.Path,
Mode: pkg.RpmdbFileMode(record.Mode),
Size: int(record.Size),
Digest: digest,
UserName: record.Username, UserName: record.Username,
GroupName: record.Groupname, GroupName: record.Groupname,
Flags: record.Flags.String(), Flags: record.Flags.String(),

View File

@ -37,7 +37,7 @@ type RpmdbFileRecord struct {
Path string `json:"path"` Path string `json:"path"`
Mode RpmdbFileMode `json:"mode"` Mode RpmdbFileMode `json:"mode"`
Size int `json:"size"` Size int `json:"size"`
Digest file.Digest `json:"digest"` Digest *file.Digest `json:"digest,omitempty"`
UserName string `json:"userName"` UserName string `json:"userName"`
GroupName string `json:"groupName"` GroupName string `json:"groupName"`
Flags string `json:"flags"` Flags string `json:"flags"`