diff --git a/rpm/native_db.go b/rpm/native_db.go index 1cc43f72e..7aee7b45e 100644 --- a/rpm/native_db.go +++ b/rpm/native_db.go @@ -5,6 +5,8 @@ import ( "context" "fmt" "io" + "path" + "regexp" "runtime/trace" "strings" @@ -121,7 +123,8 @@ type Info struct { Module string Arch string Digest string - Signature []byte // This is a PGP signature packet. + Signature []byte // This is a PGP signature packet. + Filenames []string // Filtered by the [filePatterns] regexp. DigestAlgo int Epoch int } @@ -129,6 +132,8 @@ type Info struct { // Load populates the receiver with information extracted from the provided // [rpm.Header]. func (i *Info) Load(ctx context.Context, h *rpm.Header) error { + var dirname, basename []string + var dirindex []int32 for idx := range h.Infos { e := &h.Infos[idx] if _, ok := wantTags[e.Tag]; !ok { @@ -159,14 +164,84 @@ func (i *Info) Load(ctx context.Context, h *rpm.Header) error { i.Digest = v.([]string)[0] case rpm.TagSigPGP: i.Signature = v.([]byte) + case rpm.TagDirnames: + dirname = v.([]string) + case rpm.TagDirindexes: + dirindex = v.([]int32) + case rpm.TagBasenames: + basename = v.([]string) + case rpm.TagFilenames: + // Filenames is the tag used in rpm4 -- this is a best-effort for + // supporting it. + for _, name := range v.([]string) { + if !filePatterns.MatchString(name) { + // Record the name as a relative path, as that's what we use + // everywhere else. + i.Filenames = append(i.Filenames, name[1:]) + } + } + } + } + + // Catch panics from malformed headers. Can't think of a better way to + // handle this. + defer func() { + if r := recover(); r == nil { + return + } + zlog.Warn(ctx). + Str("name", i.Name). + Strs("basename", basename). + Strs("dirname", dirname). + Ints32("dirindex", dirindex). + Msg("caught panic in filename construction") + i.Filenames = nil + }() + for j := range basename { + // We only want '/'-separated paths, even if running on some other, + // weird OS. It seems that RPM assumes '/' throughout. + name := path.Join(dirname[dirindex[j]], basename[j]) + if filePatterns.MatchString(name) { + // Record the name as a relative path, as that's what we use + // everywhere else. + i.Filenames = append(i.Filenames, name[1:]) } } return nil } +// FilePatterns is a regular expression for *any* file that may need to be +// recorded alongside a package. +// +// The tested strings are absolute paths. +var filePatterns *regexp.Regexp + +func init() { + // TODO(hank) The blanket binary pattern is too broad and can miss things. + // Long-term, we should add pattern matching akin to [yara] or file(1) as a + // plugin mechanism that all indexers can use. That way, the Go indexer + // could register a pattern and use a shared filter over the + // [fs.WalkDirFunc] while this package (and dpkg, etc) can tell that another + // indexer will find those files relevant. + // + // [yara]: https://github.com/VirusTotal/yara + pat := []string{ + `^.*/[^/]+\.jar$`, // Jar files + `^.*/site-packages/[^/]+\.egg-info/PKG-INFO$`, // Python packages + `^.*/package.json$`, // npm packages + `^.*/[^/]+\.gemspec$`, // ruby gems + `^/usr/bin/[^/]+$`, // any executable + } + filePatterns = regexp.MustCompile(strings.Join(pat, `|`)) +} + var wantTags = map[rpm.Tag]struct{}{ rpm.TagArch: {}, + rpm.TagBasenames: {}, + rpm.TagDirindexes: {}, + rpm.TagDirnames: {}, rpm.TagEpoch: {}, + rpm.TagFilenames: {}, rpm.TagModularityLabel: {}, rpm.TagName: {}, rpm.TagPayloadDigest: {}, diff --git a/rpm/native_db_test.go b/rpm/native_db_test.go new file mode 100644 index 000000000..567c98216 --- /dev/null +++ b/rpm/native_db_test.go @@ -0,0 +1,125 @@ +package rpm + +import ( + "context" + "encoding/json" + "os" + "path/filepath" + "strings" + "testing" + + "github.com/google/go-cmp/cmp" + "github.com/quay/zlog" + "golang.org/x/tools/txtar" + + "github.com/quay/claircore/rpm/bdb" + "github.com/quay/claircore/rpm/internal/rpm" + "github.com/quay/claircore/rpm/ndb" + "github.com/quay/claircore/rpm/sqlite" +) + +func TestInfo(t *testing.T) { + t.Run("Files", func(t *testing.T) { + ms, err := filepath.Glob("testdata/Info.Files.*.txtar") + if err != nil { + t.Fatal(err) + } + for _, m := range ms { + ar, err := txtar.ParseFile(m) + if err != nil { + t.Fatal(err) + } + name := strings.TrimPrefix(strings.TrimSuffix(filepath.Base(m), ".txtar"), "Info.Files.") + t.Run(name, func(t *testing.T) { + //t.Parallel() + ctx := zlog.Test(context.Background(), t) + filename := strings.TrimSpace(string(ar.Comment)) + t.Logf("opening %q", filename) + + var want map[string][]string + for _, f := range ar.Files { + if f.Name == "want.json" { + want = make(map[string][]string) + if err := json.Unmarshal(f.Data, &want); err != nil { + t.Fatal(err) + } + break + } + } + if want == nil { + t.Fatal(`"want.json" not found`) + } + + pre, _, ok := strings.Cut(filename, `/testdata/`) + if !ok { + t.Fatal("input file not in a testdata directory") + } + + var nat nativeDB + switch pre { + case `bdb`: + f, err := os.Open(filename) + if err != nil { + t.Fatal(err) + } else { + t.Cleanup(func() { f.Close() }) + } + var db bdb.PackageDB + if err := db.Parse(f); err != nil { + t.Fatal(err) + } + nat = &db + case `ndb`: + f, err := os.Open(filename) + if err != nil { + t.Fatal(err) + } else { + t.Cleanup(func() { f.Close() }) + } + var db ndb.PackageDB + if err := db.Parse(f); err != nil { + t.Fatal(err) + } + nat = &db + case `sqlite`: + db, err := sqlite.Open(filename) + if err != nil { + t.Fatal(err) + } else { + t.Cleanup(func() { db.Close() }) + } + nat = db + } + + rds, err := nat.AllHeaders(ctx) + if err != nil { + t.Fatal(err) + } + + got := make(map[string][]string, len(want)) + for _, rd := range rds { + var h rpm.Header + if err := h.Parse(ctx, rd); err != nil { + t.Error(err) + continue + } + var info Info + if err := info.Load(ctx, &h); err != nil { + t.Error(err) + continue + } + if info.Name == "gpg-pubkey" { + // This is *not* an rpm package. It is just a public key stored in the rpm database. + // Ignore this "package". + continue + } + got[info.Name] = info.Filenames + } + + if !cmp.Equal(got, want) { + t.Error(cmp.Diff(got, want)) + } + }) + } + }) +} diff --git a/rpm/testdata/Info.Files.BDB.txtar b/rpm/testdata/Info.Files.BDB.txtar new file mode 100644 index 000000000..6c23f3f56 --- /dev/null +++ b/rpm/testdata/Info.Files.BDB.txtar @@ -0,0 +1,627 @@ +bdb/testdata/ubi8.Packages +-- want.json -- +{ + "acl": [ + "usr/bin/chacl", + "usr/bin/getfacl", + "usr/bin/setfacl" + ], + "audit-libs": null, + "basesystem": null, + "bash": [ + "usr/bin/alias", + "usr/bin/bash", + "usr/bin/bashbug", + "usr/bin/bashbug-64", + "usr/bin/bg", + "usr/bin/cd", + "usr/bin/command", + "usr/bin/fc", + "usr/bin/fg", + "usr/bin/getopts", + "usr/bin/hash", + "usr/bin/jobs", + "usr/bin/read", + "usr/bin/sh", + "usr/bin/type", + "usr/bin/ulimit", + "usr/bin/umask", + "usr/bin/unalias", + "usr/bin/wait" + ], + "brotli": [ + "usr/bin/brotli" + ], + "bzip2-libs": null, + "ca-certificates": [ + "usr/bin/ca-legacy", + "usr/bin/update-ca-trust" + ], + "chkconfig": null, + "coreutils-single": [ + "usr/bin/[", + "usr/bin/arch", + "usr/bin/b2sum", + "usr/bin/base32", + "usr/bin/base64", + "usr/bin/basename", + "usr/bin/cat", + "usr/bin/chcon", + "usr/bin/chgrp", + "usr/bin/chmod", + "usr/bin/chown", + "usr/bin/cksum", + "usr/bin/comm", + "usr/bin/coreutils", + "usr/bin/cp", + "usr/bin/csplit", + "usr/bin/cut", + "usr/bin/date", + "usr/bin/dd", + "usr/bin/df", + "usr/bin/dir", + "usr/bin/dircolors", + "usr/bin/dirname", + "usr/bin/du", + "usr/bin/echo", + "usr/bin/env", + "usr/bin/expand", + "usr/bin/expr", + "usr/bin/factor", + "usr/bin/false", + "usr/bin/fmt", + "usr/bin/fold", + "usr/bin/groups", + "usr/bin/head", + "usr/bin/hostid", + "usr/bin/id", + "usr/bin/install", + "usr/bin/join", + "usr/bin/link", + "usr/bin/ln", + "usr/bin/logname", + "usr/bin/ls", + "usr/bin/md5sum", + "usr/bin/mkdir", + "usr/bin/mkfifo", + "usr/bin/mknod", + "usr/bin/mktemp", + "usr/bin/mv", + "usr/bin/nice", + "usr/bin/nl", + "usr/bin/nohup", + "usr/bin/nproc", + "usr/bin/numfmt", + "usr/bin/od", + "usr/bin/paste", + "usr/bin/pathchk", + "usr/bin/pinky", + "usr/bin/pr", + "usr/bin/printenv", + "usr/bin/printf", + "usr/bin/ptx", + "usr/bin/pwd", + "usr/bin/readlink", + "usr/bin/realpath", + "usr/bin/rm", + "usr/bin/rmdir", + "usr/bin/runcon", + "usr/bin/seq", + "usr/bin/sha1sum", + "usr/bin/sha224sum", + "usr/bin/sha256sum", + "usr/bin/sha384sum", + "usr/bin/sha512sum", + "usr/bin/shred", + "usr/bin/shuf", + "usr/bin/sleep", + "usr/bin/sort", + "usr/bin/split", + "usr/bin/stat", + "usr/bin/stdbuf", + "usr/bin/stty", + "usr/bin/sum", + "usr/bin/sync", + "usr/bin/tac", + "usr/bin/tail", + "usr/bin/tee", + "usr/bin/test", + "usr/bin/timeout", + "usr/bin/touch", + "usr/bin/tr", + "usr/bin/true", + "usr/bin/truncate", + "usr/bin/tsort", + "usr/bin/tty", + "usr/bin/uname", + "usr/bin/unexpand", + "usr/bin/uniq", + "usr/bin/unlink", + "usr/bin/users", + "usr/bin/vdir", + "usr/bin/wc", + "usr/bin/who", + "usr/bin/whoami", + "usr/bin/yes" + ], + "cracklib": null, + "cracklib-dicts": null, + "crypto-policies": null, + "crypto-policies-scripts": [ + "usr/bin/fips-finish-install", + "usr/bin/fips-mode-setup", + "usr/bin/update-crypto-policies" + ], + "cryptsetup-libs": null, + "curl": [ + "usr/bin/curl" + ], + "cyrus-sasl-lib": null, + "dbus": null, + "dbus-common": null, + "dbus-daemon": [ + "usr/bin/dbus-cleanup-sockets", + "usr/bin/dbus-daemon", + "usr/bin/dbus-run-session", + "usr/bin/dbus-test-tool" + ], + "dbus-glib": [ + "usr/bin/dbus-binding-tool" + ], + "dbus-libs": null, + "dbus-tools": [ + "usr/bin/dbus-monitor", + "usr/bin/dbus-send", + "usr/bin/dbus-update-activation-environment", + "usr/bin/dbus-uuidgen" + ], + "device-mapper": null, + "device-mapper-libs": null, + "dmidecode": null, + "dnf": [ + "usr/bin/dnf" + ], + "dnf-data": null, + "dnf-plugin-subscription-manager": null, + "elfutils-default-yama-scope": null, + "elfutils-libelf": null, + "elfutils-libs": null, + "expat": [ + "usr/bin/xmlwf" + ], + "file-libs": null, + "filesystem": null, + "findutils": [ + "usr/bin/find", + "usr/bin/xargs" + ], + "gawk": [ + "usr/bin/awk", + "usr/bin/gawk" + ], + "gdb-gdbserver": [ + "usr/bin/gdbserver" + ], + "gdbm": [ + "usr/bin/gdbm_dump", + "usr/bin/gdbm_load", + "usr/bin/gdbmtool" + ], + "gdbm-libs": null, + "glib2": [ + "usr/bin/gapplication", + "usr/bin/gdbus", + "usr/bin/gio", + "usr/bin/gio-querymodules-64", + "usr/bin/glib-compile-schemas", + "usr/bin/gsettings" + ], + "glibc": null, + "glibc-common": [ + "usr/bin/catchsegv", + "usr/bin/gencat", + "usr/bin/getconf", + "usr/bin/getent", + "usr/bin/iconv", + "usr/bin/ld.so", + "usr/bin/ldd", + "usr/bin/locale", + "usr/bin/localedef", + "usr/bin/makedb", + "usr/bin/pldd", + "usr/bin/sotruss", + "usr/bin/sprof", + "usr/bin/tzselect" + ], + "glibc-minimal-langpack": null, + "gmp": null, + "gnupg2": [ + "usr/bin/dirmngr", + "usr/bin/dirmngr-client", + "usr/bin/g13", + "usr/bin/gpg", + "usr/bin/gpg-agent", + "usr/bin/gpg-connect-agent", + "usr/bin/gpg-wks-server", + "usr/bin/gpg-zip", + "usr/bin/gpg2", + "usr/bin/gpgconf", + "usr/bin/gpgparsemail", + "usr/bin/gpgsplit", + "usr/bin/gpgv", + "usr/bin/gpgv2", + "usr/bin/watchgnupg" + ], + "gnutls": null, + "gobject-introspection": null, + "gpgme": [ + "usr/bin/gpgme-json" + ], + "grep": [ + "usr/bin/egrep", + "usr/bin/fgrep", + "usr/bin/grep" + ], + "gzip": [ + "usr/bin/gunzip", + "usr/bin/gzexe", + "usr/bin/gzip", + "usr/bin/zcat", + "usr/bin/zcmp", + "usr/bin/zdiff", + "usr/bin/zegrep", + "usr/bin/zfgrep", + "usr/bin/zforce", + "usr/bin/zgrep", + "usr/bin/zless", + "usr/bin/zmore", + "usr/bin/znew" + ], + "ima-evm-utils": [ + "usr/bin/evmctl" + ], + "info": [ + "usr/bin/info" + ], + "json-c": null, + "json-glib": null, + "keyutils-libs": null, + "kmod-libs": null, + "krb5-libs": null, + "langpacks-en": null, + "libacl": null, + "libarchive": null, + "libassuan": null, + "libattr": null, + "libblkid": null, + "libcap": null, + "libcap-ng": null, + "libcom_err": null, + "libcomps": null, + "libcurl": null, + "libdb": null, + "libdb-utils": [ + "usr/bin/db_archive", + "usr/bin/db_checkpoint", + "usr/bin/db_deadlock", + "usr/bin/db_dump", + "usr/bin/db_dump185", + "usr/bin/db_hotbackup", + "usr/bin/db_load", + "usr/bin/db_log_verify", + "usr/bin/db_printlog", + "usr/bin/db_recover", + "usr/bin/db_replicate", + "usr/bin/db_stat", + "usr/bin/db_tuner", + "usr/bin/db_upgrade", + "usr/bin/db_verify" + ], + "libdnf": null, + "libfdisk": null, + "libffi": null, + "libgcc": null, + "libgcrypt": null, + "libgpg-error": [ + "usr/bin/gpg-error" + ], + "libidn2": null, + "libksba": null, + "libmodulemd": [ + "usr/bin/modulemd-validator" + ], + "libmount": null, + "libnghttp2": null, + "libnl3": null, + "libnsl2": null, + "libpsl": null, + "libpwquality": [ + "usr/bin/pwmake", + "usr/bin/pwscore" + ], + "librepo": null, + "libreport-filesystem": null, + "librhsm": null, + "libseccomp": null, + "libselinux": null, + "libsemanage": null, + "libsepol": null, + "libsigsegv": null, + "libsmartcols": null, + "libsolv": null, + "libssh": null, + "libssh-config": null, + "libstdc++": null, + "libtasn1": null, + "libtirpc": null, + "libunistring": null, + "libusbx": null, + "libuser": [ + "usr/bin/lchfn", + "usr/bin/lchsh" + ], + "libutempter": null, + "libuuid": null, + "libverto": null, + "libxcrypt": null, + "libxml2": [ + "usr/bin/xmlcatalog", + "usr/bin/xmllint" + ], + "libyaml": null, + "libzstd": null, + "lua-libs": null, + "lz4-libs": null, + "mpfr": null, + "ncurses-base": null, + "ncurses-libs": null, + "nettle": null, + "npth": null, + "openldap": null, + "openssl-libs": null, + "p11-kit": [ + "usr/bin/p11-kit" + ], + "p11-kit-trust": [ + "usr/bin/trust" + ], + "pam": null, + "passwd": [ + "usr/bin/passwd" + ], + "pcre": null, + "pcre2": null, + "platform-python": [ + "usr/bin/pydoc3.6", + "usr/bin/pyvenv-3.6", + "usr/bin/unversioned-python" + ], + "platform-python-setuptools": null, + "popt": null, + "publicsuffix-list-dafsa": null, + "python3-chardet": [ + "usr/bin/chardetect", + "usr/lib/python3.6/site-packages/chardet-3.0.4-py3.6.egg-info/PKG-INFO" + ], + "python3-cloud-what": null, + "python3-dateutil": [ + "usr/lib/python3.6/site-packages/python_dateutil-2.6.1-py3.6.egg-info/PKG-INFO" + ], + "python3-dbus": [ + "usr/lib64/python3.6/site-packages/dbus_python-1.2.4-py3.6.egg-info/PKG-INFO" + ], + "python3-decorator": [ + "usr/lib/python3.6/site-packages/decorator-4.2.1-py3.6.egg-info/PKG-INFO" + ], + "python3-dmidecode": null, + "python3-dnf": [ + "usr/bin/dnf-3" + ], + "python3-dnf-plugins-core": null, + "python3-ethtool": [ + "usr/lib64/python3.6/site-packages/ethtool-0.14-py3.6.egg-info/PKG-INFO" + ], + "python3-gobject-base": null, + "python3-gpg": null, + "python3-hawkey": null, + "python3-idna": [ + "usr/lib/python3.6/site-packages/idna-2.5-py3.6.egg-info/PKG-INFO" + ], + "python3-iniparse": [ + "usr/lib/python3.6/site-packages/iniparse-0.4-py3.6.egg-info/PKG-INFO" + ], + "python3-inotify": [ + "usr/bin/pyinotify", + "usr/lib/python3.6/site-packages/pyinotify-0.9.6-py3.6.egg-info/PKG-INFO" + ], + "python3-libcomps": [ + "usr/lib64/python3.6/site-packages/libcomps-0.1.18-py3.6.egg-info/PKG-INFO" + ], + "python3-libdnf": null, + "python3-librepo": null, + "python3-libs": null, + "python3-libxml2": null, + "python3-pip-wheel": null, + "python3-pysocks": [ + "usr/lib/python3.6/site-packages/PySocks-1.6.8-py3.6.egg-info/PKG-INFO" + ], + "python3-requests": [ + "usr/lib/python3.6/site-packages/requests-2.20.0-py3.6.egg-info/PKG-INFO" + ], + "python3-rpm": null, + "python3-setuptools-wheel": null, + "python3-six": null, + "python3-subscription-manager-rhsm": null, + "python3-syspurpose": [ + "usr/lib/python3.6/site-packages/syspurpose-1.28.29-py3.6.egg-info/PKG-INFO" + ], + "python3-urllib3": [ + "usr/lib/python3.6/site-packages/urllib3-1.24.2-py3.6.egg-info/PKG-INFO" + ], + "readline": null, + "redhat-release": null, + "rootfiles": null, + "rpm": [ + "usr/bin/rpm", + "usr/bin/rpm2archive", + "usr/bin/rpm2cpio", + "usr/bin/rpmdb", + "usr/bin/rpmkeys", + "usr/bin/rpmquery", + "usr/bin/rpmverify" + ], + "rpm-build-libs": null, + "rpm-libs": null, + "sed": [ + "usr/bin/sed" + ], + "setup": null, + "shadow-utils": [ + "usr/bin/chage", + "usr/bin/gpasswd", + "usr/bin/lastlog", + "usr/bin/newgidmap", + "usr/bin/newgrp", + "usr/bin/newuidmap", + "usr/bin/sg" + ], + "sqlite-libs": null, + "subscription-manager": [ + "usr/bin/rct", + "usr/bin/rhsm-debug", + "usr/bin/rhsmcertd", + "usr/bin/subscription-manager", + "usr/lib64/python3.6/site-packages/subscription_manager-1.28.29-py3.6.egg-info/PKG-INFO" + ], + "subscription-manager-rhsm-certificates": null, + "systemd": [ + "usr/bin/busctl", + "usr/bin/coredumpctl", + "usr/bin/hostnamectl", + "usr/bin/journalctl", + "usr/bin/localectl", + "usr/bin/loginctl", + "usr/bin/resolvectl", + "usr/bin/systemctl", + "usr/bin/systemd-analyze", + "usr/bin/systemd-ask-password", + "usr/bin/systemd-cat", + "usr/bin/systemd-cgls", + "usr/bin/systemd-cgtop", + "usr/bin/systemd-delta", + "usr/bin/systemd-detect-virt", + "usr/bin/systemd-escape", + "usr/bin/systemd-firstboot", + "usr/bin/systemd-inhibit", + "usr/bin/systemd-machine-id-setup", + "usr/bin/systemd-mount", + "usr/bin/systemd-notify", + "usr/bin/systemd-path", + "usr/bin/systemd-resolve", + "usr/bin/systemd-run", + "usr/bin/systemd-socket-activate", + "usr/bin/systemd-stdio-bridge", + "usr/bin/systemd-sysusers", + "usr/bin/systemd-tmpfiles", + "usr/bin/systemd-tty-ask-password-agent", + "usr/bin/systemd-umount", + "usr/bin/timedatectl" + ], + "systemd-libs": null, + "systemd-pam": null, + "tar": [ + "usr/bin/gtar", + "usr/bin/tar" + ], + "tpm2-tss": null, + "tzdata": null, + "usermode": [ + "usr/bin/consolehelper" + ], + "util-linux": [ + "usr/bin/cal", + "usr/bin/chmem", + "usr/bin/chrt", + "usr/bin/col", + "usr/bin/colcrt", + "usr/bin/colrm", + "usr/bin/column", + "usr/bin/dmesg", + "usr/bin/eject", + "usr/bin/fallocate", + "usr/bin/fincore", + "usr/bin/findmnt", + "usr/bin/flock", + "usr/bin/getopt", + "usr/bin/hexdump", + "usr/bin/i386", + "usr/bin/ionice", + "usr/bin/ipcmk", + "usr/bin/ipcrm", + "usr/bin/ipcs", + "usr/bin/isosize", + "usr/bin/kill", + "usr/bin/last", + "usr/bin/lastb", + "usr/bin/linux32", + "usr/bin/linux64", + "usr/bin/logger", + "usr/bin/login", + "usr/bin/look", + "usr/bin/lsblk", + "usr/bin/lscpu", + "usr/bin/lsipc", + "usr/bin/lslocks", + "usr/bin/lslogins", + "usr/bin/lsmem", + "usr/bin/lsns", + "usr/bin/mcookie", + "usr/bin/mesg", + "usr/bin/more", + "usr/bin/mount", + "usr/bin/mountpoint", + "usr/bin/namei", + "usr/bin/nsenter", + "usr/bin/prlimit", + "usr/bin/raw", + "usr/bin/rename", + "usr/bin/renice", + "usr/bin/rev", + "usr/bin/script", + "usr/bin/scriptreplay", + "usr/bin/setarch", + "usr/bin/setpriv", + "usr/bin/setsid", + "usr/bin/setterm", + "usr/bin/su", + "usr/bin/taskset", + "usr/bin/ul", + "usr/bin/umount", + "usr/bin/uname26", + "usr/bin/unshare", + "usr/bin/utmpdump", + "usr/bin/uuidgen", + "usr/bin/uuidparse", + "usr/bin/wall", + "usr/bin/wdctl", + "usr/bin/whereis", + "usr/bin/write", + "usr/bin/x86_64" + ], + "vim-minimal": [ + "usr/bin/ex", + "usr/bin/rvi", + "usr/bin/rview", + "usr/bin/vi", + "usr/bin/view" + ], + "virt-what": null, + "which": [ + "usr/bin/which" + ], + "xz-libs": null, + "yum": [ + "usr/bin/yum" + ], + "zlib": null +} diff --git a/rpm/testdata/Info.Files.NDB.txtar b/rpm/testdata/Info.Files.NDB.txtar new file mode 100644 index 000000000..98d3eb199 --- /dev/null +++ b/rpm/testdata/Info.Files.NDB.txtar @@ -0,0 +1,471 @@ +ndb/testdata/Packages.db +-- want.json -- +{ + "aaa_base": [ + "usr/bin/chkconfig", + "usr/bin/filesize", + "usr/bin/get_kernel_version", + "usr/bin/mkinfodir", + "usr/bin/old", + "usr/bin/rpmlocate", + "usr/bin/safe-rm", + "usr/bin/safe-rmdir" + ], + "bash": [ + "usr/bin/bash", + "usr/bin/bashbug", + "usr/bin/rbash" + ], + "bash-sh": [ + "usr/bin/sh" + ], + "boost-license1_66_0": null, + "ca-certificates": null, + "ca-certificates-mozilla": null, + "container-suseconnect": [ + "usr/bin/container-suseconnect" + ], + "coreutils": [ + "usr/bin/[", + "usr/bin/arch", + "usr/bin/b2sum", + "usr/bin/base32", + "usr/bin/base64", + "usr/bin/basename", + "usr/bin/basenc", + "usr/bin/cat", + "usr/bin/chcon", + "usr/bin/chgrp", + "usr/bin/chmod", + "usr/bin/chown", + "usr/bin/chroot", + "usr/bin/cksum", + "usr/bin/comm", + "usr/bin/cp", + "usr/bin/csplit", + "usr/bin/cut", + "usr/bin/date", + "usr/bin/dd", + "usr/bin/df", + "usr/bin/dir", + "usr/bin/dircolors", + "usr/bin/dirname", + "usr/bin/du", + "usr/bin/echo", + "usr/bin/env", + "usr/bin/expand", + "usr/bin/expr", + "usr/bin/factor", + "usr/bin/false", + "usr/bin/fmt", + "usr/bin/fold", + "usr/bin/groups", + "usr/bin/head", + "usr/bin/hostid", + "usr/bin/id", + "usr/bin/install", + "usr/bin/join", + "usr/bin/link", + "usr/bin/ln", + "usr/bin/logname", + "usr/bin/ls", + "usr/bin/md5sum", + "usr/bin/mkdir", + "usr/bin/mkfifo", + "usr/bin/mknod", + "usr/bin/mktemp", + "usr/bin/mv", + "usr/bin/nice", + "usr/bin/nl", + "usr/bin/nohup", + "usr/bin/nproc", + "usr/bin/numfmt", + "usr/bin/od", + "usr/bin/paste", + "usr/bin/pathchk", + "usr/bin/pinky", + "usr/bin/pr", + "usr/bin/printenv", + "usr/bin/printf", + "usr/bin/ptx", + "usr/bin/pwd", + "usr/bin/readlink", + "usr/bin/realpath", + "usr/bin/rm", + "usr/bin/rmdir", + "usr/bin/runcon", + "usr/bin/seq", + "usr/bin/sha1sum", + "usr/bin/sha224sum", + "usr/bin/sha256sum", + "usr/bin/sha384sum", + "usr/bin/sha512sum", + "usr/bin/shred", + "usr/bin/shuf", + "usr/bin/sleep", + "usr/bin/sort", + "usr/bin/split", + "usr/bin/stat", + "usr/bin/stdbuf", + "usr/bin/stty", + "usr/bin/sum", + "usr/bin/sync", + "usr/bin/tac", + "usr/bin/tail", + "usr/bin/tee", + "usr/bin/test", + "usr/bin/timeout", + "usr/bin/touch", + "usr/bin/tr", + "usr/bin/true", + "usr/bin/truncate", + "usr/bin/tsort", + "usr/bin/tty", + "usr/bin/uname", + "usr/bin/unexpand", + "usr/bin/uniq", + "usr/bin/unlink", + "usr/bin/uptime", + "usr/bin/users", + "usr/bin/vdir", + "usr/bin/wc", + "usr/bin/who", + "usr/bin/whoami", + "usr/bin/yes" + ], + "cpio": [ + "usr/bin/cpio" + ], + "cracklib": null, + "cracklib-dict-small": null, + "crypto-policies": null, + "curl": [ + "usr/bin/curl" + ], + "diffutils": [ + "usr/bin/cmp", + "usr/bin/diff", + "usr/bin/diff3", + "usr/bin/sdiff" + ], + "file-magic": null, + "filesystem": null, + "fillup": [ + "usr/bin/fillup" + ], + "findutils": [ + "usr/bin/find", + "usr/bin/xargs" + ], + "glibc": [ + "usr/bin/gencat", + "usr/bin/getconf", + "usr/bin/getent", + "usr/bin/iconv", + "usr/bin/ldd", + "usr/bin/locale", + "usr/bin/localedef" + ], + "gpg2": [ + "usr/bin/g13", + "usr/bin/gpg", + "usr/bin/gpg-agent", + "usr/bin/gpg-connect-agent", + "usr/bin/gpg-wks-server", + "usr/bin/gpg-zip", + "usr/bin/gpg2", + "usr/bin/gpgconf", + "usr/bin/gpgparsemail", + "usr/bin/gpgscm", + "usr/bin/gpgsm", + "usr/bin/gpgsplit", + "usr/bin/gpgtar", + "usr/bin/gpgv", + "usr/bin/gpgv2", + "usr/bin/kbxutil", + "usr/bin/scdaemon", + "usr/bin/watchgnupg" + ], + "grep": [ + "usr/bin/egrep", + "usr/bin/fgrep", + "usr/bin/grep" + ], + "info": [ + "usr/bin/info", + "usr/bin/install-info" + ], + "krb5": null, + "kubic-locale-archive": null, + "libacl1": null, + "libassuan0": null, + "libattr1": null, + "libaudit1": null, + "libaugeas0": null, + "libblkid1": null, + "libboost_system1_66_0": null, + "libboost_thread1_66_0": null, + "libbrotlicommon1": null, + "libbrotlidec1": null, + "libbz2-1": null, + "libcap-ng0": null, + "libcap2": null, + "libcom_err2": null, + "libcrack2": null, + "libcrypt1": null, + "libcurl4": null, + "libdw1": null, + "libeconf0": null, + "libelf1": null, + "libfdisk1": null, + "libffi7": null, + "libgcc_s1": null, + "libgcrypt20": null, + "libgcrypt20-hmac": null, + "libglib-2_0-0": null, + "libgmp10": null, + "libgpg-error0": null, + "libgpgme11": null, + "libidn2-0": null, + "libkeyutils1": null, + "libksba8": null, + "libldap-2_4-2": null, + "libldap-data": null, + "liblua5_3-5": null, + "liblz4-1": null, + "liblzma5": null, + "libmagic1": null, + "libmount1": null, + "libncurses6": null, + "libnghttp2-14": null, + "libnpth0": null, + "libnsl2": null, + "libopenssl1_1": null, + "libopenssl1_1-hmac": null, + "libp11-kit0": null, + "libpcre1": null, + "libpopt0": null, + "libprocps7": null, + "libprotobuf-lite20": null, + "libproxy1": null, + "libpsl5": null, + "libreadline7": null, + "libsasl2-3": null, + "libselinux1": null, + "libsemanage1": null, + "libsepol1": null, + "libsigc-2_0-0": null, + "libsmartcols1": null, + "libsolv-tools": [ + "usr/bin/appdata2solv", + "usr/bin/comps2solv", + "usr/bin/deltainfoxml2solv", + "usr/bin/dumpsolv", + "usr/bin/installcheck", + "usr/bin/mergesolv", + "usr/bin/repo2solv", + "usr/bin/repo2solv.sh", + "usr/bin/repomdxml2solv", + "usr/bin/rpmdb2solv", + "usr/bin/rpmmd2solv", + "usr/bin/rpms2solv", + "usr/bin/susetags2solv", + "usr/bin/testsolv", + "usr/bin/updateinfoxml2solv" + ], + "libsqlite3-0": null, + "libssh-config": null, + "libssh4": null, + "libstdc++6": null, + "libsystemd0": null, + "libtasn1": [ + "usr/bin/asn1Coding", + "usr/bin/asn1Decoding", + "usr/bin/asn1Parser" + ], + "libtasn1-6": null, + "libtirpc-netconfig": null, + "libtirpc3": null, + "libudev1": null, + "libunistring2": null, + "libusb-1_0-0": null, + "libutempter0": null, + "libuuid1": null, + "libverto1": null, + "libxml2-2": null, + "libyaml-cpp0_6": null, + "libz1": null, + "libzio1": null, + "libzstd1": null, + "libzypp": [ + "usr/bin/zypp-CheckAccessDeleted", + "usr/bin/zypp-NameReqPrv" + ], + "login_defs": null, + "ncurses-utils": [ + "usr/bin/clear", + "usr/bin/infocmp", + "usr/bin/reset", + "usr/bin/tabs", + "usr/bin/toe", + "usr/bin/tput", + "usr/bin/tset" + ], + "netcfg": null, + "openssl-1_1": [ + "usr/bin/c_rehash", + "usr/bin/fips_standalone_hmac", + "usr/bin/openssl" + ], + "p11-kit": null, + "p11-kit-tools": [ + "usr/bin/p11-kit", + "usr/bin/trust" + ], + "pam": null, + "patterns-base-fips": null, + "perl-base": [ + "usr/bin/perl", + "usr/bin/perl5.26.1" + ], + "permissions": [ + "usr/bin/chkstat" + ], + "pinentry": [ + "usr/bin/pinentry", + "usr/bin/pinentry-curses", + "usr/bin/pinentry-tty" + ], + "procps": [ + "usr/bin/free", + "usr/bin/pgrep", + "usr/bin/pkill", + "usr/bin/pmap", + "usr/bin/ps", + "usr/bin/pwdx", + "usr/bin/skill", + "usr/bin/slabtop", + "usr/bin/snice", + "usr/bin/tload", + "usr/bin/top", + "usr/bin/vmstat", + "usr/bin/w", + "usr/bin/watch" + ], + "rpm-config-SUSE": null, + "rpm-ndb": [ + "usr/bin/gendiff", + "usr/bin/rpm", + "usr/bin/rpm2cpio", + "usr/bin/rpmdb", + "usr/bin/rpmgraph", + "usr/bin/rpmkeys", + "usr/bin/rpmqpack", + "usr/bin/rpmquery", + "usr/bin/rpmsign", + "usr/bin/rpmspec", + "usr/bin/rpmverify" + ], + "sed": [ + "usr/bin/sed" + ], + "shadow": [ + "usr/bin/chage", + "usr/bin/chfn", + "usr/bin/chsh", + "usr/bin/expiry", + "usr/bin/gpasswd", + "usr/bin/lastlog", + "usr/bin/newgidmap", + "usr/bin/newgrp", + "usr/bin/newuidmap", + "usr/bin/passwd", + "usr/bin/sg" + ], + "skelcd-EULA-bci": null, + "sles-release": null, + "suse-build-key": null, + "system-group-hardware": null, + "system-user-root": null, + "sysuser-shadow": null, + "terminfo-base": null, + "timezone": [ + "usr/bin/tzselect" + ], + "util-linux": [ + "usr/bin/cal", + "usr/bin/chmem", + "usr/bin/choom", + "usr/bin/chrt", + "usr/bin/col", + "usr/bin/colcrt", + "usr/bin/colrm", + "usr/bin/column", + "usr/bin/dmesg", + "usr/bin/eject", + "usr/bin/fallocate", + "usr/bin/fincore", + "usr/bin/flock", + "usr/bin/getopt", + "usr/bin/hardlink", + "usr/bin/hexdump", + "usr/bin/i386", + "usr/bin/ionice", + "usr/bin/ipcmk", + "usr/bin/ipcrm", + "usr/bin/ipcs", + "usr/bin/irqtop", + "usr/bin/isosize", + "usr/bin/kill", + "usr/bin/last", + "usr/bin/lastb", + "usr/bin/line", + "usr/bin/linux32", + "usr/bin/linux64", + "usr/bin/look", + "usr/bin/lscpu", + "usr/bin/lsipc", + "usr/bin/lsirq", + "usr/bin/lslocks", + "usr/bin/lsmem", + "usr/bin/lsns", + "usr/bin/mcookie", + "usr/bin/mesg", + "usr/bin/more", + "usr/bin/mount", + "usr/bin/mountpoint", + "usr/bin/namei", + "usr/bin/nsenter", + "usr/bin/prlimit", + "usr/bin/rename", + "usr/bin/renice", + "usr/bin/rev", + "usr/bin/script", + "usr/bin/scriptlive", + "usr/bin/scriptreplay", + "usr/bin/setarch", + "usr/bin/setpriv", + "usr/bin/setsid", + "usr/bin/setterm", + "usr/bin/su", + "usr/bin/taskset", + "usr/bin/uclampset", + "usr/bin/ul", + "usr/bin/umount", + "usr/bin/uname26", + "usr/bin/unshare", + "usr/bin/utmpdump", + "usr/bin/uuidgen", + "usr/bin/uuidparse", + "usr/bin/wall", + "usr/bin/wdctl", + "usr/bin/whereis", + "usr/bin/write", + "usr/bin/x86_64" + ], + "zypper": [ + "usr/bin/installation_sources", + "usr/bin/yzpper", + "usr/bin/zypper" + ] +} diff --git a/rpm/testdata/Info.Files.SQLite.txtar b/rpm/testdata/Info.Files.SQLite.txtar new file mode 100644 index 000000000..796303325 --- /dev/null +++ b/rpm/testdata/Info.Files.SQLite.txtar @@ -0,0 +1,314 @@ +sqlite/testdata/rpmdb.sqlite +-- want.json -- +{ + "alternatives": null, + "audit-libs": null, + "basesystem": null, + "bash": [ + "usr/bin/alias", + "usr/bin/bash", + "usr/bin/bashbug", + "usr/bin/bashbug-64", + "usr/bin/bg", + "usr/bin/cd", + "usr/bin/command", + "usr/bin/fc", + "usr/bin/fg", + "usr/bin/getopts", + "usr/bin/hash", + "usr/bin/jobs", + "usr/bin/read", + "usr/bin/sh", + "usr/bin/type", + "usr/bin/ulimit", + "usr/bin/umask", + "usr/bin/unalias", + "usr/bin/wait" + ], + "bzip2-libs": null, + "ca-certificates": [ + "usr/bin/ca-legacy", + "usr/bin/update-ca-trust" + ], + "coreutils": [ + "usr/bin/[", + "usr/bin/arch", + "usr/bin/b2sum", + "usr/bin/base32", + "usr/bin/base64", + "usr/bin/basename", + "usr/bin/basenc", + "usr/bin/cat", + "usr/bin/chcon", + "usr/bin/chgrp", + "usr/bin/chmod", + "usr/bin/chown", + "usr/bin/cksum", + "usr/bin/comm", + "usr/bin/cp", + "usr/bin/csplit", + "usr/bin/cut", + "usr/bin/date", + "usr/bin/dd", + "usr/bin/df", + "usr/bin/dir", + "usr/bin/dircolors", + "usr/bin/dirname", + "usr/bin/du", + "usr/bin/echo", + "usr/bin/env", + "usr/bin/expand", + "usr/bin/expr", + "usr/bin/factor", + "usr/bin/false", + "usr/bin/fmt", + "usr/bin/fold", + "usr/bin/groups", + "usr/bin/head", + "usr/bin/hostid", + "usr/bin/id", + "usr/bin/install", + "usr/bin/join", + "usr/bin/link", + "usr/bin/ln", + "usr/bin/logname", + "usr/bin/ls", + "usr/bin/md5sum", + "usr/bin/mkdir", + "usr/bin/mkfifo", + "usr/bin/mknod", + "usr/bin/mktemp", + "usr/bin/mv", + "usr/bin/nice", + "usr/bin/nl", + "usr/bin/nohup", + "usr/bin/nproc", + "usr/bin/numfmt", + "usr/bin/od", + "usr/bin/paste", + "usr/bin/pathchk", + "usr/bin/pinky", + "usr/bin/pr", + "usr/bin/printenv", + "usr/bin/printf", + "usr/bin/ptx", + "usr/bin/pwd", + "usr/bin/readlink", + "usr/bin/realpath", + "usr/bin/rm", + "usr/bin/rmdir", + "usr/bin/runcon", + "usr/bin/seq", + "usr/bin/sha1sum", + "usr/bin/sha224sum", + "usr/bin/sha256sum", + "usr/bin/sha384sum", + "usr/bin/sha512sum", + "usr/bin/shred", + "usr/bin/shuf", + "usr/bin/sleep", + "usr/bin/sort", + "usr/bin/split", + "usr/bin/stat", + "usr/bin/stdbuf", + "usr/bin/stty", + "usr/bin/sum", + "usr/bin/sync", + "usr/bin/tac", + "usr/bin/tail", + "usr/bin/tee", + "usr/bin/test", + "usr/bin/timeout", + "usr/bin/touch", + "usr/bin/tr", + "usr/bin/true", + "usr/bin/truncate", + "usr/bin/tsort", + "usr/bin/tty", + "usr/bin/uname", + "usr/bin/unexpand", + "usr/bin/uniq", + "usr/bin/unlink", + "usr/bin/users", + "usr/bin/vdir", + "usr/bin/wc", + "usr/bin/who", + "usr/bin/whoami", + "usr/bin/yes" + ], + "coreutils-common": null, + "crypto-policies": null, + "curl": [ + "usr/bin/curl" + ], + "cyrus-sasl-lib": [ + "usr/bin/cyrusbdb2current" + ], + "dejavu-sans-fonts": null, + "dnf-data": null, + "fedora-gpg-keys": null, + "fedora-release-common": null, + "fedora-release-container": null, + "fedora-release-identity-container": null, + "fedora-repos": null, + "file-libs": null, + "filesystem": null, + "fonts-filesystem": null, + "gawk": [ + "usr/bin/awk", + "usr/bin/gawk" + ], + "gdbm-libs": null, + "glib2": [ + "usr/bin/gapplication", + "usr/bin/gdbus", + "usr/bin/gio", + "usr/bin/gio-querymodules-64", + "usr/bin/glib-compile-schemas", + "usr/bin/gsettings" + ], + "glibc": null, + "glibc-common": [ + "usr/bin/catchsegv", + "usr/bin/gencat", + "usr/bin/getconf", + "usr/bin/getent", + "usr/bin/iconv", + "usr/bin/ld.so", + "usr/bin/ldd", + "usr/bin/locale", + "usr/bin/localedef", + "usr/bin/pldd", + "usr/bin/sotruss", + "usr/bin/sprof", + "usr/bin/tzselect", + "usr/bin/zdump" + ], + "glibc-minimal-langpack": null, + "gmp": null, + "gnupg2": [ + "usr/bin/dirmngr", + "usr/bin/dirmngr-client", + "usr/bin/g13", + "usr/bin/gpg", + "usr/bin/gpg-agent", + "usr/bin/gpg-card", + "usr/bin/gpg-connect-agent", + "usr/bin/gpg-wks-client", + "usr/bin/gpg-wks-server", + "usr/bin/gpg2", + "usr/bin/gpgconf", + "usr/bin/gpgparsemail", + "usr/bin/gpgsplit", + "usr/bin/gpgtar", + "usr/bin/gpgv", + "usr/bin/gpgv2", + "usr/bin/watchgnupg" + ], + "gnutls": null, + "gobject-introspection": null, + "gpgme": [ + "usr/bin/gpgme-json" + ], + "grep": [ + "usr/bin/egrep", + "usr/bin/fgrep", + "usr/bin/grep" + ], + "json-c": null, + "keyutils-libs": null, + "krb5-libs": null, + "langpacks-core-en": null, + "langpacks-core-font-en": null, + "langpacks-en": null, + "libacl": null, + "libarchive": null, + "libassuan": null, + "libattr": null, + "libblkid": null, + "libbrotli": null, + "libcap": null, + "libcap-ng": null, + "libcom_err": null, + "libcurl": null, + "libdnf": null, + "libffi": null, + "libgcc": null, + "libgcrypt": null, + "libgpg-error": [ + "usr/bin/gpg-error" + ], + "libidn2": null, + "libksba": null, + "libmodulemd": [ + "usr/bin/modulemd-validator" + ], + "libmount": null, + "libnghttp2": null, + "libpeas": null, + "libpsl": null, + "librepo": null, + "libreport-filesystem": null, + "libselinux": null, + "libsepol": null, + "libsigsegv": null, + "libsmartcols": null, + "libsolv": null, + "libssh": null, + "libssh-config": null, + "libstdc++": null, + "libtasn1": null, + "libunistring": null, + "libuuid": null, + "libverto": null, + "libxcrypt": null, + "libxml2": [ + "usr/bin/xmlcatalog", + "usr/bin/xmllint" + ], + "libyaml": null, + "libzstd": null, + "lua-libs": null, + "lz4-libs": null, + "microdnf": [ + "usr/bin/microdnf" + ], + "mpfr": null, + "ncurses-base": null, + "ncurses-libs": null, + "nettle": null, + "npth": null, + "openldap": null, + "openssl-libs": null, + "p11-kit": [ + "usr/bin/p11-kit" + ], + "p11-kit-trust": [ + "usr/bin/trust" + ], + "pcre": null, + "pcre2": null, + "pcre2-syntax": null, + "popt": null, + "publicsuffix-list-dafsa": null, + "readline": null, + "rpm": [ + "usr/bin/rpm", + "usr/bin/rpm2archive", + "usr/bin/rpm2cpio", + "usr/bin/rpmdb", + "usr/bin/rpmkeys", + "usr/bin/rpmquery", + "usr/bin/rpmverify" + ], + "rpm-libs": null, + "sed": [ + "usr/bin/sed" + ], + "setup": null, + "sqlite-libs": null, + "tzdata": null, + "xz-libs": null, + "zchunk-libs": null, + "zlib": null +}