Documentation ¶
Index ¶
- type ConnMap
- type EndpointMap
- type LineageMap
- type MockSensor
- func (m *MockSensor) Connections(containerID string) []types.NetworkInfo
- func (m *MockSensor) Endpoints(containerID string) []types.EndpointInfo
- func (s *MockSensor) ExpectConnections(t *testing.T, containerID string, timeout time.Duration, ...) bool
- func (s *MockSensor) ExpectConnectionsN(t *testing.T, containerID string, timeout time.Duration, n int) []types.NetworkInfo
- func (s *MockSensor) ExpectEndpoints(t *testing.T, containerID string, timeout time.Duration, ...) bool
- func (s *MockSensor) ExpectEndpointsN(t *testing.T, containerID string, timeout time.Duration, n int) []types.EndpointInfo
- func (s *MockSensor) ExpectLineages(t *testing.T, containerID string, timeout time.Duration, processName string, ...) bool
- func (s *MockSensor) ExpectProcesses(t *testing.T, containerID string, timeout time.Duration, ...) bool
- func (s *MockSensor) ExpectProcessesN(t *testing.T, containerID string, timeout time.Duration, n int) []types.ProcessInfo
- func (m *MockSensor) HasConnection(containerID string, conn types.NetworkInfo) bool
- func (m *MockSensor) HasEndpoint(containerID string, endpoint types.EndpointInfo) bool
- func (m *MockSensor) HasLineage(containerID string, lineage types.ProcessLineage) bool
- func (m *MockSensor) HasProcess(containerID string, process types.ProcessInfo) bool
- func (m *MockSensor) LiveConnections() <-chan *sensorAPI.NetworkConnection
- func (m *MockSensor) LiveEndpoints() <-chan *sensorAPI.NetworkEndpoint
- func (m *MockSensor) LiveLineages() <-chan *storage.ProcessSignal_LineageInfo
- func (m *MockSensor) LiveProcesses() <-chan *storage.ProcessSignal
- func (m *MockSensor) ProcessLineages(containerID string) []types.ProcessLineage
- func (m *MockSensor) Processes(containerID string) []types.ProcessInfo
- func (m *MockSensor) PushNetworkConnectionInfo(stream sensorAPI.NetworkConnectionInfoService_PushNetworkConnectionInfoServer) error
- func (m *MockSensor) PushSignals(stream sensorAPI.SignalService_PushSignalsServer) error
- func (m *MockSensor) Start()
- func (m *MockSensor) Stop()
- func (s *MockSensor) WaitEndpointsN(t *testing.T, containerID string, timeout time.Duration, n int) bool
- func (s *MockSensor) WaitProcessesN(containerID string, timeout time.Duration, n int, tickFn func()) bool
- type ProcessMap
- type RingChan
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnMap ¶
type ConnMap map[types.NetworkInfo]interface{}
type EndpointMap ¶
type EndpointMap map[types.EndpointInfo]interface{}
type LineageMap ¶
type LineageMap map[types.ProcessLineage]interface{}
type MockSensor ¶
type MockSensor struct {
// contains filtered or unexported fields
}
func NewMockSensor ¶
func NewMockSensor(test string) *MockSensor
func (*MockSensor) Connections ¶
func (m *MockSensor) Connections(containerID string) []types.NetworkInfo
Connections returns a list of all connections that have been received for a given container ID
func (*MockSensor) Endpoints ¶
func (m *MockSensor) Endpoints(containerID string) []types.EndpointInfo
Endpoints returns a list of all endpoints that have been received for a given container ID
func (*MockSensor) ExpectConnections ¶
func (s *MockSensor) ExpectConnections(t *testing.T, containerID string, timeout time.Duration, expected ...types.NetworkInfo) bool
ExpectConnections waits up to the timeout for the gRPC server to receive the list of expected Connections. It will first check to see if the connections have been received already, and then monitor the live feed of connections until timeout or until all the events have been received.
func (*MockSensor) ExpectConnectionsN ¶
func (s *MockSensor) ExpectConnectionsN(t *testing.T, containerID string, timeout time.Duration, n int) []types.NetworkInfo
ExpectConnectionsN waits up to the timeout for the gRPC server to receive the a set number of connections. It will first check to see if the connections have been received already, and then monitor the live feed of connections until timeout or until all the events have been received.
It does not consider the content of the events, just that a certain number have been received
func (*MockSensor) ExpectEndpoints ¶
func (s *MockSensor) ExpectEndpoints(t *testing.T, containerID string, timeout time.Duration, expected ...types.EndpointInfo) bool
ExpectEndpoints waits up to the timeout for the gRPC server to receive the list of expected Endpoints. It will first check to see if the endpoints have been received already, and then monitor the live feed of endpoints until timeout or until all the events have been received.
func (*MockSensor) ExpectEndpointsN ¶
func (s *MockSensor) ExpectEndpointsN(t *testing.T, containerID string, timeout time.Duration, n int) []types.EndpointInfo
ExpectEndpointsN waits up to the timeout for the gRPC server to receive the a set number of endpoints. It will first check to see if the endpoints have been received already, and then monitor the live feed of endpoints until timeout or until all the events have been received.
It does not consider the content of the events, just that a certain number have been received
func (*MockSensor) ExpectLineages ¶
func (s *MockSensor) ExpectLineages(t *testing.T, containerID string, timeout time.Duration, processName string, expected ...types.ProcessLineage) bool
func (*MockSensor) ExpectProcesses ¶
func (s *MockSensor) ExpectProcesses( t *testing.T, containerID string, timeout time.Duration, expected ...types.ProcessInfo) bool
func (*MockSensor) ExpectProcessesN ¶
func (s *MockSensor) ExpectProcessesN(t *testing.T, containerID string, timeout time.Duration, n int) []types.ProcessInfo
func (*MockSensor) HasConnection ¶
func (m *MockSensor) HasConnection(containerID string, conn types.NetworkInfo) bool
HasConnection returns whether a given connection has been seen for a given container ID
func (*MockSensor) HasEndpoint ¶
func (m *MockSensor) HasEndpoint(containerID string, endpoint types.EndpointInfo) bool
HasEndpoint returns whether a given endpoint has been seen for a given container ID
func (*MockSensor) HasLineage ¶
func (m *MockSensor) HasLineage(containerID string, lineage types.ProcessLineage) bool
HasLineage returns whether a given process lineage has been seen for a given container ID
func (*MockSensor) HasProcess ¶
func (m *MockSensor) HasProcess(containerID string, process types.ProcessInfo) bool
HasProcess returns whether a given process has been seen for a given container ID.
func (*MockSensor) LiveConnections ¶
func (m *MockSensor) LiveConnections() <-chan *sensorAPI.NetworkConnection
LiveConnections returns a channel that can be used to read live connection events
func (*MockSensor) LiveEndpoints ¶
func (m *MockSensor) LiveEndpoints() <-chan *sensorAPI.NetworkEndpoint
Liveendpoints returns a channel that can be used to read live endpoint events
func (*MockSensor) LiveLineages ¶
func (m *MockSensor) LiveLineages() <-chan *storage.ProcessSignal_LineageInfo
LiveLineages returns a channel that can be used to read live process lineage events
func (*MockSensor) LiveProcesses ¶
func (m *MockSensor) LiveProcesses() <-chan *storage.ProcessSignal
LiveProcesses returns a channel that can be used to read live process events
func (*MockSensor) ProcessLineages ¶
func (m *MockSensor) ProcessLineages(containerID string) []types.ProcessLineage
ProcessLineages returns a list of all processes that have been received for a given container ID
func (*MockSensor) Processes ¶
func (m *MockSensor) Processes(containerID string) []types.ProcessInfo
Processes returns a list of all processes that have been receieved for a given container ID
func (*MockSensor) PushNetworkConnectionInfo ¶
func (m *MockSensor) PushNetworkConnectionInfo(stream sensorAPI.NetworkConnectionInfoService_PushNetworkConnectionInfoServer) error
PushNetworkConnectionInfo conforms to the Sensor API. It is here that networking events (connections and endpoints) are handled and stored/sent to the relevant channel
func (*MockSensor) PushSignals ¶
func (m *MockSensor) PushSignals(stream sensorAPI.SignalService_PushSignalsServer) error
PushSignals conforms to the Sensor API. It is here that process signals and process lineage information is handled and stored/sent to the relevant channel
func (*MockSensor) Start ¶
func (m *MockSensor) Start()
Start will initialize the gRPC server and begin serving The server itself runs in a separate thread.
func (*MockSensor) Stop ¶
func (m *MockSensor) Stop()
Stop will shut down the gRPC server and clear the internal store of all events
func (*MockSensor) WaitEndpointsN ¶
func (s *MockSensor) WaitEndpointsN(t *testing.T, containerID string, timeout time.Duration, n int) bool
WaitEndpointsN is a non-fatal version of ExpectEndpointsN. It waits for a given timeout until n Endpoints have been receieved. On timeout it returns false.
func (*MockSensor) WaitProcessesN ¶
type ProcessMap ¶
type ProcessMap map[types.ProcessInfo]interface{}
Using maps in this way allows us a very quick way of identifying when specific events arrive. (Go allows us to use any comparable type as the key)
type RingChan ¶
type RingChan[T any] struct { // contains filtered or unexported fields }
func NewRingChan ¶
NewRingChan initializes a RingChan of a given size. The input and output channels will have the same capacity as defined by the size parameter
Note: for every RingChan, a new goroutine is started
func (*RingChan[T]) Stop ¶
func (r *RingChan[T]) Stop()
Stop closes the channels. The side effect of this is that the gorountine will stop.