Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EBPF] attacher: Add Log() call to registry #31390

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/ebpf/uprobes/attacher.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ type FileRegistry interface {

// GetRegisteredProcesses returns a map of all the processes that are currently registered in the registry
GetRegisteredProcesses() map[uint32]struct{}

// Log is a function that gets called periodically to log the state of the registry
Log()
}

// AttachCallback is a callback that is called whenever a probe is attached successfully
Expand Down Expand Up @@ -464,6 +467,9 @@ func (ua *UprobeAttacher) Start() error {
case <-processSync.C:
// We always track process deletions in the scan, to avoid memory leaks.
_ = ua.Sync(ua.config.EnablePeriodicScanNewProcesses, true)

// Periodically log the state of the registry
ua.fileRegistry.Log()
case event, ok := <-sharedLibDataChan:
if !ok {
return
Expand Down
3 changes: 3 additions & 0 deletions pkg/ebpf/uprobes/attacher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ func TestMonitor(t *testing.T) {

// Tell mockRegistry to return on any calls, we will check the values later
mockRegistry.On("Clear").Return()
mockRegistry.On("Log").Return()
mockRegistry.On("Unregister", mock.Anything).Return(nil)
mockRegistry.On("Register", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil)
lib := getLibSSLPath(t)
Expand Down Expand Up @@ -822,6 +823,7 @@ func (s *SharedLibrarySuite) TestSingleFile() {

// Tell mockRegistry to return on any calls, we will check the values later
mockRegistry.On("Clear").Return()
mockRegistry.On("Log").Return()
mockRegistry.On("Unregister", mock.Anything).Return(nil)
mockRegistry.On("Register", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil)

Expand Down Expand Up @@ -899,6 +901,7 @@ func (s *SharedLibrarySuite) TestDetectionWithPIDAndRootNamespace() {

// Tell mockRegistry to return on any calls, we will check the values later
mockRegistry.On("Clear").Return()
mockRegistry.On("Log").Return()
mockRegistry.On("Unregister", mock.Anything).Return(nil)
mockRegistry.On("Register", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil)

Expand Down
5 changes: 5 additions & 0 deletions pkg/ebpf/uprobes/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ func (m *MockFileRegistry) GetRegisteredProcesses() map[uint32]struct{} {
return args.Get(0).(map[uint32]struct{})
}

// Log is a mock implementation of the FileRegistry.Log method.
func (m *MockFileRegistry) Log() {
m.Called()
}

// MockBinaryInspector is a mock implementation of the BinaryInspector interface.
type MockBinaryInspector struct {
mock.Mock
Expand Down
Loading