Skip to content

Commit

Permalink
[CWS] move cgroup context in linux specific serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
safchain committed Dec 18, 2024
1 parent 332025d commit bc3b56a
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 155 deletions.
8 changes: 4 additions & 4 deletions docs/cloud-workload-security/backend_linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -1718,9 +1718,6 @@ CSM Threats event for Linux systems have the following JSON schema:
"container": {
"$ref": "#/$defs/ContainerContext"
},
"cgroup": {
"$ref": "#/$defs/CGroupContext"
},
"network": {
"$ref": "#/$defs/NetworkContext"
},
Expand All @@ -1730,6 +1727,9 @@ CSM Threats event for Linux systems have the following JSON schema:
"security_profile": {
"$ref": "#/$defs/SecurityProfileContext"
},
"cgroup": {
"$ref": "#/$defs/CGroupContext"
},
"selinux": {
"$ref": "#/$defs/SELinuxEvent"
},
Expand Down Expand Up @@ -1802,10 +1802,10 @@ CSM Threats event for Linux systems have the following JSON schema:
| `exit` | $ref | Please see [ExitEvent](#exitevent) |
| `process` | $ref | Please see [ProcessContext](#processcontext) |
| `container` | $ref | Please see [ContainerContext](#containercontext) |
| `cgroup` | $ref | Please see [CGroupContext](#cgroupcontext) |
| `network` | $ref | Please see [NetworkContext](#networkcontext) |
| `dd` | $ref | Please see [DDContext](#ddcontext) |
| `security_profile` | $ref | Please see [SecurityProfileContext](#securityprofilecontext) |
| `cgroup` | $ref | Please see [CGroupContext](#cgroupcontext) |
| `selinux` | $ref | Please see [SELinuxEvent](#selinuxevent) |
| `bpf` | $ref | Please see [BPFEvent](#bpfevent) |
| `mmap` | $ref | Please see [MMapEvent](#mmapevent) |
Expand Down
6 changes: 3 additions & 3 deletions docs/cloud-workload-security/backend_linux.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1707,9 +1707,6 @@
"container": {
"$ref": "#/$defs/ContainerContext"
},
"cgroup": {
"$ref": "#/$defs/CGroupContext"
},
"network": {
"$ref": "#/$defs/NetworkContext"
},
Expand All @@ -1719,6 +1716,9 @@
"security_profile": {
"$ref": "#/$defs/SecurityProfileContext"
},
"cgroup": {
"$ref": "#/$defs/CGroupContext"
},
"selinux": {
"$ref": "#/$defs/SELinuxEvent"
},
Expand Down
10 changes: 0 additions & 10 deletions pkg/security/serializers/serializers_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@ import (
"github.com/DataDog/datadog-agent/pkg/util/scrubber"
)

// CGroupContextSerializer serializes a cgroup context to JSON
// easyjson:json
type CGroupContextSerializer struct {
// CGroup ID
ID string `json:"id,omitempty"`
// CGroup manager
Manager string `json:"manager,omitempty"`
}

// ContainerContextSerializer serializes a container context to JSON
// easyjson:json
type ContainerContextSerializer struct {
Expand Down Expand Up @@ -213,7 +204,6 @@ type BaseEventSerializer struct {
*ExitEventSerializer `json:"exit,omitempty"`
*ProcessContextSerializer `json:"process,omitempty"`
*ContainerContextSerializer `json:"container,omitempty"`
*CGroupContextSerializer `json:"cgroup,omitempty"`
}

// TLSContextSerializer defines a tls context serializer
Expand Down
110 changes: 12 additions & 98 deletions pkg/security/serializers/serializers_base_linux_easyjson.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions pkg/security/serializers/serializers_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ type FileSerializer struct {
MountOrigin string `json:"mount_origin,omitempty"`
}

// CGroupContextSerializer serializes a cgroup context to JSON
// easyjson:json
type CGroupContextSerializer struct {
// CGroup ID
ID string `json:"id,omitempty"`
// CGroup manager
Manager string `json:"manager,omitempty"`
}

// UserContextSerializer serializes a user context to JSON
// easyjson:json
type UserContextSerializer struct {
Expand Down Expand Up @@ -622,6 +631,7 @@ type EventSerializer struct {
*NetworkContextSerializer `json:"network,omitempty"`
*DDContextSerializer `json:"dd,omitempty"`
*SecurityProfileContextSerializer `json:"security_profile,omitempty"`
*CGroupContextSerializer `json:"cgroup,omitempty"`

*SELinuxEventSerializer `json:"selinux,omitempty"`
*BPFEventSerializer `json:"bpf,omitempty"`
Expand Down
Loading

0 comments on commit bc3b56a

Please sign in to comment.