mock_sensor

package
v0.0.0-...-8341b1f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

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

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

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(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

func (s *MockSensor) WaitProcessesN(containerID string, timeout time.Duration, n int, tickFn func()) bool

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

func NewRingChan[T any](size int) RingChan[T]

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]) Read

func (r *RingChan[T]) Read() T

Read a value from the output channel

func (*RingChan[T]) Stop

func (r *RingChan[T]) Stop()

Stop closes the channels. The side effect of this is that the gorountine will stop.

func (*RingChan[T]) Stream

func (r *RingChan[T]) Stream() chan T

Stream returns the output channel

func (*RingChan[T]) Write

func (r *RingChan[T]) Write(item T)

Write a value to the input channel

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL