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

[CWS] remove some vars from event types #33910

Merged
merged 1 commit into from
Feb 12, 2025
Merged
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
19 changes: 10 additions & 9 deletions pkg/security/ebpf/probes/event_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,15 @@ func NetworkSelectors() []manager.ProbesSelector {
}

// SyscallMonitorSelectors is the list of probes that should be activated for the syscall monitor feature
var SyscallMonitorSelectors = []manager.ProbesSelector{
&manager.ProbeSelector{ProbeIdentificationPair: manager.ProbeIdentificationPair{UID: SecurityAgentUID, EBPFFuncName: "sys_enter"}},
func SyscallMonitorSelectors() []manager.ProbesSelector {
return []manager.ProbesSelector{
&manager.ProbeSelector{
ProbeIdentificationPair: manager.ProbeIdentificationPair{
UID: SecurityAgentUID,
EBPFFuncName: "sys_enter",
},
},
}
}

// SnapshotSelectors selectors required during the snapshot
Expand All @@ -92,15 +99,9 @@ func SnapshotSelectors(fentry bool) []manager.ProbesSelector {
}
}

var selectorsPerEventTypeStore map[eval.EventType][]manager.ProbesSelector

// GetSelectorsPerEventType returns the list of probes that should be activated for each event
func GetSelectorsPerEventType(fentry bool) map[eval.EventType][]manager.ProbesSelector {
if selectorsPerEventTypeStore != nil {
return selectorsPerEventTypeStore
}

selectorsPerEventTypeStore = map[eval.EventType][]manager.ProbesSelector{
selectorsPerEventTypeStore := map[eval.EventType][]manager.ProbesSelector{
// The following probes will always be activated, regardless of the loaded rules
"*": {
// Exec probes
Expand Down
10 changes: 5 additions & 5 deletions pkg/security/probe/probe_ebpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -1537,13 +1537,13 @@ func (p *EBPFProbe) updateProbes(ruleEventTypes []eval.EventType, needRawSyscall
}

if needRawSyscalls {
activatedProbes = append(activatedProbes, probes.SyscallMonitorSelectors...)
activatedProbes = append(activatedProbes, probes.SyscallMonitorSelectors()...)
} else {
// ActivityDumps
if p.config.RuntimeSecurity.ActivityDumpEnabled {
for _, e := range p.profileManagers.GetActivityDumpTracedEventTypes() {
if e == model.SyscallsEventType {
activatedProbes = append(activatedProbes, probes.SyscallMonitorSelectors...)
activatedProbes = append(activatedProbes, probes.SyscallMonitorSelectors()...)
break
}
}
Expand All @@ -1552,7 +1552,7 @@ func (p *EBPFProbe) updateProbes(ruleEventTypes []eval.EventType, needRawSyscall
if p.config.RuntimeSecurity.AnomalyDetectionEnabled {
for _, e := range p.profileManagers.GetAnomalyDetectionEventTypes() {
if e == model.SyscallsEventType {
activatedProbes = append(activatedProbes, probes.SyscallMonitorSelectors...)
activatedProbes = append(activatedProbes, probes.SyscallMonitorSelectors()...)
break
}
}
Expand Down Expand Up @@ -2178,7 +2178,7 @@ func (p *EBPFProbe) initManagerOptionsActivatedProbes(config *config.Config) {
for _, e := range config.RuntimeSecurity.ActivityDumpTracedEventTypes {
if e == model.SyscallsEventType {
// Add syscall monitor probes
p.managerOptions.ActivatedProbes = append(p.managerOptions.ActivatedProbes, probes.SyscallMonitorSelectors...)
p.managerOptions.ActivatedProbes = append(p.managerOptions.ActivatedProbes, probes.SyscallMonitorSelectors()...)
break
}
}
Expand All @@ -2187,7 +2187,7 @@ func (p *EBPFProbe) initManagerOptionsActivatedProbes(config *config.Config) {
for _, e := range config.RuntimeSecurity.AnomalyDetectionEventTypes {
if e == model.SyscallsEventType {
// Add syscall monitor probes
p.managerOptions.ActivatedProbes = append(p.managerOptions.ActivatedProbes, probes.SyscallMonitorSelectors...)
p.managerOptions.ActivatedProbes = append(p.managerOptions.ActivatedProbes, probes.SyscallMonitorSelectors()...)
break
}
}
Expand Down
Loading