mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-12 15:50:15 -08:00
* refactor(docker_conf): rename and remove unnecessary options * feat(rpc): define new API * fix(cli): change default timeout * fix(import): fix package names * refactor(vulnerability): remove old mock * refactor(utils): remove un-needed functions * feat(cache): implement cache communicating with a server * refactor(scan): separate scan function as local scanner * test(scanner): add tests for ScanImage * refactor(scan): remove unused options * test(vulnerability): generate mock * refactor(server): split a file * feat(server): implement new RPC server * feat(client): implement new RPC client * fix(cache): use new cache interface * fix(standalone): use new scanner * fix(client): use new scanner * fix(server): pass cache * test(integration): make sure an error is not nil before calling the method * fix(mod): update dependencies * test(integration): ensure the image load finishes * feat(docker): support DOCKER_HOST and DOCKER_CERT_PATH * chore(mod): update dependencies * refactor(rpc): remove old client * feat(server): support old API for backward compatibility * fix(server): check a schema version of JSON cache * fix(rpc): add a version to packages * feat(rpc): add PutImage * test: rename expectations * refactor(cache): rename LayerCache to ImageCache * refactor: rename ImageInfo to ImageReference * fix(applier): pass image_id to ApplyLayer * feat(cache): handle image cache * chore(mod): update dependencies * refactor(server): pass only config * feat(cli): add -removed-pkgs option * refactor(err): wrap errors
108 lines
2.8 KiB
Go
108 lines
2.8 KiB
Go
// Code generated by mockery v1.0.0. DO NOT EDIT.
|
|
|
|
package scanner
|
|
|
|
import digest "github.com/opencontainers/go-digest"
|
|
import fanaltypes "github.com/aquasecurity/fanal/types"
|
|
import mock "github.com/stretchr/testify/mock"
|
|
import report "github.com/aquasecurity/trivy/pkg/report"
|
|
import types "github.com/aquasecurity/trivy/pkg/types"
|
|
|
|
// MockDriver is an autogenerated mock type for the Driver type
|
|
type MockDriver struct {
|
|
mock.Mock
|
|
}
|
|
|
|
type ScanArgs struct {
|
|
Target string
|
|
TargetAnything bool
|
|
ImageID digest.Digest
|
|
ImageIDAnything bool
|
|
LayerIDs []string
|
|
LayerIDsAnything bool
|
|
Options types.ScanOptions
|
|
OptionsAnything bool
|
|
}
|
|
|
|
type ScanReturns struct {
|
|
Results report.Results
|
|
OsFound *fanaltypes.OS
|
|
Eols bool
|
|
Err error
|
|
}
|
|
|
|
type ScanExpectation struct {
|
|
Args ScanArgs
|
|
Returns ScanReturns
|
|
}
|
|
|
|
func (_m *MockDriver) ApplyScanExpectation(e ScanExpectation) {
|
|
var args []interface{}
|
|
if e.Args.TargetAnything {
|
|
args = append(args, mock.Anything)
|
|
} else {
|
|
args = append(args, e.Args.Target)
|
|
}
|
|
if e.Args.ImageIDAnything {
|
|
args = append(args, mock.Anything)
|
|
} else {
|
|
args = append(args, e.Args.ImageID)
|
|
}
|
|
if e.Args.LayerIDsAnything {
|
|
args = append(args, mock.Anything)
|
|
} else {
|
|
args = append(args, e.Args.LayerIDs)
|
|
}
|
|
if e.Args.OptionsAnything {
|
|
args = append(args, mock.Anything)
|
|
} else {
|
|
args = append(args, e.Args.Options)
|
|
}
|
|
_m.On("Scan", args...).Return(e.Returns.Results, e.Returns.OsFound, e.Returns.Eols, e.Returns.Err)
|
|
}
|
|
|
|
func (_m *MockDriver) ApplyScanExpectations(expectations []ScanExpectation) {
|
|
for _, e := range expectations {
|
|
_m.ApplyScanExpectation(e)
|
|
}
|
|
}
|
|
|
|
// Scan provides a mock function with given fields: target, imageID, layerIDs, options
|
|
func (_m *MockDriver) Scan(target string, imageID digest.Digest, layerIDs []string, options types.ScanOptions) (report.Results, *fanaltypes.OS, bool, error) {
|
|
ret := _m.Called(target, imageID, layerIDs, options)
|
|
|
|
var r0 report.Results
|
|
if rf, ok := ret.Get(0).(func(string, digest.Digest, []string, types.ScanOptions) report.Results); ok {
|
|
r0 = rf(target, imageID, layerIDs, options)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(report.Results)
|
|
}
|
|
}
|
|
|
|
var r1 *fanaltypes.OS
|
|
if rf, ok := ret.Get(1).(func(string, digest.Digest, []string, types.ScanOptions) *fanaltypes.OS); ok {
|
|
r1 = rf(target, imageID, layerIDs, options)
|
|
} else {
|
|
if ret.Get(1) != nil {
|
|
r1 = ret.Get(1).(*fanaltypes.OS)
|
|
}
|
|
}
|
|
|
|
var r2 bool
|
|
if rf, ok := ret.Get(2).(func(string, digest.Digest, []string, types.ScanOptions) bool); ok {
|
|
r2 = rf(target, imageID, layerIDs, options)
|
|
} else {
|
|
r2 = ret.Get(2).(bool)
|
|
}
|
|
|
|
var r3 error
|
|
if rf, ok := ret.Get(3).(func(string, digest.Digest, []string, types.ScanOptions) error); ok {
|
|
r3 = rf(target, imageID, layerIDs, options)
|
|
} else {
|
|
r3 = ret.Error(3)
|
|
}
|
|
|
|
return r0, r1, r2, r3
|
|
}
|