mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
c89cd370d5
This adds the option to set up an S3 bucket as the storage backend for file carving (partially solving #111). It works by using the multipart upload capabilities of S3 to maintain compatibility with the "upload in blocks" protocol that osquery uses. It does this basically replacing the carve_blocks table while still maintaining the metadata in the original place (it would probably be possible to rely completely on S3 by using object tagging at the cost of listing performance). To make this pluggable, I created a new field in the service struct dedicated to the CarveStore which, if no configuration for S3 is set up will be just a reference to the standard datastore, otherwise it will point to the S3 one (effectively this separation will allow in the future to add more backends).
104 lines
2.8 KiB
Go
104 lines
2.8 KiB
Go
// Automatically generated by mockimpl. DO NOT EDIT!
|
|
|
|
package mock
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/fleetdm/fleet/server/kolide"
|
|
)
|
|
|
|
var _ kolide.CarveStore = (*CarveStore)(nil)
|
|
|
|
type NewCarveFunc func(c *kolide.CarveMetadata) (*kolide.CarveMetadata, error)
|
|
|
|
type UpdateCarveFunc func(c *kolide.CarveMetadata) error
|
|
|
|
type CarveFunc func(carveId int64) (*kolide.CarveMetadata, error)
|
|
|
|
type ListCarvesFunc func(opt kolide.CarveListOptions) ([]*kolide.CarveMetadata, error)
|
|
|
|
type CarveBySessionIdFunc func(sessionId string) (*kolide.CarveMetadata, error)
|
|
|
|
type CarveByNameFunc func(name string) (*kolide.CarveMetadata, error)
|
|
|
|
type NewBlockFunc func(metadata *kolide.CarveMetadata, blockId int64, data []byte) error
|
|
|
|
type GetBlockFunc func(metadata *kolide.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
|
|
|
|
ListCarvesFunc ListCarvesFunc
|
|
ListCarvesFuncInvoked bool
|
|
|
|
CarveBySessionIdFunc CarveBySessionIdFunc
|
|
CarveBySessionIdFuncInvoked bool
|
|
|
|
CarveByNameFunc CarveByNameFunc
|
|
CarveByNameFuncInvoked bool
|
|
|
|
NewBlockFunc NewBlockFunc
|
|
NewBlockFuncInvoked bool
|
|
|
|
GetBlockFunc GetBlockFunc
|
|
GetBlockFuncInvoked bool
|
|
|
|
CleanupCarvesFunc CleanupCarvesFunc
|
|
CleanupCarvesFuncInvoked bool
|
|
}
|
|
|
|
func (s *CarveStore) NewCarve(c *kolide.CarveMetadata) (*kolide.CarveMetadata, error) {
|
|
s.NewCarveFuncInvoked = true
|
|
return s.NewCarveFunc(c)
|
|
}
|
|
|
|
func (s *CarveStore) UpdateCarve(c *kolide.CarveMetadata) error {
|
|
s.UpdateCarveFuncInvoked = true
|
|
return s.UpdateCarveFunc(c)
|
|
}
|
|
|
|
func (s *CarveStore) Carve(carveId int64) (*kolide.CarveMetadata, error) {
|
|
s.CarveFuncInvoked = true
|
|
return s.CarveFunc(carveId)
|
|
}
|
|
|
|
func (s *CarveStore) ListCarves(opt kolide.CarveListOptions) ([]*kolide.CarveMetadata, error) {
|
|
s.ListCarvesFuncInvoked = true
|
|
return s.ListCarvesFunc(opt)
|
|
}
|
|
|
|
func (s *CarveStore) CarveBySessionId(sessionId string) (*kolide.CarveMetadata, error) {
|
|
s.CarveBySessionIdFuncInvoked = true
|
|
return s.CarveBySessionIdFunc(sessionId)
|
|
}
|
|
|
|
func (s *CarveStore) CarveByName(name string) (*kolide.CarveMetadata, error) {
|
|
s.CarveByNameFuncInvoked = true
|
|
return s.CarveByNameFunc(name)
|
|
}
|
|
|
|
func (s *CarveStore) NewBlock(metadata *kolide.CarveMetadata, blockId int64, data []byte) error {
|
|
s.NewBlockFuncInvoked = true
|
|
return s.NewBlockFunc(metadata, blockId, data)
|
|
}
|
|
|
|
func (s *CarveStore) GetBlock(metadata *kolide.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)
|
|
}
|