This repository has been archived by the owner on Oct 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* define schema for config file and add cobra flag to specify config * initialize root logic for kubeauditConfig * push logic to PodOverride, prior to testing * pre-testing build * add support for custom capabilities * finalize tests and update readme * cleanup the mess * add override for netpols * add netpol feature to auditconfig override and add suggestion * add from config to file names * set nill auditConfig for test * reset auditConfig flag after use in testing suite * reset back * get rid extra newline * temp commit to change filenames to lowecase * revert back * oops forgot about the README * increase test coverage * add headsup for unmarshling unreachability
- Loading branch information
Showing
26 changed files
with
523 additions
and
60 deletions.
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
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
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,81 @@ | ||
package cmd | ||
|
||
import "reflect" | ||
|
||
func dropCapFromConfigList(capList *KubeauditConfigCapabilities) (dropCapSet CapSet) { | ||
var configCapabilityValue reflect.Value | ||
var r reflect.Value | ||
dropCapSet = make(CapSet) | ||
r = reflect.ValueOf(capList) | ||
configCapabilityValue = reflect.Indirect(r).FieldByName("SetPCAP") | ||
if configCapabilityValue.String() == "drop" { | ||
dropCapSet[CapabilityV1("SETPCAP")] = true | ||
} | ||
|
||
configCapabilityValue = reflect.Indirect(r).FieldByName("MKNOD") | ||
if configCapabilityValue.String() == "drop" { | ||
dropCapSet[CapabilityV1("MKNOD")] = true | ||
} | ||
|
||
configCapabilityValue = reflect.Indirect(r).FieldByName("AuditWrite") | ||
if configCapabilityValue.String() == "drop" { | ||
dropCapSet[CapabilityV1("AUDIT_WRITE")] = true | ||
} | ||
|
||
configCapabilityValue = reflect.Indirect(r).FieldByName("Chown") | ||
if configCapabilityValue.String() == "drop" { | ||
dropCapSet[CapabilityV1("CHOWN")] = true | ||
} | ||
|
||
configCapabilityValue = reflect.Indirect(r).FieldByName("NetRaw") | ||
if configCapabilityValue.String() == "drop" { | ||
dropCapSet[CapabilityV1("NET_RAW")] = true | ||
} | ||
|
||
configCapabilityValue = reflect.Indirect(r).FieldByName("DacOverride") | ||
if configCapabilityValue.String() == "drop" { | ||
dropCapSet[CapabilityV1("DAC_OVERRIDE")] = true | ||
} | ||
|
||
configCapabilityValue = reflect.Indirect(r).FieldByName("FOWNER") | ||
if configCapabilityValue.String() == "drop" { | ||
dropCapSet[CapabilityV1("FOWNER")] = true | ||
} | ||
|
||
configCapabilityValue = reflect.Indirect(r).FieldByName("FSetID") | ||
if configCapabilityValue.String() == "drop" { | ||
dropCapSet[CapabilityV1("FSETID")] = true | ||
} | ||
|
||
configCapabilityValue = reflect.Indirect(r).FieldByName("Kill") | ||
if configCapabilityValue.String() == "drop" { | ||
dropCapSet[CapabilityV1("KILL")] = true | ||
} | ||
|
||
configCapabilityValue = reflect.Indirect(r).FieldByName("SetGID") | ||
if configCapabilityValue.String() == "drop" { | ||
dropCapSet[CapabilityV1("SETGID")] = true | ||
} | ||
|
||
configCapabilityValue = reflect.Indirect(r).FieldByName("SetUID") | ||
if configCapabilityValue.String() == "drop" { | ||
dropCapSet[CapabilityV1("SETUID")] = true | ||
} | ||
|
||
configCapabilityValue = reflect.Indirect(r).FieldByName("NetBindService") | ||
if configCapabilityValue.String() == "drop" { | ||
dropCapSet[CapabilityV1("NET_BIND_SERVICE")] = true | ||
} | ||
|
||
configCapabilityValue = reflect.Indirect(r).FieldByName("SYSChroot") | ||
if configCapabilityValue.String() == "drop" { | ||
dropCapSet[CapabilityV1("SYS_CHROOT")] = true | ||
} | ||
|
||
configCapabilityValue = reflect.Indirect(r).FieldByName("SetFCAP") | ||
if configCapabilityValue.String() == "drop" { | ||
dropCapSet[CapabilityV1("SETFCAP")] = true | ||
} | ||
|
||
return dropCapSet | ||
} |
Oops, something went wrong.