-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #822 from Essietom/main
- Loading branch information
Showing
3 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright 2022 Authors of KubeArmor | ||
|
||
package core | ||
|
||
import ( | ||
kl "github.com/kubearmor/KubeArmor/KubeArmor/common" | ||
cfg "github.com/kubearmor/KubeArmor/KubeArmor/config" | ||
tp "github.com/kubearmor/KubeArmor/KubeArmor/types" | ||
) | ||
|
||
type KarmorData struct { | ||
OSImage string | ||
KernelVersion string | ||
KubeletVersion string | ||
ContainerRuntime string | ||
ActiveLSM string | ||
KernelHeaderPresent bool | ||
HostSecurity bool | ||
ContainerSecurity bool | ||
ContainerDefaultPosture tp.DefaultPosture | ||
HostDefaultPosture tp.DefaultPosture | ||
} | ||
|
||
// SetKarmorData generates runtime configuration for KubeArmor to be consumed by kArmor | ||
func (dm *KubeArmorDaemon) SetKarmorData() { | ||
var kd KarmorData | ||
|
||
kd.ContainerDefaultPosture = tp.DefaultPosture{ | ||
FileAction: cfg.GlobalCfg.DefaultFilePosture, | ||
NetworkAction: cfg.GlobalCfg.DefaultNetworkPosture, | ||
CapabilitiesAction: cfg.GlobalCfg.DefaultCapabilitiesPosture, | ||
} | ||
kd.HostDefaultPosture = tp.DefaultPosture{ | ||
FileAction: cfg.GlobalCfg.HostDefaultFilePosture, | ||
NetworkAction: cfg.GlobalCfg.HostDefaultNetworkPosture, | ||
CapabilitiesAction: cfg.GlobalCfg.HostDefaultCapabilitiesPosture, | ||
} | ||
|
||
kd.OSImage = dm.Node.OSImage | ||
kd.ContainerRuntime = dm.Node.ContainerRuntimeVersion | ||
kd.KernelVersion = dm.Node.KernelVersion | ||
kd.KubeletVersion = dm.Node.KubeletVersion | ||
kd.ContainerRuntime = dm.Node.ContainerRuntimeVersion | ||
if dm.RuntimeEnforcer != nil { | ||
kd.ActiveLSM = dm.RuntimeEnforcer.EnforcerType | ||
|
||
if cfg.GlobalCfg.Policy { | ||
kd.ContainerSecurity = true | ||
} | ||
if cfg.GlobalCfg.HostPolicy { | ||
kd.HostSecurity = true | ||
} | ||
} | ||
kd.KernelHeaderPresent = true //this is always true since KubeArmor is running | ||
err := kl.WriteToFile(kd, "/tmp/karmorProbeData.cfg") | ||
if err != nil { | ||
dm.Logger.Errf("Error writing karmor config data", err) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters