Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

Commit

Permalink
Also detect RPM databases in NDB format (#341)
Browse files Browse the repository at this point in the history
RPM databases in the native DB format rather than the traditional
Berkeley DB format are stored as different filenames, so detect
those as well.
  • Loading branch information
dirkmueller authored Dec 19, 2021
1 parent 78ffd90 commit 4d222c8
Show file tree
Hide file tree
Showing 5 changed files with 1,644 additions and 3 deletions.
2 changes: 2 additions & 0 deletions analyzer/pkg/rpm/rpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ func init() {
const version = 1

var requiredFiles = []string{
"usr/lib/sysimage/rpm/Packages.db",
"usr/lib/sysimage/rpm/Packages",
"var/lib/rpm/Packages.db",
"var/lib/rpm/Packages",
}
var errUnexpectedNameFormat = xerrors.New("unexpected name format")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
github.com/hashicorp/hcl v1.0.0
github.com/knqyf263/go-apk-version v0.0.0-20200609155635-041fdbb8563f
github.com/knqyf263/go-deb-version v0.0.0-20190517075300-09fca494f03d
github.com/knqyf263/go-rpmdb v0.0.0-20210911072402-73bd0ce46c49
github.com/knqyf263/go-rpmdb v0.0.0-20211216113947-1369b2ee40b7
github.com/knqyf263/nested v0.0.1
github.com/kylelemons/godebug v1.1.0
github.com/mitchellh/mapstructure v1.4.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -867,8 +867,8 @@ github.com/knqyf263/go-apk-version v0.0.0-20200609155635-041fdbb8563f h1:GvCU5GX
github.com/knqyf263/go-apk-version v0.0.0-20200609155635-041fdbb8563f/go.mod h1:q59u9px8b7UTj0nIjEjvmTWekazka6xIt6Uogz5Dm+8=
github.com/knqyf263/go-deb-version v0.0.0-20190517075300-09fca494f03d h1:X4cedH4Kn3JPupAwwWuo4AzYp16P0OyLO9d7OnMZc/c=
github.com/knqyf263/go-deb-version v0.0.0-20190517075300-09fca494f03d/go.mod h1:o8sgWoz3JADecfc/cTYD92/Et1yMqMy0utV1z+VaZao=
github.com/knqyf263/go-rpmdb v0.0.0-20210911072402-73bd0ce46c49 h1:QazJZdFn/ApQh8OHepQiCKXGZ0QE08Bu8BnS10aHgvE=
github.com/knqyf263/go-rpmdb v0.0.0-20210911072402-73bd0ce46c49/go.mod h1:RDPNeIkU5NWXtt0OMEoILyxwUC/DyXeRtK295wpqSi0=
github.com/knqyf263/go-rpmdb v0.0.0-20211216113947-1369b2ee40b7 h1:xVowqxH8FU6XAG1YIIjeWiUlbDh9ZQZWpk5pz6IcxEU=
github.com/knqyf263/go-rpmdb v0.0.0-20211216113947-1369b2ee40b7/go.mod h1:RDPNeIkU5NWXtt0OMEoILyxwUC/DyXeRtK295wpqSi0=
github.com/knqyf263/nested v0.0.1 h1:Sv26CegUMhjt19zqbBKntjwESdxe5hxVPSk0+AKjdUc=
github.com/knqyf263/nested v0.0.1/go.mod h1:zwhsIhMkBg90DTOJQvxPkKIypEHPYkgWHs4gybdlUmk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
Expand Down
8 changes: 8 additions & 0 deletions test/integration/library_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ var testCases = []testCase{
imageFile: "testdata/fixtures/opensuse-leap-151.tar.gz",
wantOS: types.OS{Name: "15.1", Family: "opensuse.leap"},
},
{
// from registry.suse.com/suse/sle15:15.3.17.8.16
name: "happy path, suse 15.3 (NDB)",
imageName: "suse/sle15:15.3.17.8.16",
remoteImageName: "knqyf263/suse-sle15:15.3.17.8.16",
imageFile: "testdata/fixtures/suse-15.3_ndb.tar.gz",
wantOS: types.OS{Name: "15.3", Family: "suse linux enterprise server"},
},
{
name: "happy path, vulnimage with lock files",
imageName: "knqyf263/vuln-image:1.2.3",
Expand Down
Loading

0 comments on commit 4d222c8

Please sign in to comment.