Skip to content

Commit 5b40f43

Browse files
authored
[CWS] remove some vars from event types (#33910)
1 parent 32d77d9 commit 5b40f43

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

pkg/security/ebpf/probes/event_types.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,15 @@ func NetworkSelectors() []manager.ProbesSelector {
7575
}
7676

7777
// SyscallMonitorSelectors is the list of probes that should be activated for the syscall monitor feature
78-
var SyscallMonitorSelectors = []manager.ProbesSelector{
79-
&manager.ProbeSelector{ProbeIdentificationPair: manager.ProbeIdentificationPair{UID: SecurityAgentUID, EBPFFuncName: "sys_enter"}},
78+
func SyscallMonitorSelectors() []manager.ProbesSelector {
79+
return []manager.ProbesSelector{
80+
&manager.ProbeSelector{
81+
ProbeIdentificationPair: manager.ProbeIdentificationPair{
82+
UID: SecurityAgentUID,
83+
EBPFFuncName: "sys_enter",
84+
},
85+
},
86+
}
8087
}
8188

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

95-
var selectorsPerEventTypeStore map[eval.EventType][]manager.ProbesSelector
96-
97102
// GetSelectorsPerEventType returns the list of probes that should be activated for each event
98103
func GetSelectorsPerEventType(fentry bool) map[eval.EventType][]manager.ProbesSelector {
99-
if selectorsPerEventTypeStore != nil {
100-
return selectorsPerEventTypeStore
101-
}
102-
103-
selectorsPerEventTypeStore = map[eval.EventType][]manager.ProbesSelector{
104+
selectorsPerEventTypeStore := map[eval.EventType][]manager.ProbesSelector{
104105
// The following probes will always be activated, regardless of the loaded rules
105106
"*": {
106107
// Exec probes

pkg/security/probe/probe_ebpf.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,13 +1537,13 @@ func (p *EBPFProbe) updateProbes(ruleEventTypes []eval.EventType, needRawSyscall
15371537
}
15381538

15391539
if needRawSyscalls {
1540-
activatedProbes = append(activatedProbes, probes.SyscallMonitorSelectors...)
1540+
activatedProbes = append(activatedProbes, probes.SyscallMonitorSelectors()...)
15411541
} else {
15421542
// ActivityDumps
15431543
if p.config.RuntimeSecurity.ActivityDumpEnabled {
15441544
for _, e := range p.profileManagers.GetActivityDumpTracedEventTypes() {
15451545
if e == model.SyscallsEventType {
1546-
activatedProbes = append(activatedProbes, probes.SyscallMonitorSelectors...)
1546+
activatedProbes = append(activatedProbes, probes.SyscallMonitorSelectors()...)
15471547
break
15481548
}
15491549
}
@@ -1552,7 +1552,7 @@ func (p *EBPFProbe) updateProbes(ruleEventTypes []eval.EventType, needRawSyscall
15521552
if p.config.RuntimeSecurity.AnomalyDetectionEnabled {
15531553
for _, e := range p.profileManagers.GetAnomalyDetectionEventTypes() {
15541554
if e == model.SyscallsEventType {
1555-
activatedProbes = append(activatedProbes, probes.SyscallMonitorSelectors...)
1555+
activatedProbes = append(activatedProbes, probes.SyscallMonitorSelectors()...)
15561556
break
15571557
}
15581558
}
@@ -2178,7 +2178,7 @@ func (p *EBPFProbe) initManagerOptionsActivatedProbes(config *config.Config) {
21782178
for _, e := range config.RuntimeSecurity.ActivityDumpTracedEventTypes {
21792179
if e == model.SyscallsEventType {
21802180
// Add syscall monitor probes
2181-
p.managerOptions.ActivatedProbes = append(p.managerOptions.ActivatedProbes, probes.SyscallMonitorSelectors...)
2181+
p.managerOptions.ActivatedProbes = append(p.managerOptions.ActivatedProbes, probes.SyscallMonitorSelectors()...)
21822182
break
21832183
}
21842184
}
@@ -2187,7 +2187,7 @@ func (p *EBPFProbe) initManagerOptionsActivatedProbes(config *config.Config) {
21872187
for _, e := range config.RuntimeSecurity.AnomalyDetectionEventTypes {
21882188
if e == model.SyscallsEventType {
21892189
// Add syscall monitor probes
2190-
p.managerOptions.ActivatedProbes = append(p.managerOptions.ActivatedProbes, probes.SyscallMonitorSelectors...)
2190+
p.managerOptions.ActivatedProbes = append(p.managerOptions.ActivatedProbes, probes.SyscallMonitorSelectors()...)
21912191
break
21922192
}
21932193
}

0 commit comments

Comments
 (0)