Documentation
¶
Overview ¶
Package tls is a generated GoMock package.
Package tls is a generated GoMock package.
Index ¶
- Constants
- Variables
- func AttachProbes[T interface{ ... }](ctx context.Context, logger *zap.Logger, target T, symbols []elf.Symbol, ...) (io.Closer, error)
- func FindSharedLibrary(ctx context.Context, root string, libNamePrefix string) ([]string, error)
- func NewTargetScanner(logger *zap.Logger, probes []Probe, opts ...TargetScannerOption) *targetScanner
- type CloserFunc
- type ContainerScanResult
- type ExeAttachable
- type ExeElfScannable
- type ExeLibraryAttachable
- type ExeLinkAttachable
- type ExeScannable
- type KeyedCoordinator
- type MockProbe
- func (m *MockProbe) Attach(ctx context.Context, target *ExeLinkAttachable, result ProbeScanResult) (io.Closer, error)
- func (m *MockProbe) AttachLibrary(ctx context.Context, target *ExeLibraryAttachable, result ProbeScanResult) (io.Closer, error)
- func (m *MockProbe) Close() error
- func (m *MockProbe) EXPECT() *MockProbeMockRecorder
- func (m *MockProbe) Name() string
- func (m *MockProbe) Scan(ctx context.Context, target *ExeElfScannable) (ProbeScanResult, error)
- func (m *MockProbe) ScanLibrary(ctx context.Context, ef *binutils.Elf) (ProbeScanResult, error)
- func (m *MockProbe) SharedLibraries() string
- type MockProbeMockRecorder
- func (mr *MockProbeMockRecorder) Attach(ctx, target, result any) *gomock.Call
- func (mr *MockProbeMockRecorder) AttachLibrary(ctx, target, result any) *gomock.Call
- func (mr *MockProbeMockRecorder) Close() *gomock.Call
- func (mr *MockProbeMockRecorder) Name() *gomock.Call
- func (mr *MockProbeMockRecorder) Scan(ctx, target any) *gomock.Call
- func (mr *MockProbeMockRecorder) ScanLibrary(ctx, ef any) *gomock.Call
- func (mr *MockProbeMockRecorder) SharedLibraries() *gomock.Call
- type MockTargetScanner
- func (m *MockTargetScanner) Attach(ctx context.Context, attachable *ExeAttachable, res *ScanResult) (io.Closer, error)
- func (m *MockTargetScanner) AttachContainer(ctx context.Context, res *ContainerScanResult) (io.Closer, error)
- func (m *MockTargetScanner) Close() error
- func (m *MockTargetScanner) EXPECT() *MockTargetScannerMockRecorder
- func (m *MockTargetScanner) Scan(ctx context.Context, target *ExeScannable) (*ScanResult, error)
- func (m *MockTargetScanner) ScanContainer(ctx context.Context, id, root string) (*ContainerScanResult, error)
- type MockTargetScannerMockRecorder
- func (mr *MockTargetScannerMockRecorder) Attach(ctx, attachable, res any) *gomock.Call
- func (mr *MockTargetScannerMockRecorder) AttachContainer(ctx, res any) *gomock.Call
- func (mr *MockTargetScannerMockRecorder) Close() *gomock.Call
- func (mr *MockTargetScannerMockRecorder) Scan(ctx, target any) *gomock.Call
- func (mr *MockTargetScannerMockRecorder) ScanContainer(ctx, id, root any) *gomock.Call
- type MultiCloser
- type Probe
- type ProbeScanResult
- type ScanResult
- type SharedLibrary
- type TargetScanner
- type TargetScannerOption
- type TlsManager
- func (m *TlsManager) Close() error
- func (m *TlsManager) ProcessReplaced(ctx context.Context, proc *process.Process) error
- func (m *TlsManager) ProcessStarted(ctx context.Context, proc *process.Process) error
- func (m *TlsManager) ProcessStopped(ctx context.Context, proc *process.Process) error
- func (m *TlsManager) SetObserver(o TlsObserver)
- type TlsObserver
Constants ¶
const ( // DefaultCacheTTL is the default TTL for cached scan results DefaultCacheTTL = 10 * time.Minute // DefaultCacheCleanupInterval is the default interval for cache cleanup DefaultCacheCleanupInterval = 5 * time.Minute )
Variables ¶
var ErrOpSuperseded = errors.New("operation superseded")
Functions ¶
func AttachProbes ¶
func AttachProbes[T interface {
*link.Executable | *ExeLinkAttachable | *ExeLibraryAttachable
}](
ctx context.Context,
logger *zap.Logger,
target T,
symbols []elf.Symbol,
matchStrategy binutils.MatchStrategy,
probes []*common.Uprobe,
skipZeroAddresses bool,
) (io.Closer, error)
AttachProbes is helper for attaching uprobes to a pre-processed list of symbols.
func FindSharedLibrary ¶
func NewTargetScanner ¶
func NewTargetScanner(logger *zap.Logger, probes []Probe, opts ...TargetScannerOption) *targetScanner
NewTargetScanner creates a new TargetScanner with the given probes
Types ¶
type CloserFunc ¶
type CloserFunc func() error
CloserFunc is a helper type to implement the io.Closer interface.
func (CloserFunc) Close ¶
func (c CloserFunc) Close() error
type ContainerScanResult ¶
type ContainerScanResult struct {
SharedLibraries map[string]map[string]ProbeScanResult
}
type ExeAttachable ¶
type ExeElfScannable ¶
type ExeElfScannable struct {
ExeScannable
// Elf is the parsed ELF file. This the primary source of information in most cases.
Elf *binutils.Elf
}
ExeScannable contains information about a binary available during the scan phase.
type ExeLibraryAttachable ¶
type ExeLibraryAttachable struct {
Path string
Exe *link.Executable
}
type ExeLinkAttachable ¶
type ExeLinkAttachable struct {
ExeAttachable
Exe *link.Executable
}
type ExeScannable ¶
type KeyedCoordinator ¶
type KeyedCoordinator[K comparable] struct { // contains filtered or unexported fields }
KeyedCoordinator manages per-key operation coordination with version tracking. It ensures that only the latest operation for a given key proceeds, cancelling any in-flight operations when a newer one starts.
func NewKeyedCoordinator ¶
func NewKeyedCoordinator[K comparable]() *KeyedCoordinator[K]
func (*KeyedCoordinator[K]) Cleanup ¶
func (c *KeyedCoordinator[K]) Cleanup(key K, cancelInflight bool)
func (*KeyedCoordinator[K]) Start ¶
func (c *KeyedCoordinator[K]) Start(key K) *opToken[K]
Start begins a new operation for the given key and returns a token. The token can be used to check validity and execute the operation.
type MockProbe ¶
type MockProbe struct {
// contains filtered or unexported fields
}
MockProbe is a mock of Probe interface.
func NewMockProbe ¶
func NewMockProbe(ctrl *gomock.Controller) *MockProbe
NewMockProbe creates a new mock instance.
func (*MockProbe) Attach ¶
func (m *MockProbe) Attach(ctx context.Context, target *ExeLinkAttachable, result ProbeScanResult) (io.Closer, error)
Attach mocks base method.
func (*MockProbe) AttachLibrary ¶
func (m *MockProbe) AttachLibrary(ctx context.Context, target *ExeLibraryAttachable, result ProbeScanResult) (io.Closer, error)
AttachLibrary mocks base method.
func (*MockProbe) EXPECT ¶
func (m *MockProbe) EXPECT() *MockProbeMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockProbe) Scan ¶
func (m *MockProbe) Scan(ctx context.Context, target *ExeElfScannable) (ProbeScanResult, error)
Scan mocks base method.
func (*MockProbe) ScanLibrary ¶
ScanLibrary mocks base method.
func (*MockProbe) SharedLibraries ¶
SharedLibraries mocks base method.
type MockProbeMockRecorder ¶
type MockProbeMockRecorder struct {
// contains filtered or unexported fields
}
MockProbeMockRecorder is the mock recorder for MockProbe.
func (*MockProbeMockRecorder) Attach ¶
func (mr *MockProbeMockRecorder) Attach(ctx, target, result any) *gomock.Call
Attach indicates an expected call of Attach.
func (*MockProbeMockRecorder) AttachLibrary ¶
func (mr *MockProbeMockRecorder) AttachLibrary(ctx, target, result any) *gomock.Call
AttachLibrary indicates an expected call of AttachLibrary.
func (*MockProbeMockRecorder) Close ¶
func (mr *MockProbeMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close.
func (*MockProbeMockRecorder) Name ¶
func (mr *MockProbeMockRecorder) Name() *gomock.Call
Name indicates an expected call of Name.
func (*MockProbeMockRecorder) Scan ¶
func (mr *MockProbeMockRecorder) Scan(ctx, target any) *gomock.Call
Scan indicates an expected call of Scan.
func (*MockProbeMockRecorder) ScanLibrary ¶
func (mr *MockProbeMockRecorder) ScanLibrary(ctx, ef any) *gomock.Call
ScanLibrary indicates an expected call of ScanLibrary.
func (*MockProbeMockRecorder) SharedLibraries ¶
func (mr *MockProbeMockRecorder) SharedLibraries() *gomock.Call
SharedLibraries indicates an expected call of SharedLibraries.
type MockTargetScanner ¶
type MockTargetScanner struct {
// contains filtered or unexported fields
}
MockTargetScanner is a mock of TargetScanner interface.
func NewMockTargetScanner ¶
func NewMockTargetScanner(ctrl *gomock.Controller) *MockTargetScanner
NewMockTargetScanner creates a new mock instance.
func (*MockTargetScanner) Attach ¶
func (m *MockTargetScanner) Attach(ctx context.Context, attachable *ExeAttachable, res *ScanResult) (io.Closer, error)
Attach mocks base method.
func (*MockTargetScanner) AttachContainer ¶
func (m *MockTargetScanner) AttachContainer(ctx context.Context, res *ContainerScanResult) (io.Closer, error)
AttachContainer mocks base method.
func (*MockTargetScanner) Close ¶
func (m *MockTargetScanner) Close() error
Close mocks base method.
func (*MockTargetScanner) EXPECT ¶
func (m *MockTargetScanner) EXPECT() *MockTargetScannerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockTargetScanner) Scan ¶
func (m *MockTargetScanner) Scan(ctx context.Context, target *ExeScannable) (*ScanResult, error)
Scan mocks base method.
func (*MockTargetScanner) ScanContainer ¶
func (m *MockTargetScanner) ScanContainer(ctx context.Context, id, root string) (*ContainerScanResult, error)
ScanContainer mocks base method.
type MockTargetScannerMockRecorder ¶
type MockTargetScannerMockRecorder struct {
// contains filtered or unexported fields
}
MockTargetScannerMockRecorder is the mock recorder for MockTargetScanner.
func (*MockTargetScannerMockRecorder) Attach ¶
func (mr *MockTargetScannerMockRecorder) Attach(ctx, attachable, res any) *gomock.Call
Attach indicates an expected call of Attach.
func (*MockTargetScannerMockRecorder) AttachContainer ¶
func (mr *MockTargetScannerMockRecorder) AttachContainer(ctx, res any) *gomock.Call
AttachContainer indicates an expected call of AttachContainer.
func (*MockTargetScannerMockRecorder) Close ¶
func (mr *MockTargetScannerMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close.
func (*MockTargetScannerMockRecorder) Scan ¶
func (mr *MockTargetScannerMockRecorder) Scan(ctx, target any) *gomock.Call
Scan indicates an expected call of Scan.
func (*MockTargetScannerMockRecorder) ScanContainer ¶
func (mr *MockTargetScannerMockRecorder) ScanContainer(ctx, id, root any) *gomock.Call
ScanContainer indicates an expected call of ScanContainer.
type MultiCloser ¶
MultiCloser wraps multiple closers into a single Closer.
func (MultiCloser) Close ¶
func (m MultiCloser) Close() error
Close closes all wrapped closers, collecting any errors
type Probe ¶
type Probe interface {
// Name returns the unique identifier for this probe (e.g., "openssl")
Name() string
// Scan performs detailed analysis of the binary to gather all information needed for attaching probes.
// If the probe does not detect anything, it should return a ProbeScanResult with ProbeDetected() == false.
//
// The returned ProbeScanResult may be cached and reused across process restarts for future Attach calls.
Scan(ctx context.Context, target *ExeElfScannable) (ProbeScanResult, error)
// Attach attaches probes to the process using the scan result.
//
// Returns a Closer that must be called when the process exits to clean up the probes.
Attach(ctx context.Context, target *ExeLinkAttachable, result ProbeScanResult) (io.Closer, error)
//
// The string is a library name prefix (e.g., "libssl.so", "libcrypto.so")
SharedLibraries() string
// ScanLibrary scans a shared library for TLS probe attachment points.
// This will be called for each of the libraries returned by SharedLibraries() that were found.
ScanLibrary(ctx context.Context, ef *binutils.Elf) (ProbeScanResult, error)
// AttachLibrary attaches probes to a shared library.
AttachLibrary(ctx context.Context, target *ExeLibraryAttachable, result ProbeScanResult) (io.Closer, error)
// Close cleans up any global resources used by the probe.
Close() error
}
Probe describes a TLS probe that can be attached to a shared library or binary target.
type ProbeScanResult ¶
type ProbeScanResult interface {
// ProbeName returns the name of the probe that produced this result
ProbeName() string
// ProbeDetected returns true if the probe was detected in the binary.
ProbeDetected() bool
}
ProbeScanResult contains the results of scanning a binary for TLS probe attachment points. Each probe defines its own concrete type that implements this interface.
type ScanResult ¶
type ScanResult struct {
Hash string
Mtime int64
// ProbeResults is a map of probe name to scan result
ProbeResults map[string]ProbeScanResult
}
ScanResult is the result of scanning a target
type SharedLibrary ¶
SharedLibrary represents a shared library that a probe can attach to.
func FindSharedLibraries ¶
func FindSharedLibraries(ctx context.Context, root string, libNamePrefixes []string) ([]*SharedLibrary, error)
FindSharedLibraries searches for shared libraries in a filesystem root.
type TargetScanner ¶
type TargetScanner interface {
Scan(ctx context.Context, target *ExeScannable) (*ScanResult, error)
Attach(ctx context.Context, attachable *ExeAttachable, res *ScanResult) (io.Closer, error)
ScanContainer(ctx context.Context, id, root string) (*ContainerScanResult, error)
AttachContainer(ctx context.Context, res *ContainerScanResult) (io.Closer, error)
Close() error
}
type TargetScannerOption ¶
type TargetScannerOption func(*targetScanner)
TargetScannerOption configures the TargetScanner
type TlsManager ¶
type TlsManager struct {
// contains filtered or unexported fields
}
TlsManager monitors processes and containers and ensures they are scanned and attached to the correct probes. It bridges between the process manager (via process.Observer) and the target scanner.
func NewTlsManager ¶
func NewTlsManager(logger *zap.Logger, scanner TargetScanner) *TlsManager
NewTlsManager creates a new TlsManager with the given options.
func (*TlsManager) Close ¶
func (m *TlsManager) Close() error
func (*TlsManager) ProcessReplaced ¶
ProcessReplaced handles when a process's binary is replaced (via exec())
func (*TlsManager) ProcessStarted ¶
ProcessStarted scans a process binary and attaches applicable TLS probes. It runs all scanners concurrently and caches results by binary hash. Returns a combined Detacher for all attached probes.
func (*TlsManager) ProcessStopped ¶
ProcessStopped cleans up when a process exits
func (*TlsManager) SetObserver ¶
func (m *TlsManager) SetObserver(o TlsObserver)
type TlsObserver ¶
type TlsObserver interface {
ProcessScanStarted(ctx context.Context, proc *process.Process) error
ProcessAttachCompleted(ctx context.Context, proc *process.Process) error
ProcessStopped(ctx context.Context, proc *process.Process) error
ContainerScanStarted(ctx context.Context, id string) error
ContainerAttachCompleted(ctx context.Context, id string) error
}