// Copyright 2017 clair authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package rpm import ( "testing" "github.com/stretchr/testify/require" "github.com/coreos/clair/database" "github.com/coreos/clair/ext/featurefmt" "github.com/coreos/clair/ext/versionfmt/rpm" ) var expectedBigCaseInfo = []database.Feature{ {"libmount", "2.32.1-1.fc28", "rpm", "binary", database.Namespace{}}, {"libffi", "3.1-16.fc28", "rpm", "binary", database.Namespace{}}, {"libunistring", "0.9.10-1.fc28", "rpm", "binary", database.Namespace{}}, {"fedora-repos", "28-5", "rpm", "binary", database.Namespace{}}, {"libarchive", "3.3.1-4.fc28", "rpm", "source", database.Namespace{}}, {"langpacks", "1.0-12.fc28", "rpm", "source", database.Namespace{}}, {"readline", "7.0-11.fc28", "rpm", "source", database.Namespace{}}, {"gzip", "1.9-3.fc28", "rpm", "source", database.Namespace{}}, {"libverto", "0.3.0-5.fc28", "rpm", "source", database.Namespace{}}, {"ncurses-base", "6.1-5.20180224.fc28", "rpm", "binary", database.Namespace{}}, {"libfdisk", "2.32.1-1.fc28", "rpm", "binary", database.Namespace{}}, {"libselinux", "2.8-1.fc28", "rpm", "source", database.Namespace{}}, {"nss-util", "3.38.0-1.0.fc28", "rpm", "source", database.Namespace{}}, {"mpfr", "3.1.6-1.fc28", "rpm", "source", database.Namespace{}}, {"libunistring", "0.9.10-1.fc28", "rpm", "source", database.Namespace{}}, {"libpcap", "14:1.9.0-1.fc28", "rpm", "binary", database.Namespace{}}, {"libarchive", "3.3.1-4.fc28", "rpm", "binary", database.Namespace{}}, {"gmp", "1:6.1.2-7.fc28", "rpm", "binary", database.Namespace{}}, {"crypto-policies", "20180425-5.git6ad4018.fc28", "rpm", "source", database.Namespace{}}, {"gzip", "1.9-3.fc28", "rpm", "binary", database.Namespace{}}, {"fedora-release", "28-2", "rpm", "source", database.Namespace{}}, {"zlib", "1.2.11-8.fc28", "rpm", "binary", database.Namespace{}}, {"crypto-policies", "20180425-5.git6ad4018.fc28", "rpm", "binary", database.Namespace{}}, {"lz4", "1.8.1.2-4.fc28", "rpm", "source", database.Namespace{}}, {"keyutils", "1.5.10-6.fc28", "rpm", "source", database.Namespace{}}, {"gpgme", "1.10.0-4.fc28", "rpm", "binary", database.Namespace{}}, {"libgpg-error", "1.31-1.fc28", "rpm", "binary", database.Namespace{}}, {"gnutls", "3.6.3-4.fc28", "rpm", "source", database.Namespace{}}, {"coreutils", "8.29-7.fc28", "rpm", "source", database.Namespace{}}, {"libsepol", "2.8-1.fc28", "rpm", "source", database.Namespace{}}, {"libssh", "0.8.2-1.fc28", "rpm", "binary", database.Namespace{}}, {"libpwquality", "1.4.0-7.fc28", "rpm", "binary", database.Namespace{}}, {"dnf-conf", "2.7.5-12.fc28", "rpm", "binary", database.Namespace{}}, {"basesystem", "11-5.fc28", "rpm", "source", database.Namespace{}}, {"setup", "2.11.4-1.fc28", "rpm", "binary", database.Namespace{}}, {"libmetalink", "0.1.3-6.fc28", "rpm", "source", database.Namespace{}}, {"texinfo", "6.5-4.fc28", "rpm", "source", database.Namespace{}}, {"expat", "2.2.5-3.fc28", "rpm", "source", database.Namespace{}}, {"ncurses", "6.1-5.20180224.fc28", "rpm", "source", database.Namespace{}}, {"libpwquality", "1.4.0-7.fc28", "rpm", "source", database.Namespace{}}, {"pcre", "8.42-3.fc28", "rpm", "binary", database.Namespace{}}, {"sssd", "1.16.3-2.fc28", "rpm", "source", database.Namespace{}}, {"basesystem", "11-5.fc28", "rpm", "binary", database.Namespace{}}, {"systemd-pam", "238-9.git0e0aa59.fc28", "rpm", "binary", database.Namespace{}}, {"python3-six", "1.11.0-3.fc28", "rpm", "binary", database.Namespace{}}, {"libcurl", "7.59.0-6.fc28", "rpm", "binary", database.Namespace{}}, {"qrencode", "3.4.4-5.fc28", "rpm", "source", database.Namespace{}}, {"xz", "5.2.4-2.fc28", "rpm", "source", database.Namespace{}}, {"libpkgconf", "1.4.2-1.fc28", "rpm", "binary", database.Namespace{}}, {"libzstd", "1.3.5-1.fc28", "rpm", "binary", database.Namespace{}}, {"bash", "4.4.23-1.fc28", "rpm", "binary", database.Namespace{}}, {"cyrus-sasl", "2.1.27-0.2rc7.fc28", "rpm", "source", database.Namespace{}}, {"ncurses-libs", "6.1-5.20180224.fc28", "rpm", "binary", database.Namespace{}}, {"xz-libs", "5.2.4-2.fc28", "rpm", "binary", database.Namespace{}}, {"dbus", "1.12.10-1.fc28", "rpm", "source", database.Namespace{}}, {"grep", "3.1-5.fc28", "rpm", "binary", database.Namespace{}}, {"libusbx", "1.0.22-1.fc28", "rpm", "binary", database.Namespace{}}, {"audit", "2.8.4-2.fc28", "rpm", "source", database.Namespace{}}, {"sed", "4.5-1.fc28", "rpm", "binary", database.Namespace{}}, {"sqlite", "3.22.0-4.fc28", "rpm", "source", database.Namespace{}}, {"openldap", "2.4.46-3.fc28", "rpm", "binary", database.Namespace{}}, {"gawk", "4.2.1-1.fc28", "rpm", "binary", database.Namespace{}}, {"gpgme", "1.10.0-4.fc28", "rpm", "source", database.Namespace{}}, {"lvm2", "2.02.177-5.fc28", "rpm", "source", database.Namespace{}}, {"nspr", "4.19.0-1.fc28", "rpm", "source", database.Namespace{}}, {"libsolv", "0.6.35-1.fc28", "rpm", "source", database.Namespace{}}, {"info", "6.5-4.fc28", "rpm", "binary", database.Namespace{}}, {"openssl-libs", "1:1.1.0h-3.fc28", "rpm", "binary", database.Namespace{}}, {"libxcrypt", "4.1.2-1.fc28", "rpm", "binary", database.Namespace{}}, {"libselinux", "2.8-1.fc28", "rpm", "binary", database.Namespace{}}, {"libgcc", "8.1.1-5.fc28", "rpm", "binary", database.Namespace{}}, {"cracklib", "2.9.6-13.fc28", "rpm", "binary", database.Namespace{}}, {"python3-libs", "3.6.6-1.fc28", "rpm", "binary", database.Namespace{}}, {"glibc-langpack-en", "2.27-32.fc28", "rpm", "binary", database.Namespace{}}, {"json-c", "0.13.1-2.fc28", "rpm", "binary", database.Namespace{}}, {"gnupg2", "2.2.8-1.fc28", "rpm", "source", database.Namespace{}}, {"openssl", "1:1.1.0h-3.fc28", "rpm", "binary", database.Namespace{}}, {"glibc-common", "2.27-32.fc28", "rpm", "binary", database.Namespace{}}, {"p11-kit-trust", "0.23.12-1.fc28", "rpm", "binary", database.Namespace{}}, {"zstd", "1.3.5-1.fc28", "rpm", "source", database.Namespace{}}, {"libxml2", "2.9.8-4.fc28", "rpm", "source", database.Namespace{}}, {"dbus", "1:1.12.10-1.fc28", "rpm", "binary", database.Namespace{}}, {"ca-certificates", "2018.2.24-1.0.fc28", "rpm", "binary", database.Namespace{}}, {"libcomps", "0.1.8-11.fc28", "rpm", "binary", database.Namespace{}}, {"nss", "3.38.0-1.0.fc28", "rpm", "binary", database.Namespace{}}, {"libcom_err", "1.44.2-0.fc28", "rpm", "binary", database.Namespace{}}, {"keyutils-libs", "1.5.10-6.fc28", "rpm", "binary", database.Namespace{}}, {"libseccomp", "2.3.3-2.fc28", "rpm", "binary", database.Namespace{}}, {"elfutils-libs", "0.173-1.fc28", "rpm", "binary", database.Namespace{}}, {"libuuid", "2.32.1-1.fc28", "rpm", "binary", database.Namespace{}}, {"pkgconf", "1.4.2-1.fc28", "rpm", "source", database.Namespace{}}, {"grep", "3.1-5.fc28", "rpm", "source", database.Namespace{}}, {"libpcap", "1.9.0-1.fc28", "rpm", "source", database.Namespace{}}, {"deltarpm", "3.6-25.fc28", "rpm", "binary", database.Namespace{}}, {"krb5-libs", "1.16.1-13.fc28", "rpm", "binary", database.Namespace{}}, {"glibc", "2.27-32.fc28", "rpm", "binary", database.Namespace{}}, {"libseccomp", "2.3.3-2.fc28", "rpm", "source", database.Namespace{}}, {"libsemanage", "2.8-2.fc28", "rpm", "binary", database.Namespace{}}, {"openssl-pkcs11", "0.4.8-1.fc28", "rpm", "binary", database.Namespace{}}, {"libxml2", "2.9.8-4.fc28", "rpm", "binary", database.Namespace{}}, {"e2fsprogs", "1.44.2-0.fc28", "rpm", "source", database.Namespace{}}, {"file-libs", "5.33-7.fc28", "rpm", "binary", database.Namespace{}}, {"elfutils-default-yama-scope", "0.173-1.fc28", "rpm", "binary", database.Namespace{}}, {"glibc", "2.27-32.fc28", "rpm", "source", database.Namespace{}}, {"publicsuffix-list-dafsa", "20180514-1.fc28", "rpm", "binary", database.Namespace{}}, {"popt", "1.16-14.fc28", "rpm", "binary", database.Namespace{}}, {"libnsl2", "1.2.0-2.20180605git4a062cf.fc28", "rpm", "binary", database.Namespace{}}, {"lua-libs", "5.3.4-10.fc28", "rpm", "binary", database.Namespace{}}, {"libsemanage", "2.8-2.fc28", "rpm", "source", database.Namespace{}}, {"glibc-minimal-langpack", "2.27-32.fc28", "rpm", "binary", database.Namespace{}}, {"attr", "2.4.48-3.fc28", "rpm", "source", database.Namespace{}}, {"gdbm", "1.14.1-4.fc28", "rpm", "source", database.Namespace{}}, {"pkgconf", "1.4.2-1.fc28", "rpm", "binary", database.Namespace{}}, {"acl", "2.2.53-1.fc28", "rpm", "source", database.Namespace{}}, {"gnutls", "3.6.3-4.fc28", "rpm", "binary", database.Namespace{}}, {"fedora-repos", "28-5", "rpm", "source", database.Namespace{}}, {"python3-pip", "9.0.3-2.fc28", "rpm", "binary", database.Namespace{}}, {"libnsl2", "1.2.0-2.20180605git4a062cf.fc28", "rpm", "source", database.Namespace{}}, {"rpm", "4.14.1-9.fc28", "rpm", "binary", database.Namespace{}}, {"libutempter", "1.1.6-14.fc28", "rpm", "source", database.Namespace{}}, {"libdnf", "0.11.1-3.fc28", "rpm", "source", database.Namespace{}}, {"vim-minimal", "2:8.1.328-1.fc28", "rpm", "binary", database.Namespace{}}, {"tzdata", "2018e-1.fc28", "rpm", "binary", database.Namespace{}}, {"nettle", "3.4-2.fc28", "rpm", "binary", database.Namespace{}}, {"python-pip", "9.0.3-2.fc28", "rpm", "source", database.Namespace{}}, {"python-six", "1.11.0-3.fc28", "rpm", "source", database.Namespace{}}, {"diffutils", "3.6-4.fc28", "rpm", "binary", database.Namespace{}}, {"rpm-plugin-selinux", "4.14.1-9.fc28", "rpm", "binary", database.Namespace{}}, {"shadow-utils", "2:4.6-1.fc28", "rpm", "binary", database.Namespace{}}, {"pkgconf-pkg-config", "1.4.2-1.fc28", "rpm", "binary", database.Namespace{}}, {"cracklib-dicts", "2.9.6-13.fc28", "rpm", "binary", database.Namespace{}}, {"libblkid", "2.32.1-1.fc28", "rpm", "binary", database.Namespace{}}, {"python-setuptools", "39.2.0-6.fc28", "rpm", "source", database.Namespace{}}, {"libsss_idmap", "1.16.3-2.fc28", "rpm", "binary", database.Namespace{}}, {"libksba", "1.3.5-7.fc28", "rpm", "source", database.Namespace{}}, {"sssd-client", "1.16.3-2.fc28", "rpm", "binary", database.Namespace{}}, {"curl", "7.59.0-6.fc28", "rpm", "binary", database.Namespace{}}, {"pam", "1.3.1-1.fc28", "rpm", "binary", database.Namespace{}}, {"libsigsegv", "2.11-5.fc28", "rpm", "binary", database.Namespace{}}, {"langpacks-en", "1.0-12.fc28", "rpm", "binary", database.Namespace{}}, {"nss-softokn-freebl", "3.38.0-1.0.fc28", "rpm", "binary", database.Namespace{}}, {"glib2", "2.56.1-4.fc28", "rpm", "binary", database.Namespace{}}, {"python3-gobject-base", "3.28.3-1.fc28", "rpm", "binary", database.Namespace{}}, {"libffi", "3.1-16.fc28", "rpm", "source", database.Namespace{}}, {"libmodulemd", "1.6.2-2.fc28", "rpm", "source", database.Namespace{}}, {"openssl", "1.1.0h-3.fc28", "rpm", "source", database.Namespace{}}, {"libyaml", "0.1.7-5.fc28", "rpm", "source", database.Namespace{}}, {"pam", "1.3.1-1.fc28", "rpm", "source", database.Namespace{}}, {"iptables", "1.6.2-3.fc28", "rpm", "source", database.Namespace{}}, {"util-linux", "2.32.1-1.fc28", "rpm", "source", database.Namespace{}}, {"libsmartcols", "2.32.1-1.fc28", "rpm", "binary", database.Namespace{}}, {"dnf", "2.7.5-12.fc28", "rpm", "binary", database.Namespace{}}, {"glib2", "2.56.1-4.fc28", "rpm", "source", database.Namespace{}}, {"lua", "5.3.4-10.fc28", "rpm", "source", database.Namespace{}}, {"nss-softokn", "3.38.0-1.0.fc28", "rpm", "source", database.Namespace{}}, {"python3-dnf", "2.7.5-12.fc28", "rpm", "binary", database.Namespace{}}, {"filesystem", "3.8-2.fc28", "rpm", "binary", database.Namespace{}}, {"libsss_nss_idmap", "1.16.3-2.fc28", "rpm", "binary", database.Namespace{}}, {"pcre2", "10.31-10.fc28", "rpm", "source", database.Namespace{}}, {"libyaml", "0.1.7-5.fc28", "rpm", "binary", database.Namespace{}}, {"python3-rpm", "4.14.1-9.fc28", "rpm", "binary", database.Namespace{}}, {"zlib", "1.2.11-8.fc28", "rpm", "source", database.Namespace{}}, {"libutempter", "1.1.6-14.fc28", "rpm", "binary", database.Namespace{}}, {"pcre2", "10.31-10.fc28", "rpm", "binary", database.Namespace{}}, {"libtirpc", "1.0.3-3.rc2.fc28", "rpm", "source", database.Namespace{}}, {"pkgconf-m4", "1.4.2-1.fc28", "rpm", "binary", database.Namespace{}}, {"libreport", "2.9.5-1.fc28", "rpm", "source", database.Namespace{}}, {"vim", "8.1.328-1.fc28", "rpm", "source", database.Namespace{}}, {"file", "5.33-7.fc28", "rpm", "source", database.Namespace{}}, {"shadow-utils", "4.6-1.fc28", "rpm", "source", database.Namespace{}}, {"sqlite-libs", "3.22.0-4.fc28", "rpm", "binary", database.Namespace{}}, {"setup", "2.11.4-1.fc28", "rpm", "source", database.Namespace{}}, {"gcc", "8.1.1-5.fc28", "rpm", "source", database.Namespace{}}, {"mpfr", "3.1.6-1.fc28", "rpm", "binary", database.Namespace{}}, {"device-mapper", "1.02.146-5.fc28", "rpm", "binary", database.Namespace{}}, {"p11-kit", "0.23.12-1.fc28", "rpm", "source", database.Namespace{}}, {"fedora-release", "28-2", "rpm", "binary", database.Namespace{}}, {"libnghttp2", "1.32.1-1.fc28", "rpm", "binary", database.Namespace{}}, {"libcap-ng", "0.7.9-4.fc28", "rpm", "source", database.Namespace{}}, {"iptables-libs", "1.6.2-3.fc28", "rpm", "binary", database.Namespace{}}, {"audit-libs", "2.8.4-2.fc28", "rpm", "binary", database.Namespace{}}, {"libsigsegv", "2.11-5.fc28", "rpm", "source", database.Namespace{}}, {"rootfiles", "8.1-22.fc28", "rpm", "source", database.Namespace{}}, {"kmod-libs", "25-2.fc28", "rpm", "binary", database.Namespace{}}, {"lz4-libs", "1.8.1.2-4.fc28", "rpm", "binary", database.Namespace{}}, {"libassuan", "2.5.1-3.fc28", "rpm", "source", database.Namespace{}}, {"p11-kit", "0.23.12-1.fc28", "rpm", "binary", database.Namespace{}}, {"nss-sysinit", "3.38.0-1.0.fc28", "rpm", "binary", database.Namespace{}}, {"libcap-ng", "0.7.9-4.fc28", "rpm", "binary", database.Namespace{}}, {"bash", "4.4.23-1.fc28", "rpm", "source", database.Namespace{}}, {"pygobject3", "3.28.3-1.fc28", "rpm", "source", database.Namespace{}}, {"dnf-yum", "2.7.5-12.fc28", "rpm", "binary", database.Namespace{}}, {"nss-softokn", "3.38.0-1.0.fc28", "rpm", "binary", database.Namespace{}}, {"expat", "2.2.5-3.fc28", "rpm", "binary", database.Namespace{}}, {"libassuan", "2.5.1-3.fc28", "rpm", "binary", database.Namespace{}}, {"libdb", "5.3.28-30.fc28", "rpm", "binary", database.Namespace{}}, {"tar", "2:1.30-3.fc28", "rpm", "binary", database.Namespace{}}, {"sed", "4.5-1.fc28", "rpm", "source", database.Namespace{}}, {"libmetalink", "0.1.3-6.fc28", "rpm", "binary", database.Namespace{}}, {"python-smartcols", "0.3.0-2.fc28", "rpm", "source", database.Namespace{}}, {"systemd", "238-9.git0e0aa59.fc28", "rpm", "source", database.Namespace{}}, {"python-iniparse", "0.4-30.fc28", "rpm", "source", database.Namespace{}}, {"libsepol", "2.8-1.fc28", "rpm", "binary", database.Namespace{}}, {"libattr", "2.4.48-3.fc28", "rpm", "binary", database.Namespace{}}, {"python3-smartcols", "0.3.0-2.fc28", "rpm", "binary", database.Namespace{}}, {"libdb", "5.3.28-30.fc28", "rpm", "source", database.Namespace{}}, {"libmodulemd", "1.6.2-2.fc28", "rpm", "binary", database.Namespace{}}, {"python3-hawkey", "0.11.1-3.fc28", "rpm", "binary", database.Namespace{}}, {"dbus-libs", "1:1.12.10-1.fc28", "rpm", "binary", database.Namespace{}}, {"chkconfig", "1.10-4.fc28", "rpm", "source", database.Namespace{}}, {"libargon2", "20161029-5.fc28", "rpm", "binary", database.Namespace{}}, {"openssl-pkcs11", "0.4.8-1.fc28", "rpm", "source", database.Namespace{}}, {"libusbx", "1.0.22-1.fc28", "rpm", "source", database.Namespace{}}, {"python3-setuptools", "39.2.0-6.fc28", "rpm", "binary", database.Namespace{}}, {"chkconfig", "1.10-4.fc28", "rpm", "binary", database.Namespace{}}, {"openldap", "2.4.46-3.fc28", "rpm", "source", database.Namespace{}}, {"bzip2", "1.0.6-26.fc28", "rpm", "source", database.Namespace{}}, {"npth", "1.5-4.fc28", "rpm", "source", database.Namespace{}}, {"libtirpc", "1.0.3-3.rc2.fc28", "rpm", "binary", database.Namespace{}}, {"util-linux", "2.32.1-1.fc28", "rpm", "binary", database.Namespace{}}, {"nss", "3.38.0-1.0.fc28", "rpm", "source", database.Namespace{}}, {"elfutils", "0.173-1.fc28", "rpm", "source", database.Namespace{}}, {"libcomps", "0.1.8-11.fc28", "rpm", "source", database.Namespace{}}, {"libxcrypt", "4.1.2-1.fc28", "rpm", "source", database.Namespace{}}, {"gnupg2", "2.2.8-1.fc28", "rpm", "binary", database.Namespace{}}, {"libdnf", "0.11.1-3.fc28", "rpm", "binary", database.Namespace{}}, {"cracklib", "2.9.6-13.fc28", "rpm", "source", database.Namespace{}}, {"libidn2", "2.0.5-1.fc28", "rpm", "source", database.Namespace{}}, {"bzip2-libs", "1.0.6-26.fc28", "rpm", "binary", database.Namespace{}}, {"json-c", "0.13.1-2.fc28", "rpm", "source", database.Namespace{}}, {"gdbm", "1:1.14.1-4.fc28", "rpm", "binary", database.Namespace{}}, {"pcre", "8.42-3.fc28", "rpm", "source", database.Namespace{}}, {"systemd", "238-9.git0e0aa59.fc28", "rpm", "binary", database.Namespace{}}, {"cryptsetup-libs", "2.0.4-1.fc28", "rpm", "binary", database.Namespace{}}, {"dnf", "2.7.5-12.fc28", "rpm", "source", database.Namespace{}}, {"ca-certificates", "2018.2.24-1.0.fc28", "rpm", "source", database.Namespace{}}, {"libidn2", "2.0.5-1.fc28", "rpm", "binary", database.Namespace{}}, {"libpsl", "0.20.2-2.fc28", "rpm", "binary", database.Namespace{}}, {"gdbm-libs", "1:1.14.1-4.fc28", "rpm", "binary", database.Namespace{}}, {"kmod", "25-2.fc28", "rpm", "source", database.Namespace{}}, {"libreport-filesystem", "2.9.5-1.fc28", "rpm", "binary", database.Namespace{}}, {"ima-evm-utils", "1.1-2.fc28", "rpm", "source", database.Namespace{}}, {"nghttp2", "1.32.1-1.fc28", "rpm", "source", database.Namespace{}}, {"cyrus-sasl-lib", "2.1.27-0.2rc7.fc28", "rpm", "binary", database.Namespace{}}, {"libsolv", "0.6.35-1.fc28", "rpm", "binary", database.Namespace{}}, {"cryptsetup", "2.0.4-1.fc28", "rpm", "source", database.Namespace{}}, {"filesystem", "3.8-2.fc28", "rpm", "source", database.Namespace{}}, {"libcap", "2.25-9.fc28", "rpm", "source", database.Namespace{}}, {"libpsl", "0.20.2-2.fc28", "rpm", "source", database.Namespace{}}, {"deltarpm", "3.6-25.fc28", "rpm", "source", database.Namespace{}}, {"fedora-gpg-keys", "28-5", "rpm", "binary", database.Namespace{}}, {"ima-evm-utils", "1.1-2.fc28", "rpm", "binary", database.Namespace{}}, {"nss-tools", "3.38.0-1.0.fc28", "rpm", "binary", database.Namespace{}}, {"libtasn1", "4.13-2.fc28", "rpm", "source", database.Namespace{}}, {"elfutils-libelf", "0.173-1.fc28", "rpm", "binary", database.Namespace{}}, {"device-mapper-libs", "1.02.146-5.fc28", "rpm", "binary", database.Namespace{}}, {"gobject-introspection", "1.56.1-1.fc28", "rpm", "source", database.Namespace{}}, {"publicsuffix-list", "20180514-1.fc28", "rpm", "source", database.Namespace{}}, {"libcap", "2.25-9.fc28", "rpm", "binary", database.Namespace{}}, {"librepo", "1.8.1-7.fc28", "rpm", "binary", database.Namespace{}}, {"rpm-sign-libs", "4.14.1-9.fc28", "rpm", "binary", database.Namespace{}}, {"coreutils-single", "8.29-7.fc28", "rpm", "binary", database.Namespace{}}, {"libacl", "2.2.53-1.fc28", "rpm", "binary", database.Namespace{}}, {"popt", "1.16-14.fc28", "rpm", "source", database.Namespace{}}, {"libtasn1", "4.13-2.fc28", "rpm", "binary", database.Namespace{}}, {"gawk", "4.2.1-1.fc28", "rpm", "source", database.Namespace{}}, {"diffutils", "3.6-4.fc28", "rpm", "source", database.Namespace{}}, {"libgpg-error", "1.31-1.fc28", "rpm", "source", database.Namespace{}}, {"libdb-utils", "5.3.28-30.fc28", "rpm", "binary", database.Namespace{}}, {"python3-iniparse", "0.4-30.fc28", "rpm", "binary", database.Namespace{}}, {"acl", "2.2.53-1.fc28", "rpm", "binary", database.Namespace{}}, {"libssh", "0.8.2-1.fc28", "rpm", "source", database.Namespace{}}, {"python3-librepo", "1.8.1-7.fc28", "rpm", "binary", database.Namespace{}}, {"gobject-introspection", "1.56.1-1.fc28", "rpm", "binary", database.Namespace{}}, {"rpm", "4.14.1-9.fc28", "rpm", "source", database.Namespace{}}, {"libgcrypt", "1.8.3-1.fc28", "rpm", "source", database.Namespace{}}, {"curl", "7.59.0-6.fc28", "rpm", "source", database.Namespace{}}, {"tzdata", "2018e-1.fc28", "rpm", "source", database.Namespace{}}, {"krb5", "1.16.1-13.fc28", "rpm", "source", database.Namespace{}}, {"librepo", "1.8.1-7.fc28", "rpm", "source", database.Namespace{}}, {"python3-gpg", "1.10.0-4.fc28", "rpm", "binary", database.Namespace{}}, {"nettle", "3.4-2.fc28", "rpm", "source", database.Namespace{}}, {"libgcrypt", "1.8.3-1.fc28", "rpm", "binary", database.Namespace{}}, {"python3", "3.6.6-1.fc28", "rpm", "binary", database.Namespace{}}, {"python3-libcomps", "0.1.8-11.fc28", "rpm", "binary", database.Namespace{}}, {"rpm-libs", "4.14.1-9.fc28", "rpm", "binary", database.Namespace{}}, {"nspr", "4.19.0-1.fc28", "rpm", "binary", database.Namespace{}}, {"argon2", "20161029-5.fc28", "rpm", "source", database.Namespace{}}, {"tar", "1.30-3.fc28", "rpm", "source", database.Namespace{}}, {"qrencode-libs", "3.4.4-5.fc28", "rpm", "binary", database.Namespace{}}, {"gmp", "6.1.2-7.fc28", "rpm", "source", database.Namespace{}}, {"libverto", "0.3.0-5.fc28", "rpm", "binary", database.Namespace{}}, {"python3", "3.6.6-1.fc28", "rpm", "source", database.Namespace{}}, {"libksba", "1.3.5-7.fc28", "rpm", "binary", database.Namespace{}}, {"readline", "7.0-11.fc28", "rpm", "binary", database.Namespace{}}, {"rpm-build-libs", "4.14.1-9.fc28", "rpm", "binary", database.Namespace{}}, {"npth", "1.5-4.fc28", "rpm", "binary", database.Namespace{}}, {"rootfiles", "8.1-22.fc28", "rpm", "binary", database.Namespace{}}, {"rpm-plugin-systemd-inhibit", "4.14.1-9.fc28", "rpm", "binary", database.Namespace{}}, {"systemd-libs", "238-9.git0e0aa59.fc28", "rpm", "binary", database.Namespace{}}, {"nss-util", "3.38.0-1.0.fc28", "rpm", "binary", database.Namespace{}}, } func TestRpmFeatureDetection(t *testing.T) { for _, test := range []featurefmt.TestCase{ { "valid small case", map[string]string{"var/lib/rpm/Packages": "rpm/testdata/valid"}, []database.Feature{ {"centos-release", "7-1.1503.el7.centos.2.8", "rpm", "binary", database.Namespace{}}, {"filesystem", "3.2-18.el7", "rpm", "binary", database.Namespace{}}, {"centos-release", "7-1.1503.el7.centos.2.8", "rpm", "source", database.Namespace{}}, {"filesystem", "3.2-18.el7", "rpm", "source", database.Namespace{}}, }, }, { "valid big case", map[string]string{"var/lib/rpm/Packages": "rpm/testdata/valid_big"}, expectedBigCaseInfo, }, } { featurefmt.RunTest(t, test, lister{}, rpm.ParserName) } } func TestParseSourceRPM(t *testing.T) { for _, test := range [...]struct { sourceRPM string expectedName string expectedVersion string expectedErr string }{ // valid cases {"publicsuffix-list-20180514-1.fc28.src.rpm", "publicsuffix-list", "20180514-1.fc28", ""}, {"libreport-2.9.5-1.fc28.src.rpm", "libreport", "2.9.5-1.fc28", ""}, {"lua-5.3.4-10.fc28.src.rpm", "lua", "5.3.4-10.fc28", ""}, {"crypto-policies-20180425-5.git6ad4018.fc28.src.rpm", "crypto-policies", "20180425-5.git6ad4018.fc28", ""}, // invalid cases {"crypto-policies-20180425-5.git6ad4018.fc28.src.dpkg", "", "", "unexpected package type, expect: 'rpm', got: 'dpkg'"}, {"crypto-policies-20180425-5.git6ad4018.fc28.debian-8.rpm", "", "", "unexpected package architecture, expect: 'src' or 'nosrc', got: 'debian-8'"}, {"fc28.src.rpm", "", "", "unexpected termination while parsing 'Release Token'"}, {"...", "", "", "unexpected package type, expect: 'rpm', got: ''"}, // impossible case // This illustrates the limitation of this parser, it will not find the // error cased by extra '-' in the intended version/expect token. Based // on the documentation, this case should never happen and indicates a // corrupted rpm database. // actual expected: name="lua", version="5.3.4", release="10.fc-28" {"lua-5.3.4-10.fc-28.src.rpm", "lua-5.3.4", "10.fc-28", ""}, } { name, version, release, _, err := parseSourceRPM(test.sourceRPM) if test.expectedErr != "" { require.EqualError(t, err, test.expectedErr) continue } require.Nil(t, err) require.Equal(t, test.expectedName, name) require.Equal(t, test.expectedVersion, version+"-"+release) } }