You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: syft/pkg/cataloger/rpmdb/parse_rpmdb.go
+28-13Lines changed: 28 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -47,25 +47,27 @@ func parseRpmDB(resolver source.FilePathResolver, dbLocation source.Location, re
47
47
allPkgs:=make([]pkg.Package, 0)
48
48
49
49
for_, entry:=rangepkgList {
50
+
metadata:= pkg.RpmdbMetadata{
51
+
Name: entry.Name,
52
+
Version: entry.Version,
53
+
Epoch: entry.Epoch,
54
+
Arch: entry.Arch,
55
+
Release: entry.Release,
56
+
SourceRpm: entry.SourceRpm,
57
+
Vendor: entry.Vendor,
58
+
License: entry.License,
59
+
Size: entry.Size,
60
+
Files: extractRpmdbFileRecords(resolver, entry),
61
+
}
62
+
50
63
p:= pkg.Package{
51
64
Name: entry.Name,
52
-
Version: fmt.Sprintf("%s-%s", entry.Version, entry.Release), // this is what engine does, instead of fmt.Sprintf("%d:%s-%s.%s", entry.Epoch, entry.Version, entry.Release, entry.Arch)
65
+
Version: toELVersion(metadata),
53
66
Locations: []source.Location{dbLocation},
54
67
FoundBy: catalogerName,
55
68
Type: pkg.RpmPkg,
56
69
MetadataType: pkg.RpmdbMetadataType,
57
-
Metadata: pkg.RpmdbMetadata{
58
-
Name: entry.Name,
59
-
Version: entry.Version,
60
-
Epoch: entry.Epoch,
61
-
Arch: entry.Arch,
62
-
Release: entry.Release,
63
-
SourceRpm: entry.SourceRpm,
64
-
Vendor: entry.Vendor,
65
-
License: entry.License,
66
-
Size: entry.Size,
67
-
Files: extractRpmdbFileRecords(resolver, entry),
68
-
},
70
+
Metadata: metadata,
69
71
}
70
72
71
73
allPkgs=append(allPkgs, p)
@@ -74,6 +76,19 @@ func parseRpmDB(resolver source.FilePathResolver, dbLocation source.Location, re
74
76
returnallPkgs, nil
75
77
}
76
78
79
+
// The RPM naming scheme is [name]-[version]-[release]-[arch], where version is implicitly expands to [epoch]:[version].
80
+
// RPM version comparison depends on comparing at least the version and release fields together as a subset of the
81
+
// naming scheme. This toELVersion function takes a RPM DB package information and converts it into a minimally comparable
82
+
// version string, containing epoch (optional), version, and release information. Epoch is an optional field and can be
83
+
// assumed to be 0 when not provided for comparison purposes, however, if the underlying RPM DB entry does not have
84
+
// an epoch specified it would be slightly disingenuous to display a value of 0.
0 commit comments