Skip to content

Commit

Permalink
fix: Do not remove trailing zeroes from MD5 checksums (#45)
Browse files Browse the repository at this point in the history
Signed-off-by: Erick Redwine <eredwine@gmail.com>
  • Loading branch information
eredwine authored Oct 8, 2023
1 parent bd1c2e6 commit ac49267
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pkg/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func getNEVRA(indexEntries []indexEntry) (*PackageInfo, error) {
pkgInfo.InstallTime = installTime
case RPMTAG_SIGMD5:
// It is just string that we need to encode to hex
digest := bytes.TrimRight(ie.Data, "\x00")
digest := ie.Data
pkgInfo.SigMD5 = hex.EncodeToString(digest)
case RPMTAG_PGP:
type pgpSig struct {
Expand Down
50 changes: 50 additions & 0 deletions pkg/rpmdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,56 @@ func TestRpmDB_Package(t *testing.T) {
wantInstalledFiles: Mariner2CurlInstalledFiles,
wantInstalledFileNames: Mariner2CurlInstalledFileNames,
},
{
name: "libuuid",
pkgName: "libuuid",
file: "testdata/libuuid/Packages",
want: &PackageInfo{
Name: "libuuid",
Version: "2.32.1",
Release: "42.el8_8",
Arch: "x86_64",
Size: 35104,
SourceRpm: "util-linux-2.32.1-42.el8_8.src.rpm",
License: "BSD",
Vendor: "Red Hat, Inc.",
Summary: "Universally unique ID library",
SigMD5: "c1e561f13d39aee443a1f00258fba000",
DigestAlgorithm: PGPHASHALGO_SHA256,
PGP: "RSA/SHA256, Mon Apr 3 18:10:39 2023, Key ID 199e2f91fd431d51",
InstallTime: 1696444673,
Provides: []string{
"libuuid",
"libuuid(x86-64)",
"libuuid.so.1()(64bit)",
"libuuid.so.1(UUIDD_PRIVATE)(64bit)",
"libuuid.so.1(UUID_1.0)(64bit)",
"libuuid.so.1(UUID_2.20)(64bit)",
"libuuid.so.1(UUID_2.31)(64bit)",
},
Requires: []string{
"/sbin/ldconfig",
"/sbin/ldconfig",
"ld-linux-x86-64.so.2()(64bit)",
"ld-linux-x86-64.so.2(GLIBC_2.3)(64bit)",
"libc.so.6()(64bit)",
"libc.so.6(GLIBC_2.14)(64bit)",
"libc.so.6(GLIBC_2.2.5)(64bit)",
"libc.so.6(GLIBC_2.25)(64bit)",
"libc.so.6(GLIBC_2.28)(64bit)",
"libc.so.6(GLIBC_2.3)(64bit)",
"libc.so.6(GLIBC_2.3.4)(64bit)",
"libc.so.6(GLIBC_2.4)(64bit)",
"rpmlib(CompressedFileNames)",
"rpmlib(FileDigests)",
"rpmlib(PayloadFilesHavePrefix)",
"rpmlib(PayloadIsXz)",
"rtld(GNU_HASH)",
},
},
wantInstalledFiles: LibuuidInstalledFiles,
wantInstalledFileNames: LibuuidInstalledFileNames,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
Loading

0 comments on commit ac49267

Please sign in to comment.