fleet/server/mock/datastore_hosts.go
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

173 lines
5.1 KiB
Go

// Automatically generated by mockimpl. DO NOT EDIT!
package mock
import (
"time"
"github.com/fleetdm/fleet/v4/server/fleet"
)
var _ fleet.HostStore = (*HostStore)(nil)
type NewHostFunc func(host *fleet.Host) (*fleet.Host, error)
type SaveHostFunc func(host *fleet.Host) error
type DeleteHostFunc func(hid uint) error
type HostFunc func(id uint) (*fleet.Host, error)
type EnrollHostFunc func(osqueryHostId string, nodeKey string, teamID *uint, cooldown time.Duration) (*fleet.Host, error)
type ListHostsFunc func(filter fleet.TeamFilter, opt fleet.HostListOptions) ([]*fleet.Host, error)
type AuthenticateHostFunc func(nodeKey string) (*fleet.Host, error)
type MarkHostSeenFunc func(host *fleet.Host, t time.Time) error
type MarkHostsSeenFunc func(hostIDs []uint, t time.Time) error
type SearchHostsFunc func(filter fleet.TeamFilter, query string, omit ...uint) ([]*fleet.Host, error)
type CleanupIncomingHostsFunc func(now time.Time) error
type GenerateHostStatusStatisticsFunc func(filter fleet.TeamFilter, now time.Time) (online uint, offline uint, mia uint, new uint, err error)
type HostIDsByNameFunc func(filter fleet.TeamFilter, hostnames []string) ([]uint, error)
type HostByIdentifierFunc func(identifier string) (*fleet.Host, error)
type AddHostsToTeamFunc func(teamID *uint, hostIDs []uint) error
type SaveHostAdditionalFunc func(host *fleet.Host) error
type HostStore struct {
NewHostFunc NewHostFunc
NewHostFuncInvoked bool
SaveHostFunc SaveHostFunc
SaveHostFuncInvoked bool
DeleteHostFunc DeleteHostFunc
DeleteHostFuncInvoked bool
HostFunc HostFunc
HostFuncInvoked bool
EnrollHostFunc EnrollHostFunc
EnrollHostFuncInvoked bool
ListHostsFunc ListHostsFunc
ListHostsFuncInvoked bool
AuthenticateHostFunc AuthenticateHostFunc
AuthenticateHostFuncInvoked bool
MarkHostSeenFunc MarkHostSeenFunc
MarkHostSeenFuncInvoked bool
MarkHostsSeenFunc MarkHostsSeenFunc
MarkHostsSeenFuncInvoked bool
SearchHostsFunc SearchHostsFunc
SearchHostsFuncInvoked bool
CleanupIncomingHostsFunc CleanupIncomingHostsFunc
CleanupIncomingHostsFuncInvoked bool
GenerateHostStatusStatisticsFunc GenerateHostStatusStatisticsFunc
GenerateHostStatusStatisticsFuncInvoked bool
HostIDsByNameFunc HostIDsByNameFunc
HostIDsByNameFuncInvoked bool
HostByIdentifierFunc HostByIdentifierFunc
HostByIdentifierFuncInvoked bool
AddHostsToTeamFunc AddHostsToTeamFunc
AddHostsToTeamFuncInvoked bool
SaveHostAdditionalFunc SaveHostAdditionalFunc
SaveHostAdditionalFuncInvoked bool
}
func (s *HostStore) NewHost(host *fleet.Host) (*fleet.Host, error) {
s.NewHostFuncInvoked = true
return s.NewHostFunc(host)
}
func (s *HostStore) SaveHost(host *fleet.Host) error {
s.SaveHostFuncInvoked = true
return s.SaveHostFunc(host)
}
func (s *HostStore) DeleteHost(hid uint) error {
s.DeleteHostFuncInvoked = true
return s.DeleteHostFunc(hid)
}
func (s *HostStore) Host(id uint) (*fleet.Host, error) {
s.HostFuncInvoked = true
return s.HostFunc(id)
}
func (s *HostStore) EnrollHost(osqueryHostId string, nodeKey string, teamID *uint, cooldown time.Duration) (*fleet.Host, error) {
s.EnrollHostFuncInvoked = true
return s.EnrollHostFunc(osqueryHostId, nodeKey, teamID, cooldown)
}
func (s *HostStore) ListHosts(filter fleet.TeamFilter, opt fleet.HostListOptions) ([]*fleet.Host, error) {
s.ListHostsFuncInvoked = true
return s.ListHostsFunc(filter, opt)
}
func (s *HostStore) AuthenticateHost(nodeKey string) (*fleet.Host, error) {
s.AuthenticateHostFuncInvoked = true
return s.AuthenticateHostFunc(nodeKey)
}
func (s *HostStore) MarkHostSeen(host *fleet.Host, t time.Time) error {
s.MarkHostSeenFuncInvoked = true
return s.MarkHostSeenFunc(host, t)
}
func (s *HostStore) MarkHostsSeen(hostIDs []uint, t time.Time) error {
s.MarkHostsSeenFuncInvoked = true
return s.MarkHostsSeenFunc(hostIDs, t)
}
func (s *HostStore) SearchHosts(filter fleet.TeamFilter, query string, omit ...uint) ([]*fleet.Host, error) {
s.SearchHostsFuncInvoked = true
return s.SearchHostsFunc(filter, query, omit...)
}
func (s *HostStore) CleanupIncomingHosts(now time.Time) error {
s.CleanupIncomingHostsFuncInvoked = true
return s.CleanupIncomingHostsFunc(now)
}
func (s *HostStore) GenerateHostStatusStatistics(filter fleet.TeamFilter, now time.Time) (online uint, offline uint, mia uint, new uint, err error) {
s.GenerateHostStatusStatisticsFuncInvoked = true
return s.GenerateHostStatusStatisticsFunc(filter, now)
}
func (s *HostStore) HostIDsByName(filter fleet.TeamFilter, hostnames []string) ([]uint, error) {
s.HostIDsByNameFuncInvoked = true
return s.HostIDsByNameFunc(filter, hostnames)
}
func (s *HostStore) HostByIdentifier(identifier string) (*fleet.Host, error) {
s.HostByIdentifierFuncInvoked = true
return s.HostByIdentifierFunc(identifier)
}
func (s *HostStore) AddHostsToTeam(teamID *uint, hostIDs []uint) error {
s.AddHostsToTeamFuncInvoked = true
return s.AddHostsToTeamFunc(teamID, hostIDs)
}
func (s *HostStore) SaveHostAdditional(host *fleet.Host) error {
s.SaveHostAdditionalFuncInvoked = true
return s.SaveHostAdditionalFunc(host)
}