diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 6882f88..8e22111 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,2 +1,3 @@ # Global -* @gitworkflows +* @knqyf263 +* @sulaiman-coder diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index 6d0f40d..4c227dc 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -6,7 +6,7 @@ on: workflow_dispatch: env: REPO_OWNER: ${{ github.repository_owner }} # used in 'make db-build' - GH_USER: khulnasoft-lab + GH_USER: khulnasoft-bot VERSION: 2 jobs: build: diff --git a/.gitignore b/.gitignore index 82fe6fe..f27c4ca 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,4 @@ assets cache # vul-db Outputs -vul-db \ No newline at end of file +vul-db diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..8a411ee --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,40 @@ +run: + go: '1.19' + timeout: 5m + skip-dirs: + - cache + - assets +linters: + enable: + - gofmt + - bodyclose + - staticcheck + - unused + - gci + - gomodguard + - tenv + - gosimple + - govet + disable: + - errcheck + - ineffassign + - structcheck +linters-settings: + gci: + sections: + - standard + - default + - prefix(github.com/khulnasoft-lab/) + - blank + - dot + gomodguard: + blocked: + modules: + - github.com/hashicorp/go-version: + recommendations: + - github.com/khulnasoft-lab/goversion + reason: "`khulnasoft-lab/goversion` is degisned for our use-cases" + - github.com/Masterminds/semver: + recommendations: + - github.com/khulnasoft-lab/goversion + reason: "`khulnasoft-lab/goversion` is degisned for our use-cases" diff --git a/NOTICE b/NOTICE index 6e69788..c747c41 100644 --- a/NOTICE +++ b/NOTICE @@ -1,4 +1,4 @@ -Vul-db -Copyright 2019-2020 Khulnasoft Security Software Ltd. +vul-db +Copyright 2019-2020 KhulnaSoft Security Software Ltd. -This product includes software developed by Khulnasoft Security (https://khulnasoft.com). +This product includes software developed by KhulnaSoft Security (https://khulnasoft.com). diff --git a/go.mod b/go.mod index db553f2..9c6ebe5 100644 --- a/go.mod +++ b/go.mod @@ -6,28 +6,27 @@ require ( github.com/briandowns/spinner v1.23.0 github.com/fatih/color v1.10.0 // indirect github.com/goark/go-cvss v1.6.6 - github.com/khulnasoft-lab/boltdb-fixtures v1.0.0 - github.com/khulnasoft-lab/go-deb-version v0.0.0-20231106220903-cfc740a3d549 - github.com/khulnasoft-lab/go-gem-version v1.0.0 - github.com/khulnasoft-lab/go-npm-version v1.0.0 - github.com/khulnasoft-lab/go-pep440-version v1.0.0 - github.com/khulnasoft-lab/go-rpm-version v0.0.0-20231106221046-93d7f23756b1 - github.com/khulnasoft-lab/goversion v1.0.1 github.com/masahiro331/go-mvn-version v0.0.0-20210429150710-d3157d602a08 github.com/samber/lo v1.38.1 github.com/stretchr/testify v1.8.4 + github.com/urfave/cli v1.22.14 go.etcd.io/bbolt v1.3.8 - golang.org/x/exp v0.0.0-20231006140011-7918f672742d - golang.org/x/text v0.14.0 - golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 - gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/utils v0.0.0-20230726121419-3b25d923346b + golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 + golang.org/x/text v0.13.0 + golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 + gopkg.in/cheggaaa/pb.v1 v1.0.28 + gopkg.in/yaml.v2 v2.4.0 + k8s.io/utils v0.0.0-20201110183641-67b214c5f920 ) require ( - github.com/urfave/cli v1.22.14 - gopkg.in/cheggaaa/pb.v1 v1.0.28 - gopkg.in/yaml.v2 v2.4.0 + github.com/khulnasoft-lab/boltdb-fixtures v1.0.0 + github.com/khulnasoft-lab/go-deb-version v0.0.0-20231106220903-cfc740a3d549 + github.com/khulnasoft-lab/go-gem-version v1.0.0 + github.com/khulnasoft-lab/go-npm-version v1.0.0 + github.com/khulnasoft-lab/go-pep440-version v1.0.0 + github.com/khulnasoft-lab/go-rpm-version v0.0.0-20231106221046-93d7f23756b1 + github.com/khulnasoft-lab/goversion v1.0.1 ) require ( @@ -43,9 +42,10 @@ require ( github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/stretchr/objx v0.5.0 // indirect go.uber.org/multierr v1.10.0 // indirect - golang.org/x/sys v0.13.0 // indirect + golang.org/x/sys v0.11.0 // indirect golang.org/x/term v0.1.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) require ( diff --git a/go.sum b/go.sum index 2c808a5..ac2e4c7 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg= github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= +github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE= @@ -56,10 +57,12 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/samber/lo v1.38.1 h1:j2XEAqXKb09Am4ebOg31SpvzUTTs6EN3VfgeLUhPdXM= github.com/samber/lo v1.38.1/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA= +github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -77,20 +80,20 @@ go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN8 go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= -golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= -golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= +golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc= +golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.1.0 h1:g6Z6vPFA9dYBAF7DWcH6sCcOntplXsDKcliusYijMlw= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU= -golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= @@ -101,5 +104,6 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= -k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= +k8s.io/utils v0.0.0-20201110183641-67b214c5f920 h1:CbnUZsM497iRC5QMVkHwyl8s2tB3g7yaSHkYPkpgelw= +k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= diff --git a/pkg/dbtest/mock_bucketer.go b/pkg/dbtest/mock_bucketer.go deleted file mode 100644 index d8a925f..0000000 --- a/pkg/dbtest/mock_bucketer.go +++ /dev/null @@ -1,59 +0,0 @@ -// Code generated by mockery v1.0.0. DO NOT EDIT. - -package dbtest - -import ( - mock "github.com/stretchr/testify/mock" - bbolt "go.etcd.io/bbolt" -) - -// mockBucketer is an autogenerated mock type for the bucketer type -type mockBucketer struct { - mock.Mock -} - -type bucketerBucketArgs struct { - Name []byte - NameAnything bool -} - -type bucketerBucketReturns struct { - _a0 *bbolt.Bucket -} - -type bucketerBucketExpectation struct { - Args bucketerBucketArgs - Returns bucketerBucketReturns -} - -func (_m *mockBucketer) ApplyBucketExpectation(e bucketerBucketExpectation) { - var args []interface{} - if e.Args.NameAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Name) - } - _m.On("Bucket", args...).Return(e.Returns._a0) -} - -func (_m *mockBucketer) ApplyBucketExpectations(expectations []bucketerBucketExpectation) { - for _, e := range expectations { - _m.ApplyBucketExpectation(e) - } -} - -// Bucket provides a mock function with given fields: name -func (_m *mockBucketer) Bucket(name []byte) *bbolt.Bucket { - ret := _m.Called(name) - - var r0 *bbolt.Bucket - if rf, ok := ret.Get(0).(func([]byte) *bbolt.Bucket); ok { - r0 = rf(name) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*bbolt.Bucket) - } - } - - return r0 -} diff --git a/pkg/vulndb/mock_vuln_db.go b/pkg/vulndb/mock_vuln_db.go deleted file mode 100644 index 072e4e3..0000000 --- a/pkg/vulndb/mock_vuln_db.go +++ /dev/null @@ -1,54 +0,0 @@ -// Code generated by mockery v1.0.0. DO NOT EDIT. - -package vulndb - -import mock "github.com/stretchr/testify/mock" - -// MockVulnDB is an autogenerated mock type for the VulnDB type -type MockVulnDB struct { - mock.Mock -} - -type VulnDBBuildArgs struct { - Targets []string - TargetsAnything bool -} - -type VulnDBBuildReturns struct { - _a0 error -} - -type VulnDBBuildExpectation struct { - Args VulnDBBuildArgs - Returns VulnDBBuildReturns -} - -func (_m *MockVulnDB) ApplyBuildExpectation(e VulnDBBuildExpectation) { - var args []interface{} - if e.Args.TargetsAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Targets) - } - _m.On("Build", args...).Return(e.Returns._a0) -} - -func (_m *MockVulnDB) ApplyBuildExpectations(expectations []VulnDBBuildExpectation) { - for _, e := range expectations { - _m.ApplyBuildExpectation(e) - } -} - -// Build provides a mock function with given fields: targets -func (_m *MockVulnDB) Build(targets []string) error { - ret := _m.Called(targets) - - var r0 error - if rf, ok := ret.Get(0).(func([]string) error); ok { - r0 = rf(targets) - } else { - r0 = ret.Error(0) - } - - return r0 -} diff --git a/pkg/vulnsrc/alma/mock_db.go b/pkg/vulnsrc/alma/mock_db.go deleted file mode 100644 index 0748ae4..0000000 --- a/pkg/vulnsrc/alma/mock_db.go +++ /dev/null @@ -1,1147 +0,0 @@ -// Code generated by mockery v1.0.0. DO NOT EDIT. - -package alma - -import ( - db "github.com/khulnasoft-lab/vul-db/pkg/db" - mock "github.com/stretchr/testify/mock" - bbolt "go.etcd.io/bbolt" - - types "github.com/khulnasoft-lab/vul-db/pkg/types" -) - -// MockDB is an autogenerated mock type for the DB type -type MockDB struct { - mock.Mock -} - -type DBBatchUpdateArgs struct { - Fn func(*bbolt.Tx) error - FnAnything bool -} - -type DBBatchUpdateReturns struct { - Err error -} - -type DBBatchUpdateExpectation struct { - Args DBBatchUpdateArgs - Returns DBBatchUpdateReturns -} - -func (_m *MockDB) ApplyBatchUpdateExpectation(e DBBatchUpdateExpectation) { - var args []interface{} - if e.Args.FnAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Fn) - } - _m.On("BatchUpdate", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyBatchUpdateExpectations(expectations []DBBatchUpdateExpectation) { - for _, e := range expectations { - _m.ApplyBatchUpdateExpectation(e) - } -} - -// BatchUpdate provides a mock function with given fields: fn -func (_m *MockDB) BatchUpdate(fn func(*bbolt.Tx) error) error { - ret := _m.Called(fn) - - var r0 error - if rf, ok := ret.Get(0).(func(func(*bbolt.Tx) error) error); ok { - r0 = rf(fn) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBDeleteAdvisoryDetailBucketReturns struct { - _a0 error -} - -type DBDeleteAdvisoryDetailBucketExpectation struct { - Returns DBDeleteAdvisoryDetailBucketReturns -} - -func (_m *MockDB) ApplyDeleteAdvisoryDetailBucketExpectation(e DBDeleteAdvisoryDetailBucketExpectation) { - var args []interface{} - _m.On("DeleteAdvisoryDetailBucket", args...).Return(e.Returns._a0) -} - -func (_m *MockDB) ApplyDeleteAdvisoryDetailBucketExpectations(expectations []DBDeleteAdvisoryDetailBucketExpectation) { - for _, e := range expectations { - _m.ApplyDeleteAdvisoryDetailBucketExpectation(e) - } -} - -// DeleteAdvisoryDetailBucket provides a mock function with given fields: -func (_m *MockDB) DeleteAdvisoryDetailBucket() error { - ret := _m.Called() - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBDeleteVulnerabilityDetailBucketReturns struct { - Err error -} - -type DBDeleteVulnerabilityDetailBucketExpectation struct { - Returns DBDeleteVulnerabilityDetailBucketReturns -} - -func (_m *MockDB) ApplyDeleteVulnerabilityDetailBucketExpectation(e DBDeleteVulnerabilityDetailBucketExpectation) { - var args []interface{} - _m.On("DeleteVulnerabilityDetailBucket", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyDeleteVulnerabilityDetailBucketExpectations(expectations []DBDeleteVulnerabilityDetailBucketExpectation) { - for _, e := range expectations { - _m.ApplyDeleteVulnerabilityDetailBucketExpectation(e) - } -} - -// DeleteVulnerabilityDetailBucket provides a mock function with given fields: -func (_m *MockDB) DeleteVulnerabilityDetailBucket() error { - ret := _m.Called() - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBForEachAdvisoryArgs struct { - Sources []string - SourcesAnything bool - PkgName string - PkgNameAnything bool -} - -type DBForEachAdvisoryReturns struct { - Value map[string]db.Value - Err error -} - -type DBForEachAdvisoryExpectation struct { - Args DBForEachAdvisoryArgs - Returns DBForEachAdvisoryReturns -} - -func (_m *MockDB) ApplyForEachAdvisoryExpectation(e DBForEachAdvisoryExpectation) { - var args []interface{} - if e.Args.SourcesAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Sources) - } - if e.Args.PkgNameAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.PkgName) - } - _m.On("ForEachAdvisory", args...).Return(e.Returns.Value, e.Returns.Err) -} - -func (_m *MockDB) ApplyForEachAdvisoryExpectations(expectations []DBForEachAdvisoryExpectation) { - for _, e := range expectations { - _m.ApplyForEachAdvisoryExpectation(e) - } -} - -// ForEachAdvisory provides a mock function with given fields: sources, pkgName -func (_m *MockDB) ForEachAdvisory(sources []string, pkgName string) (map[string]db.Value, error) { - ret := _m.Called(sources, pkgName) - - var r0 map[string]db.Value - if rf, ok := ret.Get(0).(func([]string, string) map[string]db.Value); ok { - r0 = rf(sources, pkgName) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(map[string]db.Value) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func([]string, string) error); ok { - r1 = rf(sources, pkgName) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type DBForEachVulnerabilityIDArgs struct { - Fn func(*bbolt.Tx, string) error - FnAnything bool -} - -type DBForEachVulnerabilityIDReturns struct { - Err error -} - -type DBForEachVulnerabilityIDExpectation struct { - Args DBForEachVulnerabilityIDArgs - Returns DBForEachVulnerabilityIDReturns -} - -func (_m *MockDB) ApplyForEachVulnerabilityIDExpectation(e DBForEachVulnerabilityIDExpectation) { - var args []interface{} - if e.Args.FnAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Fn) - } - _m.On("ForEachVulnerabilityID", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyForEachVulnerabilityIDExpectations(expectations []DBForEachVulnerabilityIDExpectation) { - for _, e := range expectations { - _m.ApplyForEachVulnerabilityIDExpectation(e) - } -} - -// ForEachVulnerabilityID provides a mock function with given fields: fn -func (_m *MockDB) ForEachVulnerabilityID(fn func(*bbolt.Tx, string) error) error { - ret := _m.Called(fn) - - var r0 error - if rf, ok := ret.Get(0).(func(func(*bbolt.Tx, string) error) error); ok { - r0 = rf(fn) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBGetArgs struct { - Release string - ReleaseAnything bool - PkgName string - PkgNameAnything bool -} - -type DBGetReturns struct { - _a0 []types.Advisory - _a1 error -} - -type DBGetExpectation struct { - Args DBGetArgs - Returns DBGetReturns -} - -func (_m *MockDB) ApplyGetExpectation(e DBGetExpectation) { - var args []interface{} - if e.Args.ReleaseAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Release) - } - if e.Args.PkgNameAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.PkgName) - } - _m.On("Get", args...).Return(e.Returns._a0, e.Returns._a1) -} - -func (_m *MockDB) ApplyGetExpectations(expectations []DBGetExpectation) { - for _, e := range expectations { - _m.ApplyGetExpectation(e) - } -} - -// Get provides a mock function with given fields: release, pkgName -func (_m *MockDB) Get(release string, pkgName string) ([]types.Advisory, error) { - ret := _m.Called(release, pkgName) - - var r0 []types.Advisory - if rf, ok := ret.Get(0).(func(string, string) []types.Advisory); ok { - r0 = rf(release, pkgName) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.Advisory) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(string, string) error); ok { - r1 = rf(release, pkgName) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type DBGetAdvisoriesArgs struct { - Source string - SourceAnything bool - PkgName string - PkgNameAnything bool -} - -type DBGetAdvisoriesReturns struct { - Advisories []types.Advisory - Err error -} - -type DBGetAdvisoriesExpectation struct { - Args DBGetAdvisoriesArgs - Returns DBGetAdvisoriesReturns -} - -func (_m *MockDB) ApplyGetAdvisoriesExpectation(e DBGetAdvisoriesExpectation) { - var args []interface{} - if e.Args.SourceAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Source) - } - if e.Args.PkgNameAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.PkgName) - } - _m.On("GetAdvisories", args...).Return(e.Returns.Advisories, e.Returns.Err) -} - -func (_m *MockDB) ApplyGetAdvisoriesExpectations(expectations []DBGetAdvisoriesExpectation) { - for _, e := range expectations { - _m.ApplyGetAdvisoriesExpectation(e) - } -} - -// GetAdvisories provides a mock function with given fields: source, pkgName -func (_m *MockDB) GetAdvisories(source string, pkgName string) ([]types.Advisory, error) { - ret := _m.Called(source, pkgName) - - var r0 []types.Advisory - if rf, ok := ret.Get(0).(func(string, string) []types.Advisory); ok { - r0 = rf(source, pkgName) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.Advisory) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(string, string) error); ok { - r1 = rf(source, pkgName) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type DBGetVulnerabilityArgs struct { - VulnerabilityID string - VulnerabilityIDAnything bool -} - -type DBGetVulnerabilityReturns struct { - Vulnerability types.Vulnerability - Err error -} - -type DBGetVulnerabilityExpectation struct { - Args DBGetVulnerabilityArgs - Returns DBGetVulnerabilityReturns -} - -func (_m *MockDB) ApplyGetVulnerabilityExpectation(e DBGetVulnerabilityExpectation) { - var args []interface{} - if e.Args.VulnerabilityIDAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.VulnerabilityID) - } - _m.On("GetVulnerability", args...).Return(e.Returns.Vulnerability, e.Returns.Err) -} - -func (_m *MockDB) ApplyGetVulnerabilityExpectations(expectations []DBGetVulnerabilityExpectation) { - for _, e := range expectations { - _m.ApplyGetVulnerabilityExpectation(e) - } -} - -// GetVulnerability provides a mock function with given fields: vulnerabilityID -func (_m *MockDB) GetVulnerability(vulnerabilityID string) (types.Vulnerability, error) { - ret := _m.Called(vulnerabilityID) - - var r0 types.Vulnerability - if rf, ok := ret.Get(0).(func(string) types.Vulnerability); ok { - r0 = rf(vulnerabilityID) - } else { - r0 = ret.Get(0).(types.Vulnerability) - } - - var r1 error - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(vulnerabilityID) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type DBGetVulnerabilityDetailArgs struct { - CveID string - CveIDAnything bool -} - -type DBGetVulnerabilityDetailReturns struct { - Detail map[types.SourceID]types.VulnerabilityDetail - Err error -} - -type DBGetVulnerabilityDetailExpectation struct { - Args DBGetVulnerabilityDetailArgs - Returns DBGetVulnerabilityDetailReturns -} - -func (_m *MockDB) ApplyGetVulnerabilityDetailExpectation(e DBGetVulnerabilityDetailExpectation) { - var args []interface{} - if e.Args.CveIDAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.CveID) - } - _m.On("GetVulnerabilityDetail", args...).Return(e.Returns.Detail, e.Returns.Err) -} - -func (_m *MockDB) ApplyGetVulnerabilityDetailExpectations(expectations []DBGetVulnerabilityDetailExpectation) { - for _, e := range expectations { - _m.ApplyGetVulnerabilityDetailExpectation(e) - } -} - -// GetVulnerabilityDetail provides a mock function with given fields: cveID -func (_m *MockDB) GetVulnerabilityDetail(cveID string) (map[types.SourceID]types.VulnerabilityDetail, error) { - ret := _m.Called(cveID) - - var r0 map[types.SourceID]types.VulnerabilityDetail - if rf, ok := ret.Get(0).(func(string) map[types.SourceID]types.VulnerabilityDetail); ok { - r0 = rf(cveID) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(map[types.SourceID]types.VulnerabilityDetail) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(cveID) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type DBPutArgs struct { - _a0 *bbolt.Tx - _a0Anything bool - _a1 PutInput - _a1Anything bool -} - -type DBPutReturns struct { - _a0 error -} - -type DBPutExpectation struct { - Args DBPutArgs - Returns DBPutReturns -} - -func (_m *MockDB) ApplyPutExpectation(e DBPutExpectation) { - var args []interface{} - if e.Args._a0Anything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args._a0) - } - if e.Args._a1Anything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args._a1) - } - _m.On("Put", args...).Return(e.Returns._a0) -} - -func (_m *MockDB) ApplyPutExpectations(expectations []DBPutExpectation) { - for _, e := range expectations { - _m.ApplyPutExpectation(e) - } -} - -// Put provides a mock function with given fields: _a0, _a1 -func (_m *MockDB) Put(_a0 *bbolt.Tx, _a1 PutInput) error { - ret := _m.Called(_a0, _a1) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, PutInput) error); ok { - r0 = rf(_a0, _a1) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBPutAdvisoryDetailArgs struct { - Tx *bbolt.Tx - TxAnything bool - VulnerabilityID string - VulnerabilityIDAnything bool - PkgName string - PkgNameAnything bool - NestedBktNames []string - NestedBktNamesAnything bool - Advisory interface{} - AdvisoryAnything bool -} - -type DBPutAdvisoryDetailReturns struct { - Err error -} - -type DBPutAdvisoryDetailExpectation struct { - Args DBPutAdvisoryDetailArgs - Returns DBPutAdvisoryDetailReturns -} - -func (_m *MockDB) ApplyPutAdvisoryDetailExpectation(e DBPutAdvisoryDetailExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.VulnerabilityIDAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.VulnerabilityID) - } - if e.Args.PkgNameAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.PkgName) - } - if e.Args.NestedBktNamesAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.NestedBktNames) - } - if e.Args.AdvisoryAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Advisory) - } - _m.On("PutAdvisoryDetail", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyPutAdvisoryDetailExpectations(expectations []DBPutAdvisoryDetailExpectation) { - for _, e := range expectations { - _m.ApplyPutAdvisoryDetailExpectation(e) - } -} - -// PutAdvisoryDetail provides a mock function with given fields: tx, vulnerabilityID, pkgName, nestedBktNames, advisory -func (_m *MockDB) PutAdvisoryDetail(tx *bbolt.Tx, vulnerabilityID string, pkgName string, nestedBktNames []string, advisory interface{}) error { - ret := _m.Called(tx, vulnerabilityID, pkgName, nestedBktNames, advisory) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, string, string, []string, interface{}) error); ok { - r0 = rf(tx, vulnerabilityID, pkgName, nestedBktNames, advisory) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBPutDataSourceArgs struct { - Tx *bbolt.Tx - TxAnything bool - BktName string - BktNameAnything bool - Source types.DataSource - SourceAnything bool -} - -type DBPutDataSourceReturns struct { - Err error -} - -type DBPutDataSourceExpectation struct { - Args DBPutDataSourceArgs - Returns DBPutDataSourceReturns -} - -func (_m *MockDB) ApplyPutDataSourceExpectation(e DBPutDataSourceExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.BktNameAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.BktName) - } - if e.Args.SourceAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Source) - } - _m.On("PutDataSource", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyPutDataSourceExpectations(expectations []DBPutDataSourceExpectation) { - for _, e := range expectations { - _m.ApplyPutDataSourceExpectation(e) - } -} - -// PutDataSource provides a mock function with given fields: tx, bktName, source -func (_m *MockDB) PutDataSource(tx *bbolt.Tx, bktName string, source types.DataSource) error { - ret := _m.Called(tx, bktName, source) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, string, types.DataSource) error); ok { - r0 = rf(tx, bktName, source) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBPutRedHatCPEsArgs struct { - Tx *bbolt.Tx - TxAnything bool - CpeIndex int - CpeIndexAnything bool - Cpe string - CpeAnything bool -} - -type DBPutRedHatCPEsReturns struct { - Err error -} - -type DBPutRedHatCPEsExpectation struct { - Args DBPutRedHatCPEsArgs - Returns DBPutRedHatCPEsReturns -} - -func (_m *MockDB) ApplyPutRedHatCPEsExpectation(e DBPutRedHatCPEsExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.CpeIndexAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.CpeIndex) - } - if e.Args.CpeAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Cpe) - } - _m.On("PutRedHatCPEs", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyPutRedHatCPEsExpectations(expectations []DBPutRedHatCPEsExpectation) { - for _, e := range expectations { - _m.ApplyPutRedHatCPEsExpectation(e) - } -} - -// PutRedHatCPEs provides a mock function with given fields: tx, cpeIndex, cpe -func (_m *MockDB) PutRedHatCPEs(tx *bbolt.Tx, cpeIndex int, cpe string) error { - ret := _m.Called(tx, cpeIndex, cpe) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, int, string) error); ok { - r0 = rf(tx, cpeIndex, cpe) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBPutRedHatNVRsArgs struct { - Tx *bbolt.Tx - TxAnything bool - Nvr string - NvrAnything bool - CpeIndices []int - CpeIndicesAnything bool -} - -type DBPutRedHatNVRsReturns struct { - Err error -} - -type DBPutRedHatNVRsExpectation struct { - Args DBPutRedHatNVRsArgs - Returns DBPutRedHatNVRsReturns -} - -func (_m *MockDB) ApplyPutRedHatNVRsExpectation(e DBPutRedHatNVRsExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.NvrAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Nvr) - } - if e.Args.CpeIndicesAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.CpeIndices) - } - _m.On("PutRedHatNVRs", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyPutRedHatNVRsExpectations(expectations []DBPutRedHatNVRsExpectation) { - for _, e := range expectations { - _m.ApplyPutRedHatNVRsExpectation(e) - } -} - -// PutRedHatNVRs provides a mock function with given fields: tx, nvr, cpeIndices -func (_m *MockDB) PutRedHatNVRs(tx *bbolt.Tx, nvr string, cpeIndices []int) error { - ret := _m.Called(tx, nvr, cpeIndices) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, string, []int) error); ok { - r0 = rf(tx, nvr, cpeIndices) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBPutRedHatRepositoriesArgs struct { - Tx *bbolt.Tx - TxAnything bool - Repository string - RepositoryAnything bool - CpeIndices []int - CpeIndicesAnything bool -} - -type DBPutRedHatRepositoriesReturns struct { - Err error -} - -type DBPutRedHatRepositoriesExpectation struct { - Args DBPutRedHatRepositoriesArgs - Returns DBPutRedHatRepositoriesReturns -} - -func (_m *MockDB) ApplyPutRedHatRepositoriesExpectation(e DBPutRedHatRepositoriesExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.RepositoryAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Repository) - } - if e.Args.CpeIndicesAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.CpeIndices) - } - _m.On("PutRedHatRepositories", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyPutRedHatRepositoriesExpectations(expectations []DBPutRedHatRepositoriesExpectation) { - for _, e := range expectations { - _m.ApplyPutRedHatRepositoriesExpectation(e) - } -} - -// PutRedHatRepositories provides a mock function with given fields: tx, repository, cpeIndices -func (_m *MockDB) PutRedHatRepositories(tx *bbolt.Tx, repository string, cpeIndices []int) error { - ret := _m.Called(tx, repository, cpeIndices) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, string, []int) error); ok { - r0 = rf(tx, repository, cpeIndices) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBPutVulnerabilityArgs struct { - Tx *bbolt.Tx - TxAnything bool - VulnerabilityID string - VulnerabilityIDAnything bool - Vulnerability types.Vulnerability - VulnerabilityAnything bool -} - -type DBPutVulnerabilityReturns struct { - Err error -} - -type DBPutVulnerabilityExpectation struct { - Args DBPutVulnerabilityArgs - Returns DBPutVulnerabilityReturns -} - -func (_m *MockDB) ApplyPutVulnerabilityExpectation(e DBPutVulnerabilityExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.VulnerabilityIDAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.VulnerabilityID) - } - if e.Args.VulnerabilityAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Vulnerability) - } - _m.On("PutVulnerability", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyPutVulnerabilityExpectations(expectations []DBPutVulnerabilityExpectation) { - for _, e := range expectations { - _m.ApplyPutVulnerabilityExpectation(e) - } -} - -// PutVulnerability provides a mock function with given fields: tx, vulnerabilityID, vulnerability -func (_m *MockDB) PutVulnerability(tx *bbolt.Tx, vulnerabilityID string, vulnerability types.Vulnerability) error { - ret := _m.Called(tx, vulnerabilityID, vulnerability) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, string, types.Vulnerability) error); ok { - r0 = rf(tx, vulnerabilityID, vulnerability) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBPutVulnerabilityDetailArgs struct { - Tx *bbolt.Tx - TxAnything bool - VulnerabilityID string - VulnerabilityIDAnything bool - Source types.SourceID - SourceAnything bool - Vulnerability types.VulnerabilityDetail - VulnerabilityAnything bool -} - -type DBPutVulnerabilityDetailReturns struct { - Err error -} - -type DBPutVulnerabilityDetailExpectation struct { - Args DBPutVulnerabilityDetailArgs - Returns DBPutVulnerabilityDetailReturns -} - -func (_m *MockDB) ApplyPutVulnerabilityDetailExpectation(e DBPutVulnerabilityDetailExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.VulnerabilityIDAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.VulnerabilityID) - } - if e.Args.SourceAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Source) - } - if e.Args.VulnerabilityAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Vulnerability) - } - _m.On("PutVulnerabilityDetail", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyPutVulnerabilityDetailExpectations(expectations []DBPutVulnerabilityDetailExpectation) { - for _, e := range expectations { - _m.ApplyPutVulnerabilityDetailExpectation(e) - } -} - -// PutVulnerabilityDetail provides a mock function with given fields: tx, vulnerabilityID, source, vulnerability -func (_m *MockDB) PutVulnerabilityDetail(tx *bbolt.Tx, vulnerabilityID string, source types.SourceID, vulnerability types.VulnerabilityDetail) error { - ret := _m.Called(tx, vulnerabilityID, source, vulnerability) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, string, types.SourceID, types.VulnerabilityDetail) error); ok { - r0 = rf(tx, vulnerabilityID, source, vulnerability) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBPutVulnerabilityIDArgs struct { - Tx *bbolt.Tx - TxAnything bool - VulnerabilityID string - VulnerabilityIDAnything bool -} - -type DBPutVulnerabilityIDReturns struct { - Err error -} - -type DBPutVulnerabilityIDExpectation struct { - Args DBPutVulnerabilityIDArgs - Returns DBPutVulnerabilityIDReturns -} - -func (_m *MockDB) ApplyPutVulnerabilityIDExpectation(e DBPutVulnerabilityIDExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.VulnerabilityIDAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.VulnerabilityID) - } - _m.On("PutVulnerabilityID", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyPutVulnerabilityIDExpectations(expectations []DBPutVulnerabilityIDExpectation) { - for _, e := range expectations { - _m.ApplyPutVulnerabilityIDExpectation(e) - } -} - -// PutVulnerabilityID provides a mock function with given fields: tx, vulnerabilityID -func (_m *MockDB) PutVulnerabilityID(tx *bbolt.Tx, vulnerabilityID string) error { - ret := _m.Called(tx, vulnerabilityID) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, string) error); ok { - r0 = rf(tx, vulnerabilityID) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBRedHatNVRToCPEsArgs struct { - Nvr string - NvrAnything bool -} - -type DBRedHatNVRToCPEsReturns struct { - CpeIndices []int - Err error -} - -type DBRedHatNVRToCPEsExpectation struct { - Args DBRedHatNVRToCPEsArgs - Returns DBRedHatNVRToCPEsReturns -} - -func (_m *MockDB) ApplyRedHatNVRToCPEsExpectation(e DBRedHatNVRToCPEsExpectation) { - var args []interface{} - if e.Args.NvrAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Nvr) - } - _m.On("RedHatNVRToCPEs", args...).Return(e.Returns.CpeIndices, e.Returns.Err) -} - -func (_m *MockDB) ApplyRedHatNVRToCPEsExpectations(expectations []DBRedHatNVRToCPEsExpectation) { - for _, e := range expectations { - _m.ApplyRedHatNVRToCPEsExpectation(e) - } -} - -// RedHatNVRToCPEs provides a mock function with given fields: nvr -func (_m *MockDB) RedHatNVRToCPEs(nvr string) ([]int, error) { - ret := _m.Called(nvr) - - var r0 []int - if rf, ok := ret.Get(0).(func(string) []int); ok { - r0 = rf(nvr) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]int) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(nvr) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type DBRedHatRepoToCPEsArgs struct { - Repository string - RepositoryAnything bool -} - -type DBRedHatRepoToCPEsReturns struct { - CpeIndices []int - Err error -} - -type DBRedHatRepoToCPEsExpectation struct { - Args DBRedHatRepoToCPEsArgs - Returns DBRedHatRepoToCPEsReturns -} - -func (_m *MockDB) ApplyRedHatRepoToCPEsExpectation(e DBRedHatRepoToCPEsExpectation) { - var args []interface{} - if e.Args.RepositoryAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Repository) - } - _m.On("RedHatRepoToCPEs", args...).Return(e.Returns.CpeIndices, e.Returns.Err) -} - -func (_m *MockDB) ApplyRedHatRepoToCPEsExpectations(expectations []DBRedHatRepoToCPEsExpectation) { - for _, e := range expectations { - _m.ApplyRedHatRepoToCPEsExpectation(e) - } -} - -// RedHatRepoToCPEs provides a mock function with given fields: repository -func (_m *MockDB) RedHatRepoToCPEs(repository string) ([]int, error) { - ret := _m.Called(repository) - - var r0 []int - if rf, ok := ret.Get(0).(func(string) []int); ok { - r0 = rf(repository) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]int) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(repository) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type DBSaveAdvisoryDetailsArgs struct { - Tx *bbolt.Tx - TxAnything bool - CveID string - CveIDAnything bool -} - -type DBSaveAdvisoryDetailsReturns struct { - Err error -} - -type DBSaveAdvisoryDetailsExpectation struct { - Args DBSaveAdvisoryDetailsArgs - Returns DBSaveAdvisoryDetailsReturns -} - -func (_m *MockDB) ApplySaveAdvisoryDetailsExpectation(e DBSaveAdvisoryDetailsExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.CveIDAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.CveID) - } - _m.On("SaveAdvisoryDetails", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplySaveAdvisoryDetailsExpectations(expectations []DBSaveAdvisoryDetailsExpectation) { - for _, e := range expectations { - _m.ApplySaveAdvisoryDetailsExpectation(e) - } -} - -// SaveAdvisoryDetails provides a mock function with given fields: tx, cveID -func (_m *MockDB) SaveAdvisoryDetails(tx *bbolt.Tx, cveID string) error { - ret := _m.Called(tx, cveID) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, string) error); ok { - r0 = rf(tx, cveID) - } else { - r0 = ret.Error(0) - } - - return r0 -} diff --git a/pkg/vulnsrc/glad/glad.go b/pkg/vulnsrc/glad/glad.go index f33794f..e8d310b 100644 --- a/pkg/vulnsrc/glad/glad.go +++ b/pkg/vulnsrc/glad/glad.go @@ -25,7 +25,6 @@ const ( // cf. https://gitlab.com/gitlab-org/security-products/gemnasium-db/-/tree/e4176fff52c027165ae5a79f5b1193090e2fbef0#package-slug-and-package-name Conan packageType = "conan" - Maven packageType = "maven" ) var ( @@ -35,8 +34,8 @@ var ( "GMS", } + // Mapping between GLAD slug and Vul ecosystem ecosystems = map[packageType]types.Ecosystem{ - Maven: vulnerability.Maven, Conan: vulnerability.Conan, } @@ -124,11 +123,6 @@ func (vs VulnSrc) commit(tx *bolt.Tx, pkgType packageType, glads []Advisory) err } pkgName := ss[1] - if pkgType == Maven { - // e.g. "maven/batik/batik-transcoder" => "maven", "batik:batik-transcoder" - pkgName = strings.ReplaceAll(pkgName, "/", ":") - } - ecosystem, ok := ecosystems[pkgType] if !ok { return xerrors.Errorf("failed to get ecosystem: %s", pkgType) diff --git a/pkg/vulnsrc/glad/glad_test.go b/pkg/vulnsrc/glad/glad_test.go index c73cc3d..bad38cb 100644 --- a/pkg/vulnsrc/glad/glad_test.go +++ b/pkg/vulnsrc/glad/glad_test.go @@ -21,14 +21,6 @@ func TestVulnSrc_Update(t *testing.T) { name: "happy path", dir: filepath.Join("testdata", "happy"), wantValues: []vulnsrctest.WantValues{ - { - Key: []string{"data-source", "maven::GitLab Advisory Database Community"}, - Value: types.DataSource{ - ID: vulnerability.GLAD, - Name: "GitLab Advisory Database Community", - URL: "https://gitlab.com/gitlab-org/advisories-community", - }, - }, { Key: []string{"data-source", "conan::GitLab Advisory Database Community"}, Value: types.DataSource{ @@ -37,28 +29,12 @@ func TestVulnSrc_Update(t *testing.T) { URL: "https://gitlab.com/gitlab-org/advisories-community", }, }, - { - Key: []string{"advisory-detail", "CVE-2018-1196", "maven::GitLab Advisory Database Community", "org.springframework.boot:spring-boot"}, - Value: types.Advisory{ - PatchedVersions: []string{"1.5.10.RELEASE"}, - VulnerableVersions: []string{"(,1.5.10)"}, - }, - }, { Key: []string{"advisory-detail", "CVE-2020-13574", "conan::GitLab Advisory Database Community", "gsoap"}, Value: types.Advisory{ VulnerableVersions: []string{"=2.8.107"}, }, }, - { - Key: []string{"vulnerability-detail", "CVE-2018-1196", "glad"}, - Value: types.VulnerabilityDetail{ - ID: "CVE-2018-1196", - Title: "Symlink privilege escalation attack via Spring Boot launch script", - Description: "Spring Boot supports an embedded launch script that can be used to easily run the application as a systemd or init.d linux service. The script included with Spring Boot is susceptible to a symlink attack which allows the `run_user` to overwrite and take ownership of any file on the same system. In order to instigate the attack, the application must be installed as a service and the `run_user` requires shell access to the server.", - References: []string{"https://pivotal.io/security/cve-2018-1196"}, - }, - }, { Key: []string{"vulnerability-detail", "CVE-2020-13574", "glad"}, Value: types.VulnerabilityDetail{ diff --git a/pkg/vulnsrc/glad/testdata/happy/vuln-list/glad/maven/org.springframework.boot/spring-boot/CVE-2018-1196.json b/pkg/vulnsrc/glad/testdata/happy/vuln-list/glad/maven/org.springframework.boot/spring-boot/CVE-2018-1196.json deleted file mode 100644 index 761feb5..0000000 --- a/pkg/vulnsrc/glad/testdata/happy/vuln-list/glad/maven/org.springframework.boot/spring-boot/CVE-2018-1196.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "Identifier": "CVE-2018-1196", - "PackageSlug": "maven/org.springframework.boot/spring-boot", - "Title": "Symlink privilege escalation attack via Spring Boot launch script", - "Description": "Spring Boot supports an embedded launch script that can be used to easily run the application as a systemd or init.d linux service. The script included with Spring Boot is susceptible to a symlink attack which allows the `run_user` to overwrite and take ownership of any file on the same system. In order to instigate the attack, the application must be installed as a service and the `run_user` requires shell access to the server.", - "Date": "2018-04-20", - "Pubdate": "2018-03-19", - "AffectedRange": "(,1.5.10)", - "FixedVersions": [ - "1.5.10.RELEASE" - ], - "AffectedVersions": "All versions before 1.5.10", - "NotImpacted": "Spring Boot application that are not installed as a service, or are not using the embedded launch script are not susceptible.", - "Solution": "Upgrade to the latest version", - "Urls": [ - "https://pivotal.io/security/cve-2018-1196" - ], - "CvssV2": "AV:N/AC:M/Au:N/C:N/I:P/A:N", - "CvssV3": "CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N", - "UUID": "b6021cbc-1e37-41d4-80c2-d62d4aea3aec" -} \ No newline at end of file diff --git a/pkg/vulnsrc/glad/testdata/sad/vuln-list/glad/maven/org.springframework.boot/spring-boot/CVE-2018-1196.json b/pkg/vulnsrc/glad/testdata/sad/vuln-list/glad/conan/gsoap/CVE-2020-13574.json similarity index 100% rename from pkg/vulnsrc/glad/testdata/sad/vuln-list/glad/maven/org.springframework.boot/spring-boot/CVE-2018-1196.json rename to pkg/vulnsrc/glad/testdata/sad/vuln-list/glad/conan/gsoap/CVE-2020-13574.json diff --git a/pkg/vulnsrc/mock_vuln_src.go b/pkg/vulnsrc/mock_vuln_src.go deleted file mode 100644 index 3c80736..0000000 --- a/pkg/vulnsrc/mock_vuln_src.go +++ /dev/null @@ -1,90 +0,0 @@ -// Code generated by mockery v1.0.0. DO NOT EDIT. - -package vulnsrc - -import ( - types "github.com/khulnasoft-lab/vul-db/pkg/types" - mock "github.com/stretchr/testify/mock" -) - -// MockVulnSrc is an autogenerated mock type for the VulnSrc type -type MockVulnSrc struct { - mock.Mock -} - -type VulnSrcNameReturns struct { - _a0 types.SourceID -} - -type VulnSrcNameExpectation struct { - Returns VulnSrcNameReturns -} - -func (_m *MockVulnSrc) ApplyNameExpectation(e VulnSrcNameExpectation) { - var args []interface{} - _m.On("Name", args...).Return(e.Returns._a0) -} - -func (_m *MockVulnSrc) ApplyNameExpectations(expectations []VulnSrcNameExpectation) { - for _, e := range expectations { - _m.ApplyNameExpectation(e) - } -} - -// Name provides a mock function with given fields: -func (_m *MockVulnSrc) Name() types.SourceID { - ret := _m.Called() - - var r0 types.SourceID - if rf, ok := ret.Get(0).(func() types.SourceID); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(types.SourceID) - } - - return r0 -} - -type VulnSrcUpdateArgs struct { - Dir string - DirAnything bool -} - -type VulnSrcUpdateReturns struct { - Err error -} - -type VulnSrcUpdateExpectation struct { - Args VulnSrcUpdateArgs - Returns VulnSrcUpdateReturns -} - -func (_m *MockVulnSrc) ApplyUpdateExpectation(e VulnSrcUpdateExpectation) { - var args []interface{} - if e.Args.DirAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Dir) - } - _m.On("Update", args...).Return(e.Returns.Err) -} - -func (_m *MockVulnSrc) ApplyUpdateExpectations(expectations []VulnSrcUpdateExpectation) { - for _, e := range expectations { - _m.ApplyUpdateExpectation(e) - } -} - -// Update provides a mock function with given fields: dir -func (_m *MockVulnSrc) Update(dir string) error { - ret := _m.Called(dir) - - var r0 error - if rf, ok := ret.Get(0).(func(string) error); ok { - r0 = rf(dir) - } else { - r0 = ret.Error(0) - } - - return r0 -} diff --git a/pkg/vulnsrc/oracle-oval/mock_db.go b/pkg/vulnsrc/oracle-oval/mock_db.go deleted file mode 100644 index 179c5dc..0000000 --- a/pkg/vulnsrc/oracle-oval/mock_db.go +++ /dev/null @@ -1,1147 +0,0 @@ -// Code generated by mockery v1.0.0. DO NOT EDIT. - -package oracleoval - -import ( - db "github.com/khulnasoft-lab/vul-db/pkg/db" - mock "github.com/stretchr/testify/mock" - bbolt "go.etcd.io/bbolt" - - types "github.com/khulnasoft-lab/vul-db/pkg/types" -) - -// MockDB is an autogenerated mock type for the DB type -type MockDB struct { - mock.Mock -} - -type DBBatchUpdateArgs struct { - Fn func(*bbolt.Tx) error - FnAnything bool -} - -type DBBatchUpdateReturns struct { - Err error -} - -type DBBatchUpdateExpectation struct { - Args DBBatchUpdateArgs - Returns DBBatchUpdateReturns -} - -func (_m *MockDB) ApplyBatchUpdateExpectation(e DBBatchUpdateExpectation) { - var args []interface{} - if e.Args.FnAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Fn) - } - _m.On("BatchUpdate", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyBatchUpdateExpectations(expectations []DBBatchUpdateExpectation) { - for _, e := range expectations { - _m.ApplyBatchUpdateExpectation(e) - } -} - -// BatchUpdate provides a mock function with given fields: fn -func (_m *MockDB) BatchUpdate(fn func(*bbolt.Tx) error) error { - ret := _m.Called(fn) - - var r0 error - if rf, ok := ret.Get(0).(func(func(*bbolt.Tx) error) error); ok { - r0 = rf(fn) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBDeleteAdvisoryDetailBucketReturns struct { - _a0 error -} - -type DBDeleteAdvisoryDetailBucketExpectation struct { - Returns DBDeleteAdvisoryDetailBucketReturns -} - -func (_m *MockDB) ApplyDeleteAdvisoryDetailBucketExpectation(e DBDeleteAdvisoryDetailBucketExpectation) { - var args []interface{} - _m.On("DeleteAdvisoryDetailBucket", args...).Return(e.Returns._a0) -} - -func (_m *MockDB) ApplyDeleteAdvisoryDetailBucketExpectations(expectations []DBDeleteAdvisoryDetailBucketExpectation) { - for _, e := range expectations { - _m.ApplyDeleteAdvisoryDetailBucketExpectation(e) - } -} - -// DeleteAdvisoryDetailBucket provides a mock function with given fields: -func (_m *MockDB) DeleteAdvisoryDetailBucket() error { - ret := _m.Called() - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBDeleteVulnerabilityDetailBucketReturns struct { - Err error -} - -type DBDeleteVulnerabilityDetailBucketExpectation struct { - Returns DBDeleteVulnerabilityDetailBucketReturns -} - -func (_m *MockDB) ApplyDeleteVulnerabilityDetailBucketExpectation(e DBDeleteVulnerabilityDetailBucketExpectation) { - var args []interface{} - _m.On("DeleteVulnerabilityDetailBucket", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyDeleteVulnerabilityDetailBucketExpectations(expectations []DBDeleteVulnerabilityDetailBucketExpectation) { - for _, e := range expectations { - _m.ApplyDeleteVulnerabilityDetailBucketExpectation(e) - } -} - -// DeleteVulnerabilityDetailBucket provides a mock function with given fields: -func (_m *MockDB) DeleteVulnerabilityDetailBucket() error { - ret := _m.Called() - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBForEachAdvisoryArgs struct { - Sources []string - SourcesAnything bool - PkgName string - PkgNameAnything bool -} - -type DBForEachAdvisoryReturns struct { - Value map[string]db.Value - Err error -} - -type DBForEachAdvisoryExpectation struct { - Args DBForEachAdvisoryArgs - Returns DBForEachAdvisoryReturns -} - -func (_m *MockDB) ApplyForEachAdvisoryExpectation(e DBForEachAdvisoryExpectation) { - var args []interface{} - if e.Args.SourcesAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Sources) - } - if e.Args.PkgNameAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.PkgName) - } - _m.On("ForEachAdvisory", args...).Return(e.Returns.Value, e.Returns.Err) -} - -func (_m *MockDB) ApplyForEachAdvisoryExpectations(expectations []DBForEachAdvisoryExpectation) { - for _, e := range expectations { - _m.ApplyForEachAdvisoryExpectation(e) - } -} - -// ForEachAdvisory provides a mock function with given fields: sources, pkgName -func (_m *MockDB) ForEachAdvisory(sources []string, pkgName string) (map[string]db.Value, error) { - ret := _m.Called(sources, pkgName) - - var r0 map[string]db.Value - if rf, ok := ret.Get(0).(func([]string, string) map[string]db.Value); ok { - r0 = rf(sources, pkgName) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(map[string]db.Value) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func([]string, string) error); ok { - r1 = rf(sources, pkgName) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type DBForEachVulnerabilityIDArgs struct { - Fn func(*bbolt.Tx, string) error - FnAnything bool -} - -type DBForEachVulnerabilityIDReturns struct { - Err error -} - -type DBForEachVulnerabilityIDExpectation struct { - Args DBForEachVulnerabilityIDArgs - Returns DBForEachVulnerabilityIDReturns -} - -func (_m *MockDB) ApplyForEachVulnerabilityIDExpectation(e DBForEachVulnerabilityIDExpectation) { - var args []interface{} - if e.Args.FnAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Fn) - } - _m.On("ForEachVulnerabilityID", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyForEachVulnerabilityIDExpectations(expectations []DBForEachVulnerabilityIDExpectation) { - for _, e := range expectations { - _m.ApplyForEachVulnerabilityIDExpectation(e) - } -} - -// ForEachVulnerabilityID provides a mock function with given fields: fn -func (_m *MockDB) ForEachVulnerabilityID(fn func(*bbolt.Tx, string) error) error { - ret := _m.Called(fn) - - var r0 error - if rf, ok := ret.Get(0).(func(func(*bbolt.Tx, string) error) error); ok { - r0 = rf(fn) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBGetArgs struct { - Release string - ReleaseAnything bool - PkgName string - PkgNameAnything bool -} - -type DBGetReturns struct { - _a0 []types.Advisory - _a1 error -} - -type DBGetExpectation struct { - Args DBGetArgs - Returns DBGetReturns -} - -func (_m *MockDB) ApplyGetExpectation(e DBGetExpectation) { - var args []interface{} - if e.Args.ReleaseAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Release) - } - if e.Args.PkgNameAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.PkgName) - } - _m.On("Get", args...).Return(e.Returns._a0, e.Returns._a1) -} - -func (_m *MockDB) ApplyGetExpectations(expectations []DBGetExpectation) { - for _, e := range expectations { - _m.ApplyGetExpectation(e) - } -} - -// Get provides a mock function with given fields: release, pkgName -func (_m *MockDB) Get(release string, pkgName string) ([]types.Advisory, error) { - ret := _m.Called(release, pkgName) - - var r0 []types.Advisory - if rf, ok := ret.Get(0).(func(string, string) []types.Advisory); ok { - r0 = rf(release, pkgName) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.Advisory) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(string, string) error); ok { - r1 = rf(release, pkgName) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type DBGetAdvisoriesArgs struct { - Source string - SourceAnything bool - PkgName string - PkgNameAnything bool -} - -type DBGetAdvisoriesReturns struct { - Advisories []types.Advisory - Err error -} - -type DBGetAdvisoriesExpectation struct { - Args DBGetAdvisoriesArgs - Returns DBGetAdvisoriesReturns -} - -func (_m *MockDB) ApplyGetAdvisoriesExpectation(e DBGetAdvisoriesExpectation) { - var args []interface{} - if e.Args.SourceAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Source) - } - if e.Args.PkgNameAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.PkgName) - } - _m.On("GetAdvisories", args...).Return(e.Returns.Advisories, e.Returns.Err) -} - -func (_m *MockDB) ApplyGetAdvisoriesExpectations(expectations []DBGetAdvisoriesExpectation) { - for _, e := range expectations { - _m.ApplyGetAdvisoriesExpectation(e) - } -} - -// GetAdvisories provides a mock function with given fields: source, pkgName -func (_m *MockDB) GetAdvisories(source string, pkgName string) ([]types.Advisory, error) { - ret := _m.Called(source, pkgName) - - var r0 []types.Advisory - if rf, ok := ret.Get(0).(func(string, string) []types.Advisory); ok { - r0 = rf(source, pkgName) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.Advisory) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(string, string) error); ok { - r1 = rf(source, pkgName) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type DBGetVulnerabilityArgs struct { - VulnerabilityID string - VulnerabilityIDAnything bool -} - -type DBGetVulnerabilityReturns struct { - Vulnerability types.Vulnerability - Err error -} - -type DBGetVulnerabilityExpectation struct { - Args DBGetVulnerabilityArgs - Returns DBGetVulnerabilityReturns -} - -func (_m *MockDB) ApplyGetVulnerabilityExpectation(e DBGetVulnerabilityExpectation) { - var args []interface{} - if e.Args.VulnerabilityIDAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.VulnerabilityID) - } - _m.On("GetVulnerability", args...).Return(e.Returns.Vulnerability, e.Returns.Err) -} - -func (_m *MockDB) ApplyGetVulnerabilityExpectations(expectations []DBGetVulnerabilityExpectation) { - for _, e := range expectations { - _m.ApplyGetVulnerabilityExpectation(e) - } -} - -// GetVulnerability provides a mock function with given fields: vulnerabilityID -func (_m *MockDB) GetVulnerability(vulnerabilityID string) (types.Vulnerability, error) { - ret := _m.Called(vulnerabilityID) - - var r0 types.Vulnerability - if rf, ok := ret.Get(0).(func(string) types.Vulnerability); ok { - r0 = rf(vulnerabilityID) - } else { - r0 = ret.Get(0).(types.Vulnerability) - } - - var r1 error - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(vulnerabilityID) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type DBGetVulnerabilityDetailArgs struct { - CveID string - CveIDAnything bool -} - -type DBGetVulnerabilityDetailReturns struct { - Detail map[types.SourceID]types.VulnerabilityDetail - Err error -} - -type DBGetVulnerabilityDetailExpectation struct { - Args DBGetVulnerabilityDetailArgs - Returns DBGetVulnerabilityDetailReturns -} - -func (_m *MockDB) ApplyGetVulnerabilityDetailExpectation(e DBGetVulnerabilityDetailExpectation) { - var args []interface{} - if e.Args.CveIDAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.CveID) - } - _m.On("GetVulnerabilityDetail", args...).Return(e.Returns.Detail, e.Returns.Err) -} - -func (_m *MockDB) ApplyGetVulnerabilityDetailExpectations(expectations []DBGetVulnerabilityDetailExpectation) { - for _, e := range expectations { - _m.ApplyGetVulnerabilityDetailExpectation(e) - } -} - -// GetVulnerabilityDetail provides a mock function with given fields: cveID -func (_m *MockDB) GetVulnerabilityDetail(cveID string) (map[types.SourceID]types.VulnerabilityDetail, error) { - ret := _m.Called(cveID) - - var r0 map[types.SourceID]types.VulnerabilityDetail - if rf, ok := ret.Get(0).(func(string) map[types.SourceID]types.VulnerabilityDetail); ok { - r0 = rf(cveID) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(map[types.SourceID]types.VulnerabilityDetail) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(cveID) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type DBPutArgs struct { - _a0 *bbolt.Tx - _a0Anything bool - _a1 PutInput - _a1Anything bool -} - -type DBPutReturns struct { - _a0 error -} - -type DBPutExpectation struct { - Args DBPutArgs - Returns DBPutReturns -} - -func (_m *MockDB) ApplyPutExpectation(e DBPutExpectation) { - var args []interface{} - if e.Args._a0Anything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args._a0) - } - if e.Args._a1Anything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args._a1) - } - _m.On("Put", args...).Return(e.Returns._a0) -} - -func (_m *MockDB) ApplyPutExpectations(expectations []DBPutExpectation) { - for _, e := range expectations { - _m.ApplyPutExpectation(e) - } -} - -// Put provides a mock function with given fields: _a0, _a1 -func (_m *MockDB) Put(_a0 *bbolt.Tx, _a1 PutInput) error { - ret := _m.Called(_a0, _a1) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, PutInput) error); ok { - r0 = rf(_a0, _a1) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBPutAdvisoryDetailArgs struct { - Tx *bbolt.Tx - TxAnything bool - VulnerabilityID string - VulnerabilityIDAnything bool - PkgName string - PkgNameAnything bool - NestedBktNames []string - NestedBktNamesAnything bool - Advisory interface{} - AdvisoryAnything bool -} - -type DBPutAdvisoryDetailReturns struct { - Err error -} - -type DBPutAdvisoryDetailExpectation struct { - Args DBPutAdvisoryDetailArgs - Returns DBPutAdvisoryDetailReturns -} - -func (_m *MockDB) ApplyPutAdvisoryDetailExpectation(e DBPutAdvisoryDetailExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.VulnerabilityIDAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.VulnerabilityID) - } - if e.Args.PkgNameAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.PkgName) - } - if e.Args.NestedBktNamesAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.NestedBktNames) - } - if e.Args.AdvisoryAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Advisory) - } - _m.On("PutAdvisoryDetail", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyPutAdvisoryDetailExpectations(expectations []DBPutAdvisoryDetailExpectation) { - for _, e := range expectations { - _m.ApplyPutAdvisoryDetailExpectation(e) - } -} - -// PutAdvisoryDetail provides a mock function with given fields: tx, vulnerabilityID, pkgName, nestedBktNames, advisory -func (_m *MockDB) PutAdvisoryDetail(tx *bbolt.Tx, vulnerabilityID string, pkgName string, nestedBktNames []string, advisory interface{}) error { - ret := _m.Called(tx, vulnerabilityID, pkgName, nestedBktNames, advisory) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, string, string, []string, interface{}) error); ok { - r0 = rf(tx, vulnerabilityID, pkgName, nestedBktNames, advisory) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBPutDataSourceArgs struct { - Tx *bbolt.Tx - TxAnything bool - BktName string - BktNameAnything bool - Source types.DataSource - SourceAnything bool -} - -type DBPutDataSourceReturns struct { - Err error -} - -type DBPutDataSourceExpectation struct { - Args DBPutDataSourceArgs - Returns DBPutDataSourceReturns -} - -func (_m *MockDB) ApplyPutDataSourceExpectation(e DBPutDataSourceExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.BktNameAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.BktName) - } - if e.Args.SourceAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Source) - } - _m.On("PutDataSource", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyPutDataSourceExpectations(expectations []DBPutDataSourceExpectation) { - for _, e := range expectations { - _m.ApplyPutDataSourceExpectation(e) - } -} - -// PutDataSource provides a mock function with given fields: tx, bktName, source -func (_m *MockDB) PutDataSource(tx *bbolt.Tx, bktName string, source types.DataSource) error { - ret := _m.Called(tx, bktName, source) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, string, types.DataSource) error); ok { - r0 = rf(tx, bktName, source) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBPutRedHatCPEsArgs struct { - Tx *bbolt.Tx - TxAnything bool - CpeIndex int - CpeIndexAnything bool - Cpe string - CpeAnything bool -} - -type DBPutRedHatCPEsReturns struct { - Err error -} - -type DBPutRedHatCPEsExpectation struct { - Args DBPutRedHatCPEsArgs - Returns DBPutRedHatCPEsReturns -} - -func (_m *MockDB) ApplyPutRedHatCPEsExpectation(e DBPutRedHatCPEsExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.CpeIndexAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.CpeIndex) - } - if e.Args.CpeAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Cpe) - } - _m.On("PutRedHatCPEs", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyPutRedHatCPEsExpectations(expectations []DBPutRedHatCPEsExpectation) { - for _, e := range expectations { - _m.ApplyPutRedHatCPEsExpectation(e) - } -} - -// PutRedHatCPEs provides a mock function with given fields: tx, cpeIndex, cpe -func (_m *MockDB) PutRedHatCPEs(tx *bbolt.Tx, cpeIndex int, cpe string) error { - ret := _m.Called(tx, cpeIndex, cpe) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, int, string) error); ok { - r0 = rf(tx, cpeIndex, cpe) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBPutRedHatNVRsArgs struct { - Tx *bbolt.Tx - TxAnything bool - Nvr string - NvrAnything bool - CpeIndices []int - CpeIndicesAnything bool -} - -type DBPutRedHatNVRsReturns struct { - Err error -} - -type DBPutRedHatNVRsExpectation struct { - Args DBPutRedHatNVRsArgs - Returns DBPutRedHatNVRsReturns -} - -func (_m *MockDB) ApplyPutRedHatNVRsExpectation(e DBPutRedHatNVRsExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.NvrAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Nvr) - } - if e.Args.CpeIndicesAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.CpeIndices) - } - _m.On("PutRedHatNVRs", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyPutRedHatNVRsExpectations(expectations []DBPutRedHatNVRsExpectation) { - for _, e := range expectations { - _m.ApplyPutRedHatNVRsExpectation(e) - } -} - -// PutRedHatNVRs provides a mock function with given fields: tx, nvr, cpeIndices -func (_m *MockDB) PutRedHatNVRs(tx *bbolt.Tx, nvr string, cpeIndices []int) error { - ret := _m.Called(tx, nvr, cpeIndices) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, string, []int) error); ok { - r0 = rf(tx, nvr, cpeIndices) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBPutRedHatRepositoriesArgs struct { - Tx *bbolt.Tx - TxAnything bool - Repository string - RepositoryAnything bool - CpeIndices []int - CpeIndicesAnything bool -} - -type DBPutRedHatRepositoriesReturns struct { - Err error -} - -type DBPutRedHatRepositoriesExpectation struct { - Args DBPutRedHatRepositoriesArgs - Returns DBPutRedHatRepositoriesReturns -} - -func (_m *MockDB) ApplyPutRedHatRepositoriesExpectation(e DBPutRedHatRepositoriesExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.RepositoryAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Repository) - } - if e.Args.CpeIndicesAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.CpeIndices) - } - _m.On("PutRedHatRepositories", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyPutRedHatRepositoriesExpectations(expectations []DBPutRedHatRepositoriesExpectation) { - for _, e := range expectations { - _m.ApplyPutRedHatRepositoriesExpectation(e) - } -} - -// PutRedHatRepositories provides a mock function with given fields: tx, repository, cpeIndices -func (_m *MockDB) PutRedHatRepositories(tx *bbolt.Tx, repository string, cpeIndices []int) error { - ret := _m.Called(tx, repository, cpeIndices) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, string, []int) error); ok { - r0 = rf(tx, repository, cpeIndices) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBPutVulnerabilityArgs struct { - Tx *bbolt.Tx - TxAnything bool - VulnerabilityID string - VulnerabilityIDAnything bool - Vulnerability types.Vulnerability - VulnerabilityAnything bool -} - -type DBPutVulnerabilityReturns struct { - Err error -} - -type DBPutVulnerabilityExpectation struct { - Args DBPutVulnerabilityArgs - Returns DBPutVulnerabilityReturns -} - -func (_m *MockDB) ApplyPutVulnerabilityExpectation(e DBPutVulnerabilityExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.VulnerabilityIDAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.VulnerabilityID) - } - if e.Args.VulnerabilityAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Vulnerability) - } - _m.On("PutVulnerability", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyPutVulnerabilityExpectations(expectations []DBPutVulnerabilityExpectation) { - for _, e := range expectations { - _m.ApplyPutVulnerabilityExpectation(e) - } -} - -// PutVulnerability provides a mock function with given fields: tx, vulnerabilityID, vulnerability -func (_m *MockDB) PutVulnerability(tx *bbolt.Tx, vulnerabilityID string, vulnerability types.Vulnerability) error { - ret := _m.Called(tx, vulnerabilityID, vulnerability) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, string, types.Vulnerability) error); ok { - r0 = rf(tx, vulnerabilityID, vulnerability) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBPutVulnerabilityDetailArgs struct { - Tx *bbolt.Tx - TxAnything bool - VulnerabilityID string - VulnerabilityIDAnything bool - Source types.SourceID - SourceAnything bool - Vulnerability types.VulnerabilityDetail - VulnerabilityAnything bool -} - -type DBPutVulnerabilityDetailReturns struct { - Err error -} - -type DBPutVulnerabilityDetailExpectation struct { - Args DBPutVulnerabilityDetailArgs - Returns DBPutVulnerabilityDetailReturns -} - -func (_m *MockDB) ApplyPutVulnerabilityDetailExpectation(e DBPutVulnerabilityDetailExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.VulnerabilityIDAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.VulnerabilityID) - } - if e.Args.SourceAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Source) - } - if e.Args.VulnerabilityAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Vulnerability) - } - _m.On("PutVulnerabilityDetail", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyPutVulnerabilityDetailExpectations(expectations []DBPutVulnerabilityDetailExpectation) { - for _, e := range expectations { - _m.ApplyPutVulnerabilityDetailExpectation(e) - } -} - -// PutVulnerabilityDetail provides a mock function with given fields: tx, vulnerabilityID, source, vulnerability -func (_m *MockDB) PutVulnerabilityDetail(tx *bbolt.Tx, vulnerabilityID string, source types.SourceID, vulnerability types.VulnerabilityDetail) error { - ret := _m.Called(tx, vulnerabilityID, source, vulnerability) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, string, types.SourceID, types.VulnerabilityDetail) error); ok { - r0 = rf(tx, vulnerabilityID, source, vulnerability) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBPutVulnerabilityIDArgs struct { - Tx *bbolt.Tx - TxAnything bool - VulnerabilityID string - VulnerabilityIDAnything bool -} - -type DBPutVulnerabilityIDReturns struct { - Err error -} - -type DBPutVulnerabilityIDExpectation struct { - Args DBPutVulnerabilityIDArgs - Returns DBPutVulnerabilityIDReturns -} - -func (_m *MockDB) ApplyPutVulnerabilityIDExpectation(e DBPutVulnerabilityIDExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.VulnerabilityIDAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.VulnerabilityID) - } - _m.On("PutVulnerabilityID", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyPutVulnerabilityIDExpectations(expectations []DBPutVulnerabilityIDExpectation) { - for _, e := range expectations { - _m.ApplyPutVulnerabilityIDExpectation(e) - } -} - -// PutVulnerabilityID provides a mock function with given fields: tx, vulnerabilityID -func (_m *MockDB) PutVulnerabilityID(tx *bbolt.Tx, vulnerabilityID string) error { - ret := _m.Called(tx, vulnerabilityID) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, string) error); ok { - r0 = rf(tx, vulnerabilityID) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBRedHatNVRToCPEsArgs struct { - Nvr string - NvrAnything bool -} - -type DBRedHatNVRToCPEsReturns struct { - CpeIndices []int - Err error -} - -type DBRedHatNVRToCPEsExpectation struct { - Args DBRedHatNVRToCPEsArgs - Returns DBRedHatNVRToCPEsReturns -} - -func (_m *MockDB) ApplyRedHatNVRToCPEsExpectation(e DBRedHatNVRToCPEsExpectation) { - var args []interface{} - if e.Args.NvrAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Nvr) - } - _m.On("RedHatNVRToCPEs", args...).Return(e.Returns.CpeIndices, e.Returns.Err) -} - -func (_m *MockDB) ApplyRedHatNVRToCPEsExpectations(expectations []DBRedHatNVRToCPEsExpectation) { - for _, e := range expectations { - _m.ApplyRedHatNVRToCPEsExpectation(e) - } -} - -// RedHatNVRToCPEs provides a mock function with given fields: nvr -func (_m *MockDB) RedHatNVRToCPEs(nvr string) ([]int, error) { - ret := _m.Called(nvr) - - var r0 []int - if rf, ok := ret.Get(0).(func(string) []int); ok { - r0 = rf(nvr) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]int) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(nvr) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type DBRedHatRepoToCPEsArgs struct { - Repository string - RepositoryAnything bool -} - -type DBRedHatRepoToCPEsReturns struct { - CpeIndices []int - Err error -} - -type DBRedHatRepoToCPEsExpectation struct { - Args DBRedHatRepoToCPEsArgs - Returns DBRedHatRepoToCPEsReturns -} - -func (_m *MockDB) ApplyRedHatRepoToCPEsExpectation(e DBRedHatRepoToCPEsExpectation) { - var args []interface{} - if e.Args.RepositoryAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Repository) - } - _m.On("RedHatRepoToCPEs", args...).Return(e.Returns.CpeIndices, e.Returns.Err) -} - -func (_m *MockDB) ApplyRedHatRepoToCPEsExpectations(expectations []DBRedHatRepoToCPEsExpectation) { - for _, e := range expectations { - _m.ApplyRedHatRepoToCPEsExpectation(e) - } -} - -// RedHatRepoToCPEs provides a mock function with given fields: repository -func (_m *MockDB) RedHatRepoToCPEs(repository string) ([]int, error) { - ret := _m.Called(repository) - - var r0 []int - if rf, ok := ret.Get(0).(func(string) []int); ok { - r0 = rf(repository) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]int) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(repository) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type DBSaveAdvisoryDetailsArgs struct { - Tx *bbolt.Tx - TxAnything bool - CveID string - CveIDAnything bool -} - -type DBSaveAdvisoryDetailsReturns struct { - Err error -} - -type DBSaveAdvisoryDetailsExpectation struct { - Args DBSaveAdvisoryDetailsArgs - Returns DBSaveAdvisoryDetailsReturns -} - -func (_m *MockDB) ApplySaveAdvisoryDetailsExpectation(e DBSaveAdvisoryDetailsExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.CveIDAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.CveID) - } - _m.On("SaveAdvisoryDetails", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplySaveAdvisoryDetailsExpectations(expectations []DBSaveAdvisoryDetailsExpectation) { - for _, e := range expectations { - _m.ApplySaveAdvisoryDetailsExpectation(e) - } -} - -// SaveAdvisoryDetails provides a mock function with given fields: tx, cveID -func (_m *MockDB) SaveAdvisoryDetails(tx *bbolt.Tx, cveID string) error { - ret := _m.Called(tx, cveID) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, string) error); ok { - r0 = rf(tx, cveID) - } else { - r0 = ret.Error(0) - } - - return r0 -} diff --git a/pkg/vulnsrc/osv/mock_transformer.go b/pkg/vulnsrc/osv/mock_transformer.go deleted file mode 100644 index 2027a60..0000000 --- a/pkg/vulnsrc/osv/mock_transformer.go +++ /dev/null @@ -1,71 +0,0 @@ -// Code generated by mockery v1.0.0. DO NOT EDIT. - -package osv - -import mock "github.com/stretchr/testify/mock" - -// MockTransformer is an autogenerated mock type for the Transformer type -type MockTransformer struct { - mock.Mock -} - -type TransformerTransformAdvisoriesArgs struct { - _a0 []Advisory - _a0Anything bool - _a1 Entry - _a1Anything bool -} - -type TransformerTransformAdvisoriesReturns struct { - _a0 []Advisory - _a1 error -} - -type TransformerTransformAdvisoriesExpectation struct { - Args TransformerTransformAdvisoriesArgs - Returns TransformerTransformAdvisoriesReturns -} - -func (_m *MockTransformer) ApplyTransformAdvisoriesExpectation(e TransformerTransformAdvisoriesExpectation) { - var args []interface{} - if e.Args._a0Anything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args._a0) - } - if e.Args._a1Anything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args._a1) - } - _m.On("TransformAdvisories", args...).Return(e.Returns._a0, e.Returns._a1) -} - -func (_m *MockTransformer) ApplyTransformAdvisoriesExpectations(expectations []TransformerTransformAdvisoriesExpectation) { - for _, e := range expectations { - _m.ApplyTransformAdvisoriesExpectation(e) - } -} - -// TransformAdvisories provides a mock function with given fields: _a0, _a1 -func (_m *MockTransformer) TransformAdvisories(_a0 []Advisory, _a1 Entry) ([]Advisory, error) { - ret := _m.Called(_a0, _a1) - - var r0 []Advisory - if rf, ok := ret.Get(0).(func([]Advisory, Entry) []Advisory); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]Advisory) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func([]Advisory, Entry) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} diff --git a/pkg/vulnsrc/osv/mock_version_range.go b/pkg/vulnsrc/osv/mock_version_range.go deleted file mode 100644 index 96e045e..0000000 --- a/pkg/vulnsrc/osv/mock_version_range.go +++ /dev/null @@ -1,155 +0,0 @@ -// Code generated by mockery v1.0.0. DO NOT EDIT. - -package osv - -import mock "github.com/stretchr/testify/mock" - -// MockVersionRange is an autogenerated mock type for the VersionRange type -type MockVersionRange struct { - mock.Mock -} - -type VersionRangeContainsArgs struct { - Ver string - VerAnything bool -} - -type VersionRangeContainsReturns struct { - _a0 bool - _a1 error -} - -type VersionRangeContainsExpectation struct { - Args VersionRangeContainsArgs - Returns VersionRangeContainsReturns -} - -func (_m *MockVersionRange) ApplyContainsExpectation(e VersionRangeContainsExpectation) { - var args []interface{} - if e.Args.VerAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Ver) - } - _m.On("Contains", args...).Return(e.Returns._a0, e.Returns._a1) -} - -func (_m *MockVersionRange) ApplyContainsExpectations(expectations []VersionRangeContainsExpectation) { - for _, e := range expectations { - _m.ApplyContainsExpectation(e) - } -} - -// Contains provides a mock function with given fields: ver -func (_m *MockVersionRange) Contains(ver string) (bool, error) { - ret := _m.Called(ver) - - var r0 bool - if rf, ok := ret.Get(0).(func(string) bool); ok { - r0 = rf(ver) - } else { - r0 = ret.Get(0).(bool) - } - - var r1 error - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(ver) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type VersionRangeSetFixedArgs struct { - Fixed string - FixedAnything bool -} - -type VersionRangeSetFixedExpectation struct { - Args VersionRangeSetFixedArgs -} - -func (_m *MockVersionRange) ApplySetFixedExpectation(e VersionRangeSetFixedExpectation) { - var args []interface{} - if e.Args.FixedAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Fixed) - } - _m.On("SetFixed", args...) -} - -func (_m *MockVersionRange) ApplySetFixedExpectations(expectations []VersionRangeSetFixedExpectation) { - for _, e := range expectations { - _m.ApplySetFixedExpectation(e) - } -} - -// SetFixed provides a mock function with given fields: fixed -func (_m *MockVersionRange) SetFixed(fixed string) { - _m.Called(fixed) -} - -type VersionRangeSetLastAffectedArgs struct { - LastAffected string - LastAffectedAnything bool -} - -type VersionRangeSetLastAffectedExpectation struct { - Args VersionRangeSetLastAffectedArgs -} - -func (_m *MockVersionRange) ApplySetLastAffectedExpectation(e VersionRangeSetLastAffectedExpectation) { - var args []interface{} - if e.Args.LastAffectedAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.LastAffected) - } - _m.On("SetLastAffected", args...) -} - -func (_m *MockVersionRange) ApplySetLastAffectedExpectations(expectations []VersionRangeSetLastAffectedExpectation) { - for _, e := range expectations { - _m.ApplySetLastAffectedExpectation(e) - } -} - -// SetLastAffected provides a mock function with given fields: lastAffected -func (_m *MockVersionRange) SetLastAffected(lastAffected string) { - _m.Called(lastAffected) -} - -type VersionRangeStringReturns struct { - _a0 string -} - -type VersionRangeStringExpectation struct { - Returns VersionRangeStringReturns -} - -func (_m *MockVersionRange) ApplyStringExpectation(e VersionRangeStringExpectation) { - var args []interface{} - _m.On("String", args...).Return(e.Returns._a0) -} - -func (_m *MockVersionRange) ApplyStringExpectations(expectations []VersionRangeStringExpectation) { - for _, e := range expectations { - _m.ApplyStringExpectation(e) - } -} - -// String provides a mock function with given fields: -func (_m *MockVersionRange) String() string { - ret := _m.Called() - - var r0 string - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(string) - } - - return r0 -} diff --git a/pkg/vulnsrc/rocky/mock_db.go b/pkg/vulnsrc/rocky/mock_db.go deleted file mode 100644 index e277adc..0000000 --- a/pkg/vulnsrc/rocky/mock_db.go +++ /dev/null @@ -1,1154 +0,0 @@ -// Code generated by mockery v1.0.0. DO NOT EDIT. - -package rocky - -import ( - db "github.com/khulnasoft-lab/vul-db/pkg/db" - mock "github.com/stretchr/testify/mock" - bbolt "go.etcd.io/bbolt" - - types "github.com/khulnasoft-lab/vul-db/pkg/types" -) - -// MockDB is an autogenerated mock type for the DB type -type MockDB struct { - mock.Mock -} - -type DBBatchUpdateArgs struct { - Fn func(*bbolt.Tx) error - FnAnything bool -} - -type DBBatchUpdateReturns struct { - Err error -} - -type DBBatchUpdateExpectation struct { - Args DBBatchUpdateArgs - Returns DBBatchUpdateReturns -} - -func (_m *MockDB) ApplyBatchUpdateExpectation(e DBBatchUpdateExpectation) { - var args []interface{} - if e.Args.FnAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Fn) - } - _m.On("BatchUpdate", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyBatchUpdateExpectations(expectations []DBBatchUpdateExpectation) { - for _, e := range expectations { - _m.ApplyBatchUpdateExpectation(e) - } -} - -// BatchUpdate provides a mock function with given fields: fn -func (_m *MockDB) BatchUpdate(fn func(*bbolt.Tx) error) error { - ret := _m.Called(fn) - - var r0 error - if rf, ok := ret.Get(0).(func(func(*bbolt.Tx) error) error); ok { - r0 = rf(fn) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBDeleteAdvisoryDetailBucketReturns struct { - _a0 error -} - -type DBDeleteAdvisoryDetailBucketExpectation struct { - Returns DBDeleteAdvisoryDetailBucketReturns -} - -func (_m *MockDB) ApplyDeleteAdvisoryDetailBucketExpectation(e DBDeleteAdvisoryDetailBucketExpectation) { - var args []interface{} - _m.On("DeleteAdvisoryDetailBucket", args...).Return(e.Returns._a0) -} - -func (_m *MockDB) ApplyDeleteAdvisoryDetailBucketExpectations(expectations []DBDeleteAdvisoryDetailBucketExpectation) { - for _, e := range expectations { - _m.ApplyDeleteAdvisoryDetailBucketExpectation(e) - } -} - -// DeleteAdvisoryDetailBucket provides a mock function with given fields: -func (_m *MockDB) DeleteAdvisoryDetailBucket() error { - ret := _m.Called() - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBDeleteVulnerabilityDetailBucketReturns struct { - Err error -} - -type DBDeleteVulnerabilityDetailBucketExpectation struct { - Returns DBDeleteVulnerabilityDetailBucketReturns -} - -func (_m *MockDB) ApplyDeleteVulnerabilityDetailBucketExpectation(e DBDeleteVulnerabilityDetailBucketExpectation) { - var args []interface{} - _m.On("DeleteVulnerabilityDetailBucket", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyDeleteVulnerabilityDetailBucketExpectations(expectations []DBDeleteVulnerabilityDetailBucketExpectation) { - for _, e := range expectations { - _m.ApplyDeleteVulnerabilityDetailBucketExpectation(e) - } -} - -// DeleteVulnerabilityDetailBucket provides a mock function with given fields: -func (_m *MockDB) DeleteVulnerabilityDetailBucket() error { - ret := _m.Called() - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBForEachAdvisoryArgs struct { - Sources []string - SourcesAnything bool - PkgName string - PkgNameAnything bool -} - -type DBForEachAdvisoryReturns struct { - Value map[string]db.Value - Err error -} - -type DBForEachAdvisoryExpectation struct { - Args DBForEachAdvisoryArgs - Returns DBForEachAdvisoryReturns -} - -func (_m *MockDB) ApplyForEachAdvisoryExpectation(e DBForEachAdvisoryExpectation) { - var args []interface{} - if e.Args.SourcesAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Sources) - } - if e.Args.PkgNameAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.PkgName) - } - _m.On("ForEachAdvisory", args...).Return(e.Returns.Value, e.Returns.Err) -} - -func (_m *MockDB) ApplyForEachAdvisoryExpectations(expectations []DBForEachAdvisoryExpectation) { - for _, e := range expectations { - _m.ApplyForEachAdvisoryExpectation(e) - } -} - -// ForEachAdvisory provides a mock function with given fields: sources, pkgName -func (_m *MockDB) ForEachAdvisory(sources []string, pkgName string) (map[string]db.Value, error) { - ret := _m.Called(sources, pkgName) - - var r0 map[string]db.Value - if rf, ok := ret.Get(0).(func([]string, string) map[string]db.Value); ok { - r0 = rf(sources, pkgName) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(map[string]db.Value) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func([]string, string) error); ok { - r1 = rf(sources, pkgName) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type DBForEachVulnerabilityIDArgs struct { - Fn func(*bbolt.Tx, string) error - FnAnything bool -} - -type DBForEachVulnerabilityIDReturns struct { - Err error -} - -type DBForEachVulnerabilityIDExpectation struct { - Args DBForEachVulnerabilityIDArgs - Returns DBForEachVulnerabilityIDReturns -} - -func (_m *MockDB) ApplyForEachVulnerabilityIDExpectation(e DBForEachVulnerabilityIDExpectation) { - var args []interface{} - if e.Args.FnAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Fn) - } - _m.On("ForEachVulnerabilityID", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyForEachVulnerabilityIDExpectations(expectations []DBForEachVulnerabilityIDExpectation) { - for _, e := range expectations { - _m.ApplyForEachVulnerabilityIDExpectation(e) - } -} - -// ForEachVulnerabilityID provides a mock function with given fields: fn -func (_m *MockDB) ForEachVulnerabilityID(fn func(*bbolt.Tx, string) error) error { - ret := _m.Called(fn) - - var r0 error - if rf, ok := ret.Get(0).(func(func(*bbolt.Tx, string) error) error); ok { - r0 = rf(fn) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBGetArgs struct { - Release string - ReleaseAnything bool - PkgName string - PkgNameAnything bool - Arch string - ArchAnything bool -} - -type DBGetReturns struct { - _a0 []types.Advisory - _a1 error -} - -type DBGetExpectation struct { - Args DBGetArgs - Returns DBGetReturns -} - -func (_m *MockDB) ApplyGetExpectation(e DBGetExpectation) { - var args []interface{} - if e.Args.ReleaseAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Release) - } - if e.Args.PkgNameAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.PkgName) - } - if e.Args.ArchAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Arch) - } - _m.On("Get", args...).Return(e.Returns._a0, e.Returns._a1) -} - -func (_m *MockDB) ApplyGetExpectations(expectations []DBGetExpectation) { - for _, e := range expectations { - _m.ApplyGetExpectation(e) - } -} - -// Get provides a mock function with given fields: release, pkgName, arch -func (_m *MockDB) Get(release string, pkgName string, arch string) ([]types.Advisory, error) { - ret := _m.Called(release, pkgName, arch) - - var r0 []types.Advisory - if rf, ok := ret.Get(0).(func(string, string, string) []types.Advisory); ok { - r0 = rf(release, pkgName, arch) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.Advisory) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(string, string, string) error); ok { - r1 = rf(release, pkgName, arch) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type DBGetAdvisoriesArgs struct { - Source string - SourceAnything bool - PkgName string - PkgNameAnything bool -} - -type DBGetAdvisoriesReturns struct { - Advisories []types.Advisory - Err error -} - -type DBGetAdvisoriesExpectation struct { - Args DBGetAdvisoriesArgs - Returns DBGetAdvisoriesReturns -} - -func (_m *MockDB) ApplyGetAdvisoriesExpectation(e DBGetAdvisoriesExpectation) { - var args []interface{} - if e.Args.SourceAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Source) - } - if e.Args.PkgNameAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.PkgName) - } - _m.On("GetAdvisories", args...).Return(e.Returns.Advisories, e.Returns.Err) -} - -func (_m *MockDB) ApplyGetAdvisoriesExpectations(expectations []DBGetAdvisoriesExpectation) { - for _, e := range expectations { - _m.ApplyGetAdvisoriesExpectation(e) - } -} - -// GetAdvisories provides a mock function with given fields: source, pkgName -func (_m *MockDB) GetAdvisories(source string, pkgName string) ([]types.Advisory, error) { - ret := _m.Called(source, pkgName) - - var r0 []types.Advisory - if rf, ok := ret.Get(0).(func(string, string) []types.Advisory); ok { - r0 = rf(source, pkgName) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.Advisory) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(string, string) error); ok { - r1 = rf(source, pkgName) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type DBGetVulnerabilityArgs struct { - VulnerabilityID string - VulnerabilityIDAnything bool -} - -type DBGetVulnerabilityReturns struct { - Vulnerability types.Vulnerability - Err error -} - -type DBGetVulnerabilityExpectation struct { - Args DBGetVulnerabilityArgs - Returns DBGetVulnerabilityReturns -} - -func (_m *MockDB) ApplyGetVulnerabilityExpectation(e DBGetVulnerabilityExpectation) { - var args []interface{} - if e.Args.VulnerabilityIDAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.VulnerabilityID) - } - _m.On("GetVulnerability", args...).Return(e.Returns.Vulnerability, e.Returns.Err) -} - -func (_m *MockDB) ApplyGetVulnerabilityExpectations(expectations []DBGetVulnerabilityExpectation) { - for _, e := range expectations { - _m.ApplyGetVulnerabilityExpectation(e) - } -} - -// GetVulnerability provides a mock function with given fields: vulnerabilityID -func (_m *MockDB) GetVulnerability(vulnerabilityID string) (types.Vulnerability, error) { - ret := _m.Called(vulnerabilityID) - - var r0 types.Vulnerability - if rf, ok := ret.Get(0).(func(string) types.Vulnerability); ok { - r0 = rf(vulnerabilityID) - } else { - r0 = ret.Get(0).(types.Vulnerability) - } - - var r1 error - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(vulnerabilityID) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type DBGetVulnerabilityDetailArgs struct { - CveID string - CveIDAnything bool -} - -type DBGetVulnerabilityDetailReturns struct { - Detail map[types.SourceID]types.VulnerabilityDetail - Err error -} - -type DBGetVulnerabilityDetailExpectation struct { - Args DBGetVulnerabilityDetailArgs - Returns DBGetVulnerabilityDetailReturns -} - -func (_m *MockDB) ApplyGetVulnerabilityDetailExpectation(e DBGetVulnerabilityDetailExpectation) { - var args []interface{} - if e.Args.CveIDAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.CveID) - } - _m.On("GetVulnerabilityDetail", args...).Return(e.Returns.Detail, e.Returns.Err) -} - -func (_m *MockDB) ApplyGetVulnerabilityDetailExpectations(expectations []DBGetVulnerabilityDetailExpectation) { - for _, e := range expectations { - _m.ApplyGetVulnerabilityDetailExpectation(e) - } -} - -// GetVulnerabilityDetail provides a mock function with given fields: cveID -func (_m *MockDB) GetVulnerabilityDetail(cveID string) (map[types.SourceID]types.VulnerabilityDetail, error) { - ret := _m.Called(cveID) - - var r0 map[types.SourceID]types.VulnerabilityDetail - if rf, ok := ret.Get(0).(func(string) map[types.SourceID]types.VulnerabilityDetail); ok { - r0 = rf(cveID) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(map[types.SourceID]types.VulnerabilityDetail) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(cveID) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type DBPutArgs struct { - _a0 *bbolt.Tx - _a0Anything bool - _a1 PutInput - _a1Anything bool -} - -type DBPutReturns struct { - _a0 error -} - -type DBPutExpectation struct { - Args DBPutArgs - Returns DBPutReturns -} - -func (_m *MockDB) ApplyPutExpectation(e DBPutExpectation) { - var args []interface{} - if e.Args._a0Anything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args._a0) - } - if e.Args._a1Anything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args._a1) - } - _m.On("Put", args...).Return(e.Returns._a0) -} - -func (_m *MockDB) ApplyPutExpectations(expectations []DBPutExpectation) { - for _, e := range expectations { - _m.ApplyPutExpectation(e) - } -} - -// Put provides a mock function with given fields: _a0, _a1 -func (_m *MockDB) Put(_a0 *bbolt.Tx, _a1 PutInput) error { - ret := _m.Called(_a0, _a1) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, PutInput) error); ok { - r0 = rf(_a0, _a1) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBPutAdvisoryDetailArgs struct { - Tx *bbolt.Tx - TxAnything bool - VulnerabilityID string - VulnerabilityIDAnything bool - PkgName string - PkgNameAnything bool - NestedBktNames []string - NestedBktNamesAnything bool - Advisory interface{} - AdvisoryAnything bool -} - -type DBPutAdvisoryDetailReturns struct { - Err error -} - -type DBPutAdvisoryDetailExpectation struct { - Args DBPutAdvisoryDetailArgs - Returns DBPutAdvisoryDetailReturns -} - -func (_m *MockDB) ApplyPutAdvisoryDetailExpectation(e DBPutAdvisoryDetailExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.VulnerabilityIDAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.VulnerabilityID) - } - if e.Args.PkgNameAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.PkgName) - } - if e.Args.NestedBktNamesAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.NestedBktNames) - } - if e.Args.AdvisoryAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Advisory) - } - _m.On("PutAdvisoryDetail", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyPutAdvisoryDetailExpectations(expectations []DBPutAdvisoryDetailExpectation) { - for _, e := range expectations { - _m.ApplyPutAdvisoryDetailExpectation(e) - } -} - -// PutAdvisoryDetail provides a mock function with given fields: tx, vulnerabilityID, pkgName, nestedBktNames, advisory -func (_m *MockDB) PutAdvisoryDetail(tx *bbolt.Tx, vulnerabilityID string, pkgName string, nestedBktNames []string, advisory interface{}) error { - ret := _m.Called(tx, vulnerabilityID, pkgName, nestedBktNames, advisory) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, string, string, []string, interface{}) error); ok { - r0 = rf(tx, vulnerabilityID, pkgName, nestedBktNames, advisory) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBPutDataSourceArgs struct { - Tx *bbolt.Tx - TxAnything bool - BktName string - BktNameAnything bool - Source types.DataSource - SourceAnything bool -} - -type DBPutDataSourceReturns struct { - Err error -} - -type DBPutDataSourceExpectation struct { - Args DBPutDataSourceArgs - Returns DBPutDataSourceReturns -} - -func (_m *MockDB) ApplyPutDataSourceExpectation(e DBPutDataSourceExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.BktNameAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.BktName) - } - if e.Args.SourceAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Source) - } - _m.On("PutDataSource", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyPutDataSourceExpectations(expectations []DBPutDataSourceExpectation) { - for _, e := range expectations { - _m.ApplyPutDataSourceExpectation(e) - } -} - -// PutDataSource provides a mock function with given fields: tx, bktName, source -func (_m *MockDB) PutDataSource(tx *bbolt.Tx, bktName string, source types.DataSource) error { - ret := _m.Called(tx, bktName, source) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, string, types.DataSource) error); ok { - r0 = rf(tx, bktName, source) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBPutRedHatCPEsArgs struct { - Tx *bbolt.Tx - TxAnything bool - CpeIndex int - CpeIndexAnything bool - Cpe string - CpeAnything bool -} - -type DBPutRedHatCPEsReturns struct { - Err error -} - -type DBPutRedHatCPEsExpectation struct { - Args DBPutRedHatCPEsArgs - Returns DBPutRedHatCPEsReturns -} - -func (_m *MockDB) ApplyPutRedHatCPEsExpectation(e DBPutRedHatCPEsExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.CpeIndexAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.CpeIndex) - } - if e.Args.CpeAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Cpe) - } - _m.On("PutRedHatCPEs", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyPutRedHatCPEsExpectations(expectations []DBPutRedHatCPEsExpectation) { - for _, e := range expectations { - _m.ApplyPutRedHatCPEsExpectation(e) - } -} - -// PutRedHatCPEs provides a mock function with given fields: tx, cpeIndex, cpe -func (_m *MockDB) PutRedHatCPEs(tx *bbolt.Tx, cpeIndex int, cpe string) error { - ret := _m.Called(tx, cpeIndex, cpe) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, int, string) error); ok { - r0 = rf(tx, cpeIndex, cpe) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBPutRedHatNVRsArgs struct { - Tx *bbolt.Tx - TxAnything bool - Nvr string - NvrAnything bool - CpeIndices []int - CpeIndicesAnything bool -} - -type DBPutRedHatNVRsReturns struct { - Err error -} - -type DBPutRedHatNVRsExpectation struct { - Args DBPutRedHatNVRsArgs - Returns DBPutRedHatNVRsReturns -} - -func (_m *MockDB) ApplyPutRedHatNVRsExpectation(e DBPutRedHatNVRsExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.NvrAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Nvr) - } - if e.Args.CpeIndicesAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.CpeIndices) - } - _m.On("PutRedHatNVRs", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyPutRedHatNVRsExpectations(expectations []DBPutRedHatNVRsExpectation) { - for _, e := range expectations { - _m.ApplyPutRedHatNVRsExpectation(e) - } -} - -// PutRedHatNVRs provides a mock function with given fields: tx, nvr, cpeIndices -func (_m *MockDB) PutRedHatNVRs(tx *bbolt.Tx, nvr string, cpeIndices []int) error { - ret := _m.Called(tx, nvr, cpeIndices) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, string, []int) error); ok { - r0 = rf(tx, nvr, cpeIndices) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBPutRedHatRepositoriesArgs struct { - Tx *bbolt.Tx - TxAnything bool - Repository string - RepositoryAnything bool - CpeIndices []int - CpeIndicesAnything bool -} - -type DBPutRedHatRepositoriesReturns struct { - Err error -} - -type DBPutRedHatRepositoriesExpectation struct { - Args DBPutRedHatRepositoriesArgs - Returns DBPutRedHatRepositoriesReturns -} - -func (_m *MockDB) ApplyPutRedHatRepositoriesExpectation(e DBPutRedHatRepositoriesExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.RepositoryAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Repository) - } - if e.Args.CpeIndicesAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.CpeIndices) - } - _m.On("PutRedHatRepositories", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyPutRedHatRepositoriesExpectations(expectations []DBPutRedHatRepositoriesExpectation) { - for _, e := range expectations { - _m.ApplyPutRedHatRepositoriesExpectation(e) - } -} - -// PutRedHatRepositories provides a mock function with given fields: tx, repository, cpeIndices -func (_m *MockDB) PutRedHatRepositories(tx *bbolt.Tx, repository string, cpeIndices []int) error { - ret := _m.Called(tx, repository, cpeIndices) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, string, []int) error); ok { - r0 = rf(tx, repository, cpeIndices) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBPutVulnerabilityArgs struct { - Tx *bbolt.Tx - TxAnything bool - VulnerabilityID string - VulnerabilityIDAnything bool - Vulnerability types.Vulnerability - VulnerabilityAnything bool -} - -type DBPutVulnerabilityReturns struct { - Err error -} - -type DBPutVulnerabilityExpectation struct { - Args DBPutVulnerabilityArgs - Returns DBPutVulnerabilityReturns -} - -func (_m *MockDB) ApplyPutVulnerabilityExpectation(e DBPutVulnerabilityExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.VulnerabilityIDAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.VulnerabilityID) - } - if e.Args.VulnerabilityAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Vulnerability) - } - _m.On("PutVulnerability", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyPutVulnerabilityExpectations(expectations []DBPutVulnerabilityExpectation) { - for _, e := range expectations { - _m.ApplyPutVulnerabilityExpectation(e) - } -} - -// PutVulnerability provides a mock function with given fields: tx, vulnerabilityID, vulnerability -func (_m *MockDB) PutVulnerability(tx *bbolt.Tx, vulnerabilityID string, vulnerability types.Vulnerability) error { - ret := _m.Called(tx, vulnerabilityID, vulnerability) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, string, types.Vulnerability) error); ok { - r0 = rf(tx, vulnerabilityID, vulnerability) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBPutVulnerabilityDetailArgs struct { - Tx *bbolt.Tx - TxAnything bool - VulnerabilityID string - VulnerabilityIDAnything bool - Source types.SourceID - SourceAnything bool - Vulnerability types.VulnerabilityDetail - VulnerabilityAnything bool -} - -type DBPutVulnerabilityDetailReturns struct { - Err error -} - -type DBPutVulnerabilityDetailExpectation struct { - Args DBPutVulnerabilityDetailArgs - Returns DBPutVulnerabilityDetailReturns -} - -func (_m *MockDB) ApplyPutVulnerabilityDetailExpectation(e DBPutVulnerabilityDetailExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.VulnerabilityIDAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.VulnerabilityID) - } - if e.Args.SourceAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Source) - } - if e.Args.VulnerabilityAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Vulnerability) - } - _m.On("PutVulnerabilityDetail", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyPutVulnerabilityDetailExpectations(expectations []DBPutVulnerabilityDetailExpectation) { - for _, e := range expectations { - _m.ApplyPutVulnerabilityDetailExpectation(e) - } -} - -// PutVulnerabilityDetail provides a mock function with given fields: tx, vulnerabilityID, source, vulnerability -func (_m *MockDB) PutVulnerabilityDetail(tx *bbolt.Tx, vulnerabilityID string, source types.SourceID, vulnerability types.VulnerabilityDetail) error { - ret := _m.Called(tx, vulnerabilityID, source, vulnerability) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, string, types.SourceID, types.VulnerabilityDetail) error); ok { - r0 = rf(tx, vulnerabilityID, source, vulnerability) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBPutVulnerabilityIDArgs struct { - Tx *bbolt.Tx - TxAnything bool - VulnerabilityID string - VulnerabilityIDAnything bool -} - -type DBPutVulnerabilityIDReturns struct { - Err error -} - -type DBPutVulnerabilityIDExpectation struct { - Args DBPutVulnerabilityIDArgs - Returns DBPutVulnerabilityIDReturns -} - -func (_m *MockDB) ApplyPutVulnerabilityIDExpectation(e DBPutVulnerabilityIDExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.VulnerabilityIDAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.VulnerabilityID) - } - _m.On("PutVulnerabilityID", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplyPutVulnerabilityIDExpectations(expectations []DBPutVulnerabilityIDExpectation) { - for _, e := range expectations { - _m.ApplyPutVulnerabilityIDExpectation(e) - } -} - -// PutVulnerabilityID provides a mock function with given fields: tx, vulnerabilityID -func (_m *MockDB) PutVulnerabilityID(tx *bbolt.Tx, vulnerabilityID string) error { - ret := _m.Called(tx, vulnerabilityID) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, string) error); ok { - r0 = rf(tx, vulnerabilityID) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type DBRedHatNVRToCPEsArgs struct { - Nvr string - NvrAnything bool -} - -type DBRedHatNVRToCPEsReturns struct { - CpeIndices []int - Err error -} - -type DBRedHatNVRToCPEsExpectation struct { - Args DBRedHatNVRToCPEsArgs - Returns DBRedHatNVRToCPEsReturns -} - -func (_m *MockDB) ApplyRedHatNVRToCPEsExpectation(e DBRedHatNVRToCPEsExpectation) { - var args []interface{} - if e.Args.NvrAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Nvr) - } - _m.On("RedHatNVRToCPEs", args...).Return(e.Returns.CpeIndices, e.Returns.Err) -} - -func (_m *MockDB) ApplyRedHatNVRToCPEsExpectations(expectations []DBRedHatNVRToCPEsExpectation) { - for _, e := range expectations { - _m.ApplyRedHatNVRToCPEsExpectation(e) - } -} - -// RedHatNVRToCPEs provides a mock function with given fields: nvr -func (_m *MockDB) RedHatNVRToCPEs(nvr string) ([]int, error) { - ret := _m.Called(nvr) - - var r0 []int - if rf, ok := ret.Get(0).(func(string) []int); ok { - r0 = rf(nvr) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]int) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(nvr) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type DBRedHatRepoToCPEsArgs struct { - Repository string - RepositoryAnything bool -} - -type DBRedHatRepoToCPEsReturns struct { - CpeIndices []int - Err error -} - -type DBRedHatRepoToCPEsExpectation struct { - Args DBRedHatRepoToCPEsArgs - Returns DBRedHatRepoToCPEsReturns -} - -func (_m *MockDB) ApplyRedHatRepoToCPEsExpectation(e DBRedHatRepoToCPEsExpectation) { - var args []interface{} - if e.Args.RepositoryAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Repository) - } - _m.On("RedHatRepoToCPEs", args...).Return(e.Returns.CpeIndices, e.Returns.Err) -} - -func (_m *MockDB) ApplyRedHatRepoToCPEsExpectations(expectations []DBRedHatRepoToCPEsExpectation) { - for _, e := range expectations { - _m.ApplyRedHatRepoToCPEsExpectation(e) - } -} - -// RedHatRepoToCPEs provides a mock function with given fields: repository -func (_m *MockDB) RedHatRepoToCPEs(repository string) ([]int, error) { - ret := _m.Called(repository) - - var r0 []int - if rf, ok := ret.Get(0).(func(string) []int); ok { - r0 = rf(repository) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]int) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(repository) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type DBSaveAdvisoryDetailsArgs struct { - Tx *bbolt.Tx - TxAnything bool - CveID string - CveIDAnything bool -} - -type DBSaveAdvisoryDetailsReturns struct { - Err error -} - -type DBSaveAdvisoryDetailsExpectation struct { - Args DBSaveAdvisoryDetailsArgs - Returns DBSaveAdvisoryDetailsReturns -} - -func (_m *MockDB) ApplySaveAdvisoryDetailsExpectation(e DBSaveAdvisoryDetailsExpectation) { - var args []interface{} - if e.Args.TxAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Tx) - } - if e.Args.CveIDAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.CveID) - } - _m.On("SaveAdvisoryDetails", args...).Return(e.Returns.Err) -} - -func (_m *MockDB) ApplySaveAdvisoryDetailsExpectations(expectations []DBSaveAdvisoryDetailsExpectation) { - for _, e := range expectations { - _m.ApplySaveAdvisoryDetailsExpectation(e) - } -} - -// SaveAdvisoryDetails provides a mock function with given fields: tx, cveID -func (_m *MockDB) SaveAdvisoryDetails(tx *bbolt.Tx, cveID string) error { - ret := _m.Called(tx, cveID) - - var r0 error - if rf, ok := ret.Get(0).(func(*bbolt.Tx, string) error); ok { - r0 = rf(tx, cveID) - } else { - r0 = ret.Error(0) - } - - return r0 -} diff --git a/pkg/vulnsrctest/mock_getter.go b/pkg/vulnsrctest/mock_getter.go deleted file mode 100644 index 936855b..0000000 --- a/pkg/vulnsrctest/mock_getter.go +++ /dev/null @@ -1,74 +0,0 @@ -// Code generated by mockery v1.0.0. DO NOT EDIT. - -package vulnsrctest - -import ( - types "github.com/khulnasoft-lab/vul-db/pkg/types" - mock "github.com/stretchr/testify/mock" -) - -// MockGetter is an autogenerated mock type for the Getter type -type MockGetter struct { - mock.Mock -} - -type GetterGetArgs struct { - _a0 string - _a0Anything bool - _a1 string - _a1Anything bool -} - -type GetterGetReturns struct { - _a0 []types.Advisory - _a1 error -} - -type GetterGetExpectation struct { - Args GetterGetArgs - Returns GetterGetReturns -} - -func (_m *MockGetter) ApplyGetExpectation(e GetterGetExpectation) { - var args []interface{} - if e.Args._a0Anything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args._a0) - } - if e.Args._a1Anything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args._a1) - } - _m.On("Get", args...).Return(e.Returns._a0, e.Returns._a1) -} - -func (_m *MockGetter) ApplyGetExpectations(expectations []GetterGetExpectation) { - for _, e := range expectations { - _m.ApplyGetExpectation(e) - } -} - -// Get provides a mock function with given fields: _a0, _a1 -func (_m *MockGetter) Get(_a0 string, _a1 string) ([]types.Advisory, error) { - ret := _m.Called(_a0, _a1) - - var r0 []types.Advisory - if rf, ok := ret.Get(0).(func(string, string) []types.Advisory); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.Advisory) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(string, string) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} diff --git a/pkg/vulnsrctest/mock_updater.go b/pkg/vulnsrctest/mock_updater.go deleted file mode 100644 index 8c95412..0000000 --- a/pkg/vulnsrctest/mock_updater.go +++ /dev/null @@ -1,54 +0,0 @@ -// Code generated by mockery v1.0.0. DO NOT EDIT. - -package vulnsrctest - -import mock "github.com/stretchr/testify/mock" - -// MockUpdater is an autogenerated mock type for the Updater type -type MockUpdater struct { - mock.Mock -} - -type UpdaterUpdateArgs struct { - Dir string - DirAnything bool -} - -type UpdaterUpdateReturns struct { - Err error -} - -type UpdaterUpdateExpectation struct { - Args UpdaterUpdateArgs - Returns UpdaterUpdateReturns -} - -func (_m *MockUpdater) ApplyUpdateExpectation(e UpdaterUpdateExpectation) { - var args []interface{} - if e.Args.DirAnything { - args = append(args, mock.Anything) - } else { - args = append(args, e.Args.Dir) - } - _m.On("Update", args...).Return(e.Returns.Err) -} - -func (_m *MockUpdater) ApplyUpdateExpectations(expectations []UpdaterUpdateExpectation) { - for _, e := range expectations { - _m.ApplyUpdateExpectation(e) - } -} - -// Update provides a mock function with given fields: dir -func (_m *MockUpdater) Update(dir string) error { - ret := _m.Called(dir) - - var r0 error - if rf, ok := ret.Get(0).(func(string) error); ok { - r0 = rf(dir) - } else { - r0 = ret.Error(0) - } - - return r0 -}