Skip to content

Commit

Permalink
Merge branch 'SUB-2185-fix-control-C-0262' of github.com:kubescape/re…
Browse files Browse the repository at this point in the history
…golibrary into SUB-2185-fix-control-C-0262

Signed-off-by: YiscahLevySilas1 <[email protected]>
  • Loading branch information
YiscahLevySilas1 committed Oct 9, 2023
2 parents 895d477 + 22233d3 commit 631166e
Show file tree
Hide file tree
Showing 82 changed files with 135 additions and 9 deletions.
2 changes: 2 additions & 0 deletions rules/exposure-to-internet/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ deny[msga] {
},
"relatedObjects": [{
"object": service,
"reviewPaths": failPath,
"failedPaths": failPath,
}]
}
Expand Down Expand Up @@ -56,6 +57,7 @@ deny[msga] {
},
"relatedObjects": [{
"object": ingress,
"reviewPaths": result,
"failedPaths": result,
}]
}
Expand Down
3 changes: 3 additions & 0 deletions rules/has-image-signature/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ deny[msga] {
"alertMessage": sprintf("image: %v is not signed", [ container.image]),
"alertScore": 7,
"fixPaths": [],
"reviewPaths": [failedPath],
"failedPaths": [failedPath],
"packagename": "armo_builtins",
"alertObject": {
Expand All @@ -37,6 +38,7 @@ deny[msga] {
"alertMessage": sprintf("image: %v is not signed", [ container.image]),
"alertScore": 7,
"fixPaths": [],
"reviewPaths": [failedPath],
"failedPaths": [failedPath],
"packagename": "armo_builtins",
"alertObject": {
Expand All @@ -59,6 +61,7 @@ deny[msga] {
"alertMessage": sprintf("image: %v is not signed", [ container.image]),
"alertScore": 7,
"fixPaths": [],
"reviewPaths": [failedPath],
"failedPaths": [failedPath],
"packagename": "armo_builtins",
"alertObject": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ deny[msga] {
"alertMessage": sprintf("%v: %v is in the 'default' namespace", [resource.kind, resource.metadata.name]),
"packagename": "armo_builtins",
"alertScore": 3,
"reviewPaths": failed_path,
"failedPaths": failed_path,
"fixPaths": fixed_path,
"alertObject": {
Expand Down
3 changes: 3 additions & 0 deletions rules/host-network-access/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ deny[msga] {
msga := {
"alertMessage": sprintf("Pod: %v is connected to the host network", [pod.metadata.name]),
"alertScore": 9,
"deletePaths": [path],
"failedPaths": [path],
"fixPaths":[],
"packagename": "armo_builtins",
Expand All @@ -28,6 +29,7 @@ deny[msga] {
msga := {
"alertMessage": sprintf("%v: %v has a pod connected to the host network", [wl.kind, wl.metadata.name]),
"alertScore": 9,
"deletePaths": [path],
"failedPaths": [path],
"fixPaths":[],
"packagename": "armo_builtins",
Expand All @@ -46,6 +48,7 @@ deny[msga] {
msga := {
"alertMessage": sprintf("CronJob: %v has a pod connected to the host network", [wl.metadata.name]),
"alertScore": 9,
"deletePaths": [path],
"failedPaths": [path],
"fixPaths":[],
"packagename": "armo_builtins",
Expand Down
1 change: 1 addition & 0 deletions rules/ingress-in-default-namespace/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ deny[msga] {
"alertMessage": sprintf("%v: %v is in the 'default' namespace", [resource.kind, resource.metadata.name]),
"packagename": "armo_builtins",
"alertScore": 3,
"reviewPaths": failed_path,
"failedPaths": failed_path,
"fixPaths": fixed_path,
"alertObject": {
Expand Down
1 change: 1 addition & 0 deletions rules/insecure-port-flag/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ deny[msga] {
"alertMessage": sprintf("The API server container: %v has insecure-port flag enabled", [ container.name]),
"packagename": "armo_builtins",
"alertScore": 7,
"reviewPaths": [path],
"failedPaths": [path],
"fixPaths": [],
"alertObject": {
Expand Down
1 change: 1 addition & 0 deletions rules/k8s-audit-logs-enabled-native-cis/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ deny[msga] {
"alertMessage": "audit logs are not enabled",
"alertScore": 5,
"packagename": "armo_builtins",
"reviewPaths": [path],
"failedPaths": [path],
"fixPaths": [],
"alertObject": {"k8sApiObjects": [obj]},
Expand Down
1 change: 1 addition & 0 deletions rules/k8s-audit-logs-enabled-native/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ deny[msga] {
"alertMessage": "audit logs is not enabled",
"alertScore": 9,
"packagename": "armo_builtins",
"reviewPaths": [path],
"failedPaths": [path],
"fixPaths": [],
"alertObject": {
Expand Down
1 change: 1 addition & 0 deletions rules/kubelet-authorization-mode-alwaysAllow/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ deny[msga] {
msga := {
"alertMessage": "Anonymous requests are enabled",
"alertScore": 10,
"reviewPaths": ["authorization.mode"],
"failedPaths": ["authorization.mode"],
"fixPaths": [],
"packagename": "armo_builtins",
Expand Down
1 change: 1 addition & 0 deletions rules/kubelet-event-qps/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ deny[msga] {
msga := {
"alertMessage": "Value of the eventRecordQPS argument is set to 0",
"alertScore": 2,
"reviewPaths": ["eventRecordQPS"],
"failedPaths": ["eventRecordQPS"],
"fixPaths": [],
"packagename": "armo_builtins",
Expand Down
1 change: 1 addition & 0 deletions rules/kubelet-ip-tables/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ deny[msga] {
msga := {
"alertMessage": "Property makeIPTablesUtilChains is not set to true",
"alertScore": 3,
"reviewPaths": ["makeIPTablesUtilChains"],
"failedPaths": ["makeIPTablesUtilChains"],
"fixPaths": [],
"packagename": "armo_builtins",
Expand Down
1 change: 1 addition & 0 deletions rules/kubelet-protect-kernel-defaults/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ deny[msga] {
msga := {
"alertMessage": "Property protectKernelDefaults is not set to true",
"alertScore": 2,
"reviewPaths": ["protectKernelDefaults"],
"failedPaths": ["protectKernelDefaults"],
"fixPaths": [],
"packagename": "armo_builtins",
Expand Down
1 change: 1 addition & 0 deletions rules/kubelet-rotate-certificates/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ deny[msga] {
msga := {
"alertMessage": "Kubelet client certificates rotation is disabled",
"alertScore": 6,
"reviewPaths": ["rotateCertificates"],
"failedPaths": ["rotateCertificates"],
"fixPaths": [],
"packagename": "armo_builtins",
Expand Down
1 change: 1 addition & 0 deletions rules/kubelet-streaming-connection-idle-timeout/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ deny[msga] {
msga := {
"alertMessage": "Timeouts on streaming connections are enabled",
"alertScore": 3,
"reviewPaths": ["streamingConnectionIdleTimeout"],
"failedPaths": ["streamingConnectionIdleTimeout"],
"fixPaths": [],
"packagename": "armo_builtins",
Expand Down
1 change: 1 addition & 0 deletions rules/kubelet-strong-cryptography-ciphers/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ deny[msga] {
msga := {
"alertMessage": "Kubelet is not configured to only use strong cryptographic ciphers",
"alertScore": 5,
"reviewPaths": ["TLSCipherSuites"],
"failedPaths": ["TLSCipherSuites"],
"fixPaths": [],
"packagename": "armo_builtins",
Expand Down
1 change: 1 addition & 0 deletions rules/lease-in-default-namespace/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ deny[msga] {
"alertMessage": sprintf("%v: %v is in the 'default' namespace", [resource.kind, resource.metadata.name]),
"packagename": "armo_builtins",
"alertScore": 3,
"reviewPaths": failed_path,
"failedPaths": failed_path,
"fixPaths": fixed_path,
"alertObject": {
Expand Down
3 changes: 3 additions & 0 deletions rules/non-root-containers/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ deny[msga] {
"alertMessage": sprintf("container: %v in pod: %v may run as root", [container.name, pod.metadata.name]),
"packagename": "armo_builtins",
"alertScore": 7,
"reviewPaths": failed_path,
"failedPaths": failed_path,
"fixPaths": fixPath,
"alertObject": {
Expand All @@ -40,6 +41,7 @@ deny[msga] {
"alertMessage": sprintf("container :%v in %v: %v may run as root", [container.name, wl.kind, wl.metadata.name]),
"packagename": "armo_builtins",
"alertScore": 7,
"reviewPaths": failed_path,
"failedPaths": failed_path,
"fixPaths": fixPath,
"alertObject": {
Expand All @@ -64,6 +66,7 @@ deny[msga] {
"alertMessage": sprintf("container :%v in %v: %v may run as root", [container.name, wl.kind, wl.metadata.name]),
"packagename": "armo_builtins",
"alertScore": 7,
"reviewPaths": failed_path,
"failedPaths": failed_path,
"fixPaths": fixPath,
"alertObject": {
Expand Down
1 change: 1 addition & 0 deletions rules/persistentvolumeclaim-in-default-namespace/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ deny[msga] {
"alertMessage": sprintf("%v: %v is in the 'default' namespace", [resource.kind, resource.metadata.name]),
"packagename": "armo_builtins",
"alertScore": 3,
"reviewPaths": failed_path,
"failedPaths": failed_path,
"fixPaths": fixed_path,
"alertObject": {
Expand Down
1 change: 1 addition & 0 deletions rules/poddisruptionbudget-in-default-namespace/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ deny[msga] {
"alertMessage": sprintf("%v: %v is in the 'default' namespace", [resource.kind, resource.metadata.name]),
"packagename": "armo_builtins",
"alertScore": 3,
"reviewPaths": failed_path,
"failedPaths": failed_path,
"fixPaths": fixed_path,
"alertObject": {
Expand Down
1 change: 1 addition & 0 deletions rules/podtemplate-in-default-namespace/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ deny[msga] {
"alertMessage": sprintf("%v: %v is in the 'default' namespace", [resource.kind, resource.metadata.name]),
"packagename": "armo_builtins",
"alertScore": 3,
"reviewPaths": failed_path,
"failedPaths": failed_path,
"fixPaths": fixed_path,
"alertObject": {
Expand Down
1 change: 1 addition & 0 deletions rules/psp-deny-allowed-capabilities/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ deny[msga] {
msga := {
"alertMessage": sprintf("PodSecurityPolicy: '%v' has allowedCapabilities.", [psp.metadata.name]),
"packagename": "armo_builtins",
"deletePaths": [path],
"failedPaths": [path],
"fixPaths": [],
"alertObject": {"k8sApiObjects": [psp]},
Expand Down
1 change: 1 addition & 0 deletions rules/psp-deny-allowprivilegeescalation/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ deny[msga] {
msga := {
"alertMessage": sprintf("PodSecurityPolicy: '%v' has allowPrivilegeEscalation set as true.", [psp.metadata.name]),
"packagename": "armo_builtins",
"deletePaths": [path],
"failedPaths": [path],
"fixPaths": [],
"alertObject": {"k8sApiObjects": [psp]},
Expand Down
1 change: 1 addition & 0 deletions rules/psp-deny-hostipc/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ deny[msga] {
msga := {
"alertMessage": sprintf("PodSecurityPolicy: '%v' has hostIPC set as true.", [psp.metadata.name]),
"packagename": "armo_builtins",
"deletePaths": [path],
"failedPaths": [path],
"fixPaths": [],
"alertObject": {"k8sApiObjects": [psp]},
Expand Down
1 change: 1 addition & 0 deletions rules/psp-deny-hostnetwork/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ deny[msga] {
msga := {
"alertMessage": sprintf("PodSecurityPolicy: '%v' has hostNetwork set as true.", [psp.metadata.name]),
"packagename": "armo_builtins",
"deletePaths": [path],
"failedPaths": [path],
"fixPaths": [],
"alertObject": {"k8sApiObjects": [psp]},
Expand Down
1 change: 1 addition & 0 deletions rules/psp-deny-hostpid/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ deny[msga] {
msga := {
"alertMessage": sprintf("PodSecurityPolicy: '%v' has hostPID set as true.", [psp.metadata.name]),
"packagename": "armo_builtins",
"deletePaths": [path],
"failedPaths": [path],
"fixPaths": [],
"alertObject": {"k8sApiObjects": [psp]},
Expand Down
1 change: 1 addition & 0 deletions rules/psp-deny-privileged-container/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ deny[msga] {
msga := {
"alertMessage": sprintf("PodSecurityPolicy: '%v' has privileged set as true.", [psp.metadata.name]),
"packagename": "armo_builtins",
"deletePaths": [path],
"failedPaths": [path],
"fixPaths": [],
"alertObject": {"k8sApiObjects": [psp]},
Expand Down
1 change: 1 addition & 0 deletions rules/psp-deny-root-container/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ deny[msga] {
msga := {
"alertMessage": sprintf("PodSecurityPolicy: '%v' permits containers to run as the root user.", [psp.metadata.name]),
"packagename": "armo_builtins",
"deletePaths": [path],
"failedPaths": [path],
"fixPaths": [],
"alertObject": {"k8sApiObjects": [psp]},
Expand Down
1 change: 1 addition & 0 deletions rules/psp-enabled-native/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ deny[msga] {
"alertMessage": "PodSecurityPolicy is not enabled",
"alertScore": 9,
"packagename": "armo_builtins",
"reviewPaths": [path],
"failedPaths": [path],
"fixPaths": [],
"alertObject": {
Expand Down
1 change: 1 addition & 0 deletions rules/rbac-enabled-cloud/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ deny[msga] {
"alertMessage": "rbac is not enabled",
"alertScore": 3,
"packagename": "armo_builtins",
"reviewPaths": ["data.properties.enableRBAC"],
"failedPaths": ["data.properties.enableRBAC"],
"fixCommand": "",
"fixPaths": [],
Expand Down
1 change: 1 addition & 0 deletions rules/rbac-enabled-native/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ deny[msga] {
"alertMessage": "RBAC is not enabled",
"alertScore": 9,
"packagename": "armo_builtins",
"reviewPaths": [path],
"failedPaths": [path],
"fixPaths": [],
"alertObject": {
Expand Down
1 change: 1 addition & 0 deletions rules/read-only-port-enabled-updated/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ deny[msga] {
msga := {
"alertMessage": "kubelet read-only port is not disabled",
"alertScore": 4,
"reviewPaths": ["readOnlyPort"],
"failedPaths": ["readOnlyPort"],
"fixPaths": [],
"packagename": "armo_builtins",
Expand Down
1 change: 1 addition & 0 deletions rules/replicationcontroller-in-default-namespace/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ deny[msga] {
"alertMessage": sprintf("%v: %v is in the 'default' namespace", [resource.kind, resource.metadata.name]),
"packagename": "armo_builtins",
"alertScore": 3,
"reviewPaths": failed_path,
"failedPaths": failed_path,
"fixPaths": fixed_path,
"alertObject": {
Expand Down
3 changes: 3 additions & 0 deletions rules/resources-cpu-limit-and-request/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ deny[msga] {
"alertMessage": sprintf("Container: %v exceeds CPU-limit or request", [ container.name]),
"packagename": "armo_builtins",
"alertScore": 7,
"reviewPaths": [failed_paths],
"failedPaths": [failed_paths],
"fixPaths": [],
"alertObject": {
Expand All @@ -112,6 +113,7 @@ deny[msga] {
"alertMessage": sprintf("Container: %v in %v: %v exceeds CPU-limit or request", [ container.name, wl.kind, wl.metadata.name]),
"packagename": "armo_builtins",
"alertScore": 7,
"reviewPaths": [failed_paths],
"failedPaths": [failed_paths],
"fixPaths": [],
"alertObject": {
Expand All @@ -136,6 +138,7 @@ deny[msga] {
"alertMessage": sprintf("Container: %v in %v: %v exceeds CPU-limit or request", [ container.name, wl.kind, wl.metadata.name]),
"packagename": "armo_builtins",
"alertScore": 7,
"reviewPaths": [failed_paths],
"failedPaths": [failed_paths],
"fixPaths": [],
"alertObject": {
Expand Down
3 changes: 3 additions & 0 deletions rules/resources-memory-limit-and-request/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ deny[msga] {
"alertMessage": sprintf("Container: %v exceeds memory-limit or request", [container.name]),
"packagename": "armo_builtins",
"alertScore": 7,
"reviewPaths": [failed_paths],
"failedPaths": [failed_paths],
"fixPaths": [],
"alertObject": {"k8sApiObjects": [pod]},
Expand All @@ -109,6 +110,7 @@ deny[msga] {
"alertMessage": sprintf("Container: %v in %v: %v exceeds memory-limit or request", [container.name, wl.kind, wl.metadata.name]),
"packagename": "armo_builtins",
"alertScore": 7,
"reviewPaths": [failed_paths],
"failedPaths": [failed_paths],
"fixPaths": [],
"alertObject": {"k8sApiObjects": [wl]},
Expand All @@ -131,6 +133,7 @@ deny[msga] {
"alertMessage": sprintf("Container: %v in %v: %v exceeds memory-limit or request", [container.name, wl.kind, wl.metadata.name]),
"packagename": "armo_builtins",
"alertScore": 7,
"reviewPaths": [failed_paths],
"failedPaths": [failed_paths],
"fixPaths": [],
"alertObject": {"k8sApiObjects": [wl]},
Expand Down
1 change: 1 addition & 0 deletions rules/resources-secret-in-default-namespace/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ deny[msga] {
"alertMessage": sprintf("%v: %v is in the 'default' namespace", [resource.kind, resource.metadata.name]),
"packagename": "armo_builtins",
"alertScore": 3,
"reviewPaths": failed_path,
"failedPaths": failed_path,
"fixPaths": fixed_path,
"alertObject": {
Expand Down
1 change: 1 addition & 0 deletions rules/role-in-default-namespace/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ deny[msga] {
"alertMessage": sprintf("%v: %v is in the 'default' namespace", [resource.kind, resource.metadata.name]),
"packagename": "armo_builtins",
"alertScore": 3,
"reviewPaths": failed_path,
"failedPaths": failed_path,
"fixPaths": fixed_path,
"alertObject": {
Expand Down
1 change: 1 addition & 0 deletions rules/rolebinding-in-default-namespace/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ deny[msga] {
"alertMessage": sprintf("%v: %v is in the 'default' namespace", [resource.kind, resource.metadata.name]),
"packagename": "armo_builtins",
"alertScore": 3,
"reviewPaths": failed_path,
"failedPaths": failed_path,
"fixPaths": fixed_path,
"alertObject": {
Expand Down
1 change: 1 addition & 0 deletions rules/rule-access-dashboard-subject-v1/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ deny[msga] {
msga := {
"alertMessage": sprintf("Subject: %v-%v is bound to dashboard role/clusterrole", [subjectVector.kind, subjectVector.name]),
"alertScore": 9,
"reviewPaths": finalpath,
"failedPaths": finalpath,
"fixPaths": [],
"packagename": "armo_builtins",
Expand Down
Loading

0 comments on commit 631166e

Please sign in to comment.