Skip to content

Commit 72f798c

Browse files
authored
Merge pull request #73 from kubescape/feature/upper-layer
Feature/upper layer
2 parents 5e0246b + 4dfb16f commit 72f798c

File tree

5 files changed

+20
-14
lines changed

5 files changed

+20
-14
lines changed

etc/app-profile.crd.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ spec:
6161
type: string
6262
path:
6363
type: string
64+
upperLayer:
65+
type: boolean
6466
name:
6567
type: string
6668
opens:

pkg/collector/collector.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,10 @@ func (cm *CollectorManager) CollectContainerEvents(id *ContainerId) {
338338
// Check if execve event is already in container profile or if it has no path name (Some execve events do not have a path name).
339339
if !execEventExists(event, containerProfile.Execs) || event.PathName == "" {
340340
containerProfile.Execs = append(containerProfile.Execs, ExecCalls{
341-
Path: event.PathName,
342-
Args: event.Args,
343-
Envs: event.Env,
341+
Path: event.PathName,
342+
UpperLayer: event.UpperLayer,
343+
Args: event.Args,
344+
Envs: event.Env,
344345
})
345346
}
346347
}
@@ -571,7 +572,7 @@ func (cm *CollectorManager) mergeApplicationProfiles(existingApplicationProfile
571572
// Merge execve events
572573
filteredExecs := []ExecCalls{}
573574
for _, exec := range containerProfile.Execs {
574-
if !execEventExists(&tracing.ExecveEvent{PathName: exec.Path, Args: exec.Args, Env: exec.Envs}, existingContainer.Execs) {
575+
if !execEventExists(&tracing.ExecveEvent{PathName: exec.Path, UpperLayer: exec.UpperLayer, Args: exec.Args, Env: exec.Envs}, existingContainer.Execs) {
575576
filteredExecs = append(filteredExecs, exec)
576577
}
577578
}
@@ -768,7 +769,7 @@ func (cm *CollectorManager) OnContainerActivityEvent(event *tracing.ContainerAct
768769

769770
func execEventExists(execEvent *tracing.ExecveEvent, execCalls []ExecCalls) bool {
770771
for _, call := range execCalls {
771-
if execEvent.PathName == call.Path && slices.Equal(execEvent.Args, call.Args) && slices.Equal(execEvent.Env, call.Envs) {
772+
if execEvent.PathName == call.Path && slices.Equal(execEvent.Args, call.Args) && slices.Equal(execEvent.Env, call.Envs) && execEvent.UpperLayer == call.UpperLayer {
772773
return true
773774
}
774775
}

pkg/collector/types.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import (
66
)
77

88
type ExecCalls struct {
9-
Path string `json:"path" yaml:"path"`
10-
Args []string `json:"args" yaml:"args"`
11-
Envs []string `json:"envs" yaml:"envs"`
9+
Path string `json:"path" yaml:"path"`
10+
UpperLayer bool `json:"upperLayer" yaml:"upperLayer"`
11+
Args []string `json:"args" yaml:"args"`
12+
Envs []string `json:"envs" yaml:"envs"`
1213
}
1314

1415
type NetworkCalls struct {

pkg/tracing/events.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ type GeneralEvent struct {
5858
type ExecveEvent struct {
5959
GeneralEvent
6060

61-
PathName string
62-
Args []string
63-
Env []string
61+
PathName string
62+
UpperLayer bool
63+
Args []string
64+
Env []string
6465
}
6566

6667
type OpenEvent struct {

pkg/tracing/ig.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,10 @@ func (t *Tracer) execEventCallback(event *tracerexectype.Event) {
408408
Timestamp: int64(event.Timestamp),
409409
EventType: ExecveEventType,
410410
},
411-
PathName: event.Args[0],
412-
Args: event.Args[1:],
413-
Env: []string{},
411+
PathName: event.Args[0],
412+
UpperLayer: event.UpperLayer,
413+
Args: event.Args[1:],
414+
Env: []string{},
414415
}
415416
for _, eventSink := range t.eventSinks {
416417
eventSink.SendExecveEvent(execveEvent)

0 commit comments

Comments
 (0)