Skip to content
This repository has been archived by the owner on Oct 30, 2024. It is now read-only.

adds support for sarif output #453

Merged
merged 31 commits into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2ac78db
captures auditor name in the result
dani-santos-code Jul 8, 2022
809dacd
adds file path to audit result - for sarif location
dani-santos-code Jul 8, 2022
184bfc7
adds sarif internal pkg
dani-santos-code Jul 8, 2022
c17b5ec
supports sarif flag to output the desired format
dani-santos-code Jul 8, 2022
f245a9a
renames result field
dani-santos-code Jul 11, 2022
69491ea
removes extra function with duplicate logic
dani-santos-code Jul 11, 2022
56f6269
tests rule occurrences
dani-santos-code Jul 12, 2022
dfd6b54
refactor sarif pkg and fix broken tests
dani-santos-code Jul 12, 2022
a70ec3a
adds more tests
dani-santos-code Jul 18, 2022
b7ae4eb
try json validation
dani-santos-code Jul 19, 2022
bdcc226
adds sarif validation tests
dani-santos-code Jul 19, 2022
f18847a
adds more tests and fixes json validation
dani-santos-code Jul 20, 2022
05ed3ba
adds violations to rules mapping
dani-santos-code Jul 20, 2022
f845c3e
refactors filepath test
dani-santos-code Jul 20, 2022
6bfc66b
adds more info on what kubeaudit does
dani-santos-code Jul 20, 2022
555562e
adds test assertion, description, fixes
dani-santos-code Jul 22, 2022
1687df9
check that rules are only added when violations found
dani-santos-code Jul 22, 2022
6f633ec
separates test for config file with no kubeuadit errors
dani-santos-code Jul 25, 2022
edae749
rebases against main - explicit markdown
dani-santos-code Jul 25, 2022
2ba56a8
fixt: expected vs actual test order
dani-santos-code Jul 25, 2022
c486c0a
feedback - part1
dani-santos-code Aug 1, 2022
36ffd3b
feedback: adds subtests
dani-santos-code Aug 1, 2022
2f32539
genevieve's feedback - pt 1
dani-santos-code Aug 10, 2022
a386749
feedback pt 2:removes sarif flag
dani-santos-code Aug 16, 2022
d6072b1
pete's feedback: add missing auditor name to redundant override
dani-santos-code Aug 16, 2022
c492afa
removes uneccessary mapping and reassigning
dani-santos-code Aug 16, 2022
f06028a
more feedback: validate func arguments - implementation vs interface)
dani-santos-code Aug 16, 2022
6b094a1
feedback: removes validation -air gapped envs
dani-santos-code Aug 16, 2022
b1b6a04
feedback: removes stdin dash appended to filepath
dani-santos-code Aug 17, 2022
bfd28db
Update README.md
dani-santos-code Aug 17, 2022
f539847
removes ref to flag and violations to rules mapping
dani-santos-code Aug 17, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ The minimum severity level can be set using the `--minSeverity/-m` flag.

By default kubeaudit will output results in a human-readable way. If the output is intended to be further processed, it can be set to output JSON using the `--format json` flag. To output results as logs (the previous default) use `--format logrus`. Some output formats include colors to make results easier to read in a terminal. To disable colors (for example, if you are sending output to a text file), you can use the `--no-color` flag.

You can generate a kubeaudit report in [SARIF](https://docs.oasis-open.org/sarif/sarif/v2.0/sarif-v2.0.html) and write it to a file by using the `-s/--sarif` flag.

If there are results of severity level `error`, kubeaudit will exit with exit code 2. This can be changed using the `--exitcode/-e` flag.

For all the ways kubeaudit can be customized, see [Global Flags](#global-flags).
Expand Down Expand Up @@ -221,6 +223,7 @@ Auditors can also be run individually.
| -m | --minseverity | Set the lowest severity level to report (one of "error", "warning", "info") (default is "info") |
| -e | --exitcode | Exit code to use if there are results with severity of "error". Conventionally, 0 is used for success and all non-zero codes for an error. (default is 2) |
| | --no-color | Don't use colors in the output (default is false) |
| -s | --sarif | The file location to save the SARIF output |

## Configuration File

Expand Down
9 changes: 6 additions & 3 deletions auditors/apparmor/apparmor.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ func auditContainer(container *k8s.ContainerV1, resource k8s.Resource) *kubeaudi

if isAppArmorAnnotationMissing(containerAnnotation, annotations) {
return &kubeaudit.AuditResult{
Name: AppArmorAnnotationMissing,
Auditor: Name,
Rule: AppArmorAnnotationMissing,
Severity: kubeaudit.Error,
Message: fmt.Sprintf("AppArmor annotation missing. The annotation '%s' should be added.", containerAnnotation),
Metadata: kubeaudit.Metadata{
Expand All @@ -80,7 +81,8 @@ func auditContainer(container *k8s.ContainerV1, resource k8s.Resource) *kubeaudi

if isAppArmorDisabled(containerAnnotation, annotations) {
return &kubeaudit.AuditResult{
Name: AppArmorDisabled,
Auditor: Name,
Rule: AppArmorDisabled,
Message: fmt.Sprintf("AppArmor is disabled. The apparmor annotation should be set to '%s' or start with '%s'.", ProfileRuntimeDefault, ProfileNamePrefix),
Severity: kubeaudit.Error,
Metadata: kubeaudit.Metadata{
Expand All @@ -107,7 +109,8 @@ func auditPodAnnotations(resource k8s.Resource, containerNames []string) []*kube
containerName := strings.Split(annotationKey, "/")[1]
if !contains(containerNames, containerName) {
auditResults = append(auditResults, &kubeaudit.AuditResult{
Name: AppArmorInvalidAnnotation,
Auditor: Name,
Rule: AppArmorInvalidAnnotation,
Severity: kubeaudit.Error,
Message: fmt.Sprintf("AppArmor annotation key refers to a container that doesn't exist. Remove the annotation '%s: %s'.", annotationKey, annotationValue),
Metadata: kubeaudit.Metadata{
Expand Down
6 changes: 4 additions & 2 deletions auditors/asat/asat.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ func auditResource(resource k8s.Resource, resources []k8s.Resource) *kubeaudit.A

if isDeprecatedServiceAccountName(podSpec) && !hasServiceAccountName(podSpec) {
return &kubeaudit.AuditResult{
Name: AutomountServiceAccountTokenDeprecated,
Auditor: Name,
Rule: AutomountServiceAccountTokenDeprecated,
Severity: kubeaudit.Warn,
Message: "serviceAccount is a deprecated alias for serviceAccountName. serviceAccountName should be used instead.",
PendingFix: &fixDeprecatedServiceAccountName{
Expand All @@ -60,7 +61,8 @@ func auditResource(resource k8s.Resource, resources []k8s.Resource) *kubeaudit.A
defaultServiceAccount := getDefaultServiceAccount(resources)
if usesDefaultServiceAccount(podSpec) && isAutomountTokenTrue(podSpec, defaultServiceAccount) {
return &kubeaudit.AuditResult{
Name: AutomountServiceAccountTokenTrueAndDefaultSA,
Auditor: Name,
Rule: AutomountServiceAccountTokenTrueAndDefaultSA,
Severity: kubeaudit.Error,
Message: "Default service account with token mounted. automountServiceAccountToken should be set to 'false' on either the ServiceAccount or on the PodSpec or a non-default service account should be used.",
PendingFix: &fixDefaultServiceAccountWithAutomountToken{
Expand Down
9 changes: 6 additions & 3 deletions auditors/capabilities/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ func auditContainer(container *k8s.ContainerV1, capability string, allowAddList
if IsCapabilityInAddList(container, capability) {
message := fmt.Sprintf("Capability \"%s\" added. It should be removed from the capability add list. If you need this capability, add an override label such as '%s: SomeReason'.", capability, override.GetContainerOverrideLabel(container.Name, getOverrideLabel(capability)))
auditResult := &kubeaudit.AuditResult{
Name: CapabilityAdded,
Auditor: Name,
Rule: CapabilityAdded,
Severity: kubeaudit.Error,
Message: message,
PendingFix: &fixCapabilityAdded{
Expand Down Expand Up @@ -103,7 +104,8 @@ func auditContainerForDropAll(container *k8s.ContainerV1) *kubeaudit.AuditResult
if !SecurityContextOrCapabilities(container) {
message := "Security Context not set. The Security Context should be specified and all Capabilities should be dropped by setting the Drop list to ALL."
return &kubeaudit.AuditResult{
Name: CapabilityOrSecurityContextMissing,
Auditor: Name,
Rule: CapabilityOrSecurityContextMissing,
Severity: kubeaudit.Error,
Message: message,
PendingFix: &fixMissingSecurityContextOrCapability{
Expand All @@ -118,7 +120,8 @@ func auditContainerForDropAll(container *k8s.ContainerV1) *kubeaudit.AuditResult
if !IsDropAll(container) {
message := "Capability Drop list should be set to ALL. Add the specific ones you need to the Add list and set an override label."
return &kubeaudit.AuditResult{
Name: CapabilityShouldDropAll,
Auditor: Name,
Rule: CapabilityShouldDropAll,
Severity: kubeaudit.Error,
Message: message,
PendingFix: &fixCapabilityNotDroppedAll{
Expand Down
3 changes: 2 additions & 1 deletion auditors/deprecatedapis/depreceatedapis.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ func (deprecatedAPIs *DeprecatedAPIs) Audit(resource k8s.Resource, _ []k8s.Resou
}
}
auditResult := &kubeaudit.AuditResult{
Name: DeprecatedAPIUsed,
Auditor: Name,
Rule: DeprecatedAPIUsed,
Severity: severity,
Message: deprecationMessage,
Metadata: metadata,
Expand Down
7 changes: 7 additions & 0 deletions auditors/deprecatedapis/depreceatedapis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package deprecatedapis

import (
"fmt"
"os"
"strings"
"testing"

Expand Down Expand Up @@ -53,6 +54,12 @@ func TestAuditDeprecatedAPIs(t *testing.T) {
require.Nil(t, err)
report := test.AuditManifest(t, fixtureDir, tc.file, auditor, []string{DeprecatedAPIUsed})
assertReport(t, report, tc.expectedSeverity, message, metadata)

// disable local tests when running in dev mode
if os.Getenv("USE_KIND") == "false" {
return
}

report = test.AuditLocal(t, fixtureDir, tc.file, auditor, fmt.Sprintf("%s-%d", strings.Split(tc.file, ".")[0], i), []string{DeprecatedAPIUsed})
assertReport(t, report, tc.expectedSeverity, message, metadata)
})
Expand Down
9 changes: 6 additions & 3 deletions auditors/hostns/hostns.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ func auditHostNetwork(podSpec *k8s.PodSpecV1) *kubeaudit.AuditResult {
metadata["PodHost"] = podSpec.Hostname
}
return &kubeaudit.AuditResult{
Name: NamespaceHostNetworkTrue,
Auditor: Name,
Rule: NamespaceHostNetworkTrue,
Severity: kubeaudit.Error,
Message: "hostNetwork is set to 'true' in PodSpec. It should be set to 'false'.",
PendingFix: &fixHostNetworkTrue{
Expand All @@ -82,7 +83,8 @@ func auditHostIPC(podSpec *k8s.PodSpecV1) *kubeaudit.AuditResult {
metadata["PodHost"] = podSpec.Hostname
}
return &kubeaudit.AuditResult{
Name: NamespaceHostIPCTrue,
Auditor: Name,
Rule: NamespaceHostIPCTrue,
Severity: kubeaudit.Error,
Message: "hostIPC is set to 'true' in PodSpec. It should be set to 'false'.",
PendingFix: &fixHostIPCTrue{
Expand All @@ -102,7 +104,8 @@ func auditHostPID(podSpec *k8s.PodSpecV1) *kubeaudit.AuditResult {
metadata["PodHost"] = podSpec.Hostname
}
return &kubeaudit.AuditResult{
Name: NamespaceHostPIDTrue,
Auditor: Name,
Rule: NamespaceHostPIDTrue,
Severity: kubeaudit.Error,
Message: "hostPID is set to 'true' in PodSpec. It should be set to 'false'.",
PendingFix: &fixHostPIDTrue{
Expand Down
9 changes: 6 additions & 3 deletions auditors/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ func auditContainer(container *k8s.ContainerV1, image string) *kubeaudit.AuditRe

if isImageTagMissing(containerTag) {
return &kubeaudit.AuditResult{
Name: ImageTagMissing,
Auditor: Name,
Rule: ImageTagMissing,
Severity: kubeaudit.Warn,
Message: "Image tag is missing.",
Metadata: kubeaudit.Metadata{
Expand All @@ -61,7 +62,8 @@ func auditContainer(container *k8s.ContainerV1, image string) *kubeaudit.AuditRe

if isImageTagIncorrect(name, tag, containerName, containerTag) {
return &kubeaudit.AuditResult{
Name: ImageTagIncorrect,
Auditor: Name,
Rule: ImageTagIncorrect,
Severity: kubeaudit.Error,
Message: fmt.Sprintf("Container tag is incorrect. It should be set to '%s'.", tag),
Metadata: kubeaudit.Metadata{
Expand All @@ -72,7 +74,8 @@ func auditContainer(container *k8s.ContainerV1, image string) *kubeaudit.AuditRe

if isImageCorrect(name, tag, containerName, containerTag) {
return &kubeaudit.AuditResult{
Name: ImageCorrect,
Auditor: Name,
Rule: ImageCorrect,
Severity: kubeaudit.Info,
Message: "Image tag is correct",
Metadata: kubeaudit.Metadata{
Expand Down
15 changes: 10 additions & 5 deletions auditors/limits/limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ func (limits *Limits) Audit(resource k8s.Resource, _ []k8s.Resource) ([]*kubeaud
func (limits *Limits) auditContainer(container *k8s.ContainerV1) (auditResults []*kubeaudit.AuditResult) {
if isLimitsNil(container) {
auditResult := &kubeaudit.AuditResult{
Name: LimitsNotSet,
Auditor: Name,
Rule: LimitsNotSet,
Severity: kubeaudit.Warn,
Message: "Resource limits not set.",
Metadata: kubeaudit.Metadata{
Expand All @@ -81,7 +82,8 @@ func (limits *Limits) auditContainer(container *k8s.ContainerV1) (auditResults [

if isCPULimitUnset(container) {
auditResult := &kubeaudit.AuditResult{
Name: LimitsCPUNotSet,
Auditor: Name,
Rule: LimitsCPUNotSet,
Severity: kubeaudit.Warn,
Message: "Resource CPU limit not set.",
Metadata: kubeaudit.Metadata{
Expand All @@ -92,7 +94,8 @@ func (limits *Limits) auditContainer(container *k8s.ContainerV1) (auditResults [
} else if exceedsCPULimit(container, limits) {
maxCPU := limits.maxCPU.String()
auditResult := &kubeaudit.AuditResult{
Name: LimitsCPUExceeded,
Auditor: Name,
Rule: LimitsCPUExceeded,
Severity: kubeaudit.Warn,
Message: fmt.Sprintf("CPU limit exceeded. It is set to '%s' which exceeds the max CPU limit of '%s'.", cpu, maxCPU),
Metadata: kubeaudit.Metadata{
Expand All @@ -106,7 +109,8 @@ func (limits *Limits) auditContainer(container *k8s.ContainerV1) (auditResults [

if isMemoryLimitUnset(container) {
auditResult := &kubeaudit.AuditResult{
Name: LimitsMemoryNotSet,
Auditor: Name,
Rule: LimitsMemoryNotSet,
Severity: kubeaudit.Warn,
Message: "Resource Memory limit not set.",
Metadata: kubeaudit.Metadata{
Expand All @@ -117,7 +121,8 @@ func (limits *Limits) auditContainer(container *k8s.ContainerV1) (auditResults [
} else if exceedsMemoryLimit(container, limits) {
maxMemory := limits.maxMemory.String()
auditResult := &kubeaudit.AuditResult{
Name: LimitsMemoryExceeded,
Auditor: Name,
Rule: LimitsMemoryExceeded,
Severity: kubeaudit.Warn,
Message: fmt.Sprintf("Memory limit exceeded. It is set to '%s' which exceeds the max Memory limit of '%s'.", memory, maxMemory),
Metadata: kubeaudit.Metadata{
Expand Down
3 changes: 2 additions & 1 deletion auditors/mounts/mounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ func auditContainer(container *k8s.ContainerV1, sensitiveVolumes map[string]v1.V
for _, mount := range container.VolumeMounts {
if volume, ok := sensitiveVolumes[mount.Name]; ok {
auditResults = append(auditResults, &kubeaudit.AuditResult{
Name: SensitivePathsMounted,
Auditor: Name,
Rule: SensitivePathsMounted,
Severity: kubeaudit.Error,
Message: fmt.Sprintf("Sensitive path mounted as volume: %s (hostPath: %s). It should be removed from the container's mounts list.", mount.Name, volume.HostPath.Path),
Metadata: kubeaudit.Metadata{
Expand Down
24 changes: 16 additions & 8 deletions auditors/netpols/netpols.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ func auditNetworkPolicy(networkPolicy *k8s.NetworkPolicyV1) []*kubeaudit.AuditRe

if allIngressTrafficAllowed(networkPolicy) {
auditResult := &kubeaudit.AuditResult{
Name: AllowAllIngressNetworkPolicyExists,
Auditor: Name,
Rule: AllowAllIngressNetworkPolicyExists,
Severity: kubeaudit.Warn,
Message: "Found allow all ingress traffic NetworkPolicy.",
Metadata: kubeaudit.Metadata{
Expand All @@ -84,7 +85,8 @@ func auditNetworkPolicy(networkPolicy *k8s.NetworkPolicyV1) []*kubeaudit.AuditRe

if allEgressTrafficAllowed(networkPolicy) {
auditResult := &kubeaudit.AuditResult{
Name: AllowAllEgressNetworkPolicyExists,
Auditor: Name,
Rule: AllowAllEgressNetworkPolicyExists,
Severity: kubeaudit.Warn,
Message: "Found allow all egress traffic NetworkPolicy.",
Metadata: kubeaudit.Metadata{
Expand All @@ -108,7 +110,8 @@ func auditNetworkPoliciesForDenyAll(resource k8s.Resource, resources []k8s.Resou
if hasCatchAllNetPol {
if !hasDefaultDenyIngress {
auditResult := &kubeaudit.AuditResult{
Name: MissingDefaultDenyIngressNetworkPolicy,
Auditor: Name,
Rule: MissingDefaultDenyIngressNetworkPolicy,
Severity: kubeaudit.Error,
Message: fmt.Sprintf("All ingress traffic should be blocked by default for namespace %s.", namespace),
Metadata: kubeaudit.Metadata{
Expand All @@ -125,7 +128,8 @@ func auditNetworkPoliciesForDenyAll(resource k8s.Resource, resources []k8s.Resou

if !hasDefaultDenyEgress {
auditResult := &kubeaudit.AuditResult{
Name: MissingDefaultDenyEgressNetworkPolicy,
Auditor: Name,
Rule: MissingDefaultDenyEgressNetworkPolicy,
Severity: kubeaudit.Error,
Message: fmt.Sprintf("All egress traffic should be blocked by default for namespace %s.", namespace),
Metadata: kubeaudit.Metadata{
Expand All @@ -149,7 +153,8 @@ func auditNetworkPoliciesForDenyAll(resource k8s.Resource, resources []k8s.Resou

if !hasIngressOverride && !hasEgressOverride {
auditResult := &kubeaudit.AuditResult{
Name: MissingDefaultDenyIngressAndEgressNetworkPolicy,
Auditor: Name,
Rule: MissingDefaultDenyIngressAndEgressNetworkPolicy,
Severity: kubeaudit.Error,
Message: "Namespace is missing a default deny ingress and egress NetworkPolicy.",
Metadata: kubeaudit.Metadata{
Expand All @@ -165,7 +170,8 @@ func auditNetworkPoliciesForDenyAll(resource k8s.Resource, resources []k8s.Resou

if hasIngressOverride && hasEgressOverride {
auditResult := &kubeaudit.AuditResult{
Name: override.GetOverriddenResultName(MissingDefaultDenyIngressAndEgressNetworkPolicy),
Auditor: Name,
Rule: override.GetOverriddenResultName(MissingDefaultDenyIngressAndEgressNetworkPolicy),
Severity: kubeaudit.Warn,
Message: "Namespace is missing a default deny ingress and egress NetworkPolicy.",
Metadata: kubeaudit.Metadata{
Expand All @@ -179,7 +185,8 @@ func auditNetworkPoliciesForDenyAll(resource k8s.Resource, resources []k8s.Resou
// At this point there is exactly one override label for either ingress or egress which means one needs to be
// fixed and the other is overridden
auditResult := &kubeaudit.AuditResult{
Name: MissingDefaultDenyIngressNetworkPolicy,
Auditor: Name,
Rule: MissingDefaultDenyIngressNetworkPolicy,
Severity: kubeaudit.Error,
Message: "Namespace is missing a default deny ingress NetworkPolicy.",
Metadata: kubeaudit.Metadata{
Expand All @@ -194,7 +201,8 @@ func auditNetworkPoliciesForDenyAll(resource k8s.Resource, resources []k8s.Resou
auditResults = append(auditResults, auditResult)

auditResult = &kubeaudit.AuditResult{
Name: MissingDefaultDenyEgressNetworkPolicy,
Auditor: Name,
Rule: MissingDefaultDenyEgressNetworkPolicy,
Severity: kubeaudit.Error,
Message: "Namespace is missing a default deny egress NetworkPolicy.",
Metadata: kubeaudit.Metadata{
Expand Down
18 changes: 12 additions & 6 deletions auditors/nonroot/nonroot.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ func auditContainer(container *k8s.ContainerV1, resource k8s.Resource) *kubeaudi
if !isContainerRunAsUserNil(container) {
if *container.SecurityContext.RunAsUser == 0 {
return &kubeaudit.AuditResult{
Name: RunAsUserCSCRoot,
Auditor: Name,
Rule: RunAsUserCSCRoot,
Severity: kubeaudit.Error,
Message: "runAsUser is set to UID 0 (root user) in the container SecurityContext. Either set it to a value > 0 or remove it and set runAsNonRoot to true.",
PendingFix: &fixRunAsNonRoot{
Expand All @@ -71,7 +72,8 @@ func auditContainer(container *k8s.ContainerV1, resource k8s.Resource) *kubeaudi
if !isPodRunAsUserNil(podSpec) {
if *podSpec.SecurityContext.RunAsUser == 0 {
return &kubeaudit.AuditResult{
Name: RunAsUserPSCRoot,
Auditor: Name,
Rule: RunAsUserPSCRoot,
Severity: kubeaudit.Warn,
Message: "runAsUser is set to UID 0 (root user) in the PodSecurityContext. Either set it to a value > 0 or remove it and set runAsNonRoot to true.",
Metadata: kubeaudit.Metadata{
Expand All @@ -87,7 +89,8 @@ func auditContainer(container *k8s.ContainerV1, resource k8s.Resource) *kubeaudi
if !isPodRunAsUserNil(podSpec) {
if *podSpec.SecurityContext.RunAsUser == 0 {
return &kubeaudit.AuditResult{
Name: RunAsUserPSCRoot,
Auditor: Name,
Rule: RunAsUserPSCRoot,
Severity: kubeaudit.Error,
Message: "runAsUser is set to UID 0 (root user) in the PodSecurityContext. Either set it to a value > 0 or remove it and set runAsNonRoot to true.",
PendingFix: &fixRunAsNonRoot{
Expand All @@ -104,7 +107,8 @@ func auditContainer(container *k8s.ContainerV1, resource k8s.Resource) *kubeaudi

if isContainerRunAsNonRootCSCFalse(container) {
return &kubeaudit.AuditResult{
Name: RunAsNonRootCSCFalse,
Auditor: Name,
Rule: RunAsNonRootCSCFalse,
Severity: kubeaudit.Error,
Message: "runAsNonRoot is set to false in the container SecurityContext. Either set it to true or set runAsUser to a value > 0.",
PendingFix: &fixRunAsNonRoot{
Expand All @@ -119,7 +123,8 @@ func auditContainer(container *k8s.ContainerV1, resource k8s.Resource) *kubeaudi
if isContainerRunAsNonRootNil(container) {
if isPodRunAsNonRootNil(podSpec) {
return &kubeaudit.AuditResult{
Name: RunAsNonRootPSCNilCSCNil,
Auditor: Name,
Rule: RunAsNonRootPSCNilCSCNil,
Severity: kubeaudit.Error,
Message: "runAsNonRoot should be set to true or runAsUser should be set to a value > 0 either in the container SecurityContext or PodSecurityContext.",
PendingFix: &fixRunAsNonRoot{
Expand All @@ -133,7 +138,8 @@ func auditContainer(container *k8s.ContainerV1, resource k8s.Resource) *kubeaudi

if isPodRunAsNonRootFalse(podSpec) {
return &kubeaudit.AuditResult{
Name: RunAsNonRootPSCFalseCSCNil,
Auditor: Name,
Rule: RunAsNonRootPSCFalseCSCNil,
Severity: kubeaudit.Error,
Message: "runAsNonRoot is set to false in the PodSecurityContext. Either set it to true or set runAsUser to a value > 0.",
PendingFix: &fixRunAsNonRoot{
Expand Down
Loading