Files
fleet/server/mock/datastore_carves.go
T
Tomas Touceda f8b7a83cc6 Process stored CPEs and store found CVEs (#1533)
* WIP

* WIP

* Make path optional and fix tests

* Add first generate

* Move to nvd package

* remove replace

* Re-add replace

* It's path, not file name

* Change how db path is set and use etag

* Fix typos

* Make db generation faster

* Remove quotes

* Doesn't like comments

* Samitize etag and save to file

* Refactor some things and improve writing of etagenv

* Compress file and truncate amount of items for faster testing

* Remove quotes

* Try to improve performance

* Ignore truncate error if not exists

* Minor cleanup and make sqlite have cpe prefix

* Simplify code and test sync

* Add VCR for sync test

* Check for nvdRelease nil

* Add test for the actual translation

* Address review comments

* Rename generate command because we'll have a cve one too

* Move to its own dir

* Add first cve db generation

* WIP but with final strategy, preparring to merge main

* Fix merge conflicts

* WIP

* wip

* Insert CVEs to the db

* Remove unused code

* Use wg instead of counting

* Call cancelFunc to avoid ctx leak

* Fix logs for better readability

* Point code to fleetdm instead of my repo
2021-08-04 18:01:39 -03:00

104 lines
2.8 KiB
Go

// Automatically generated by mockimpl. DO NOT EDIT!
package mock
import (
"time"
"github.com/fleetdm/fleet/v4/server/fleet"
)
var _ fleet.CarveStore = (*CarveStore)(nil)
type NewCarveFunc func(metadata *fleet.CarveMetadata) (*fleet.CarveMetadata, error)
type UpdateCarveFunc func(metadata *fleet.CarveMetadata) error
type CarveFunc func(carveId int64) (*fleet.CarveMetadata, error)
type CarveBySessionIdFunc func(sessionId string) (*fleet.CarveMetadata, error)
type CarveByNameFunc func(name string) (*fleet.CarveMetadata, error)
type ListCarvesFunc func(opt fleet.CarveListOptions) ([]*fleet.CarveMetadata, error)
type NewBlockFunc func(metadata *fleet.CarveMetadata, blockId int64, data []byte) error
type GetBlockFunc func(metadata *fleet.CarveMetadata, blockId int64) ([]byte, error)
type CleanupCarvesFunc func(now time.Time) (expired int, err error)
type CarveStore struct {
NewCarveFunc NewCarveFunc
NewCarveFuncInvoked bool
UpdateCarveFunc UpdateCarveFunc
UpdateCarveFuncInvoked bool
CarveFunc CarveFunc
CarveFuncInvoked bool
CarveBySessionIdFunc CarveBySessionIdFunc
CarveBySessionIdFuncInvoked bool
CarveByNameFunc CarveByNameFunc
CarveByNameFuncInvoked bool
ListCarvesFunc ListCarvesFunc
ListCarvesFuncInvoked bool
NewBlockFunc NewBlockFunc
NewBlockFuncInvoked bool
GetBlockFunc GetBlockFunc
GetBlockFuncInvoked bool
CleanupCarvesFunc CleanupCarvesFunc
CleanupCarvesFuncInvoked bool
}
func (s *CarveStore) NewCarve(metadata *fleet.CarveMetadata) (*fleet.CarveMetadata, error) {
s.NewCarveFuncInvoked = true
return s.NewCarveFunc(metadata)
}
func (s *CarveStore) UpdateCarve(metadata *fleet.CarveMetadata) error {
s.UpdateCarveFuncInvoked = true
return s.UpdateCarveFunc(metadata)
}
func (s *CarveStore) Carve(carveId int64) (*fleet.CarveMetadata, error) {
s.CarveFuncInvoked = true
return s.CarveFunc(carveId)
}
func (s *CarveStore) CarveBySessionId(sessionId string) (*fleet.CarveMetadata, error) {
s.CarveBySessionIdFuncInvoked = true
return s.CarveBySessionIdFunc(sessionId)
}
func (s *CarveStore) CarveByName(name string) (*fleet.CarveMetadata, error) {
s.CarveByNameFuncInvoked = true
return s.CarveByNameFunc(name)
}
func (s *CarveStore) ListCarves(opt fleet.CarveListOptions) ([]*fleet.CarveMetadata, error) {
s.ListCarvesFuncInvoked = true
return s.ListCarvesFunc(opt)
}
func (s *CarveStore) NewBlock(metadata *fleet.CarveMetadata, blockId int64, data []byte) error {
s.NewBlockFuncInvoked = true
return s.NewBlockFunc(metadata, blockId, data)
}
func (s *CarveStore) GetBlock(metadata *fleet.CarveMetadata, blockId int64) ([]byte, error) {
s.GetBlockFuncInvoked = true
return s.GetBlockFunc(metadata, blockId)
}
func (s *CarveStore) CleanupCarves(now time.Time) (expired int, err error) {
s.CleanupCarvesFuncInvoked = true
return s.CleanupCarvesFunc(now)
}