-
Notifications
You must be signed in to change notification settings - Fork 700
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into add_cis_slem
- Loading branch information
Showing
59 changed files
with
10,371 additions
and
113 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
61 changes: 61 additions & 0 deletions
61
applications/openshift/master/master_taint_noschedule/rule.yml
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 @@ | ||
documentation_complete: true | ||
|
||
title: Verify that Control Plane Nodes are not schedulable for workloads | ||
|
||
description: -| | ||
<p> | ||
User workloads should not be colocated with control plane workloads. To ensure that the scheduler won't | ||
schedule workloads on the master nodes, the taint "node-role.kubernetes.io/master" with the "NoSchedule" | ||
effect is set by default in most cluster configurations (excluding SNO and Compact Clusters). | ||
</p> | ||
<p> | ||
The scheduling of the master nodes is centrally configurable without reboot via | ||
<pre>oc edit schedulers.config.openshift.io cluster </pre> for details see the Red Hat Solution | ||
{{{ weblink(link="https://access.redhat.com/solutions/4564851") }}} | ||
</p> | ||
<p> | ||
If you run a setup, which requires the colocation of control plane and user workload you need to | ||
exclude this rule. | ||
</p> | ||
|
||
rationale: -| | ||
By separating user workloads and the control plane workloads we can better ensure that there is | ||
no ill effects from workload boosts to each other. Furthermore we ensure that an adversary who gets | ||
control over a badly secured workload container is not colocated to critical components of the control plane. | ||
In some setups it might be necessary to make the control plane schedulable for workloads i.e. | ||
Single Node Openshift (SNO) or Compact Cluster (Three Node Cluster) setups. | ||
|
||
{{% set jqfilter = '.items[] | select(.metadata.labels."node-role.kubernetes.io/master" == "" or .metadata.labels."node-role.kubernetes.io/control-plane" == "" ) | .spec.taints[] | select(.key == "node-role.kubernetes.io/master" and .effect == "NoSchedule")' %}} | ||
|
||
identifiers: | ||
cce@ocp4: CCE-88731-5 | ||
|
||
severity: medium | ||
|
||
ocil_clause: 'Control Plane is schedulable' | ||
|
||
ocil: |- | ||
Run the following command to see if control planes are schedulable | ||
<pre>$oc get --raw /api/v1/nodes | jq '.items[] | select(.metadata.labels."node-role.kubernetes.io/master" == "" or .metadata.labels."node-role.kubernetes.io/control-plane" == "" ) | .spec.taints[] | select(.key == "node-role.kubernetes.io/master" and .effect == "NoSchedule" )'</pre> | ||
for each master node, there should be an output of a key with the NoSchedule effect. | ||
By editing the cluster scheduler you can centrally configure the masters as schedulable or not | ||
by setting .spec.mastersSchedulable to true. | ||
Use <pre>$oc edit schedulers.config.openshift.io cluster</pre> to configure the scheduling. | ||
warnings: | ||
- general: |- | ||
{{{ openshift_filtered_cluster_setting({'/api/v1/nodes': jqfilter}) | indent(8) }}} | ||
template: | ||
name: yamlfile_value | ||
vars: | ||
ocp_data: "true" | ||
filepath: |- | ||
{{{ openshift_filtered_path('/api/v1/nodes', jqfilter) }}} | ||
yamlpath: ".effect" | ||
check_existence: "at_least_one_exists" | ||
entity_check: "at least one" | ||
values: | ||
- value: "NoSchedule" | ||
operation: "pattern match" |
2 changes: 2 additions & 0 deletions
2
applications/openshift/master/master_taint_noschedule/tests/ocp4/e2e.yml
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,2 @@ | ||
--- | ||
default_result: PASS |
2 changes: 2 additions & 0 deletions
2
applications/openshift/networking/configure_appropriate_network_policies/ocp4/e2e.yml
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,2 @@ | ||
--- | ||
default_result: MANUAL |
43 changes: 43 additions & 0 deletions
43
applications/openshift/networking/configure_appropriate_network_policies/rule.yml
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,43 @@ | ||
documentation_complete: true | ||
|
||
title: 'Ensure Appropriate Network Policies are Configured' | ||
|
||
description: |- | ||
Configure Network Policies in any application namespace in an appropriate way, so that | ||
only the required communications are allowed. The Network Policies should precisely define | ||
source and target using label selectors and ports. | ||
rationale: |- | ||
By default, all pod to pod traffic within a cluster is allowed. Network | ||
Policy creates a pod- level firewall that can be used to restrict traffic | ||
between sources. Pod traffic is restricted by having a Network Policy that | ||
selects it (through the use of labels). Once there is any Network Policy in a | ||
namespace selecting a particular pod, that pod will reject any connections | ||
that are not allowed by any Network Policy. Other pods in the namespace that | ||
are not selected by any Network Policy will continue to accept all traffic. | ||
Implementing Kubernetes Network Policies with minimal allowed communication enhances security | ||
by reducing entry points and limiting attacker movement within the cluster. It ensures pods and | ||
services communicate only with necessary entities, reducing unauthorized access risks. In case | ||
of a breach, these policies contain compromised pods, preventing widespread malicious activity. | ||
Additionally, they enhance monitoring and detection of anomalous network activities. | ||
severity: medium | ||
|
||
identifiers: | ||
cce@ocp4: CCE-89537-5 | ||
|
||
ocil_clause: 'Network Policies need to be evaluated if they are appropriate' | ||
|
||
ocil: |- | ||
For each non-default namespace in the cluster, review the configured Network Policies | ||
and ensure that they only allow the necessary network connections. They should | ||
precisely define source and target using label selectors and ports. | ||
1. Get a list of existing projects(namespaces), exclude default, kube-*, openshift-* | ||
<pre>$ oc get namespaces -ojson | jq -r '[.items[] | select((.metadata.name | startswith("openshift") | not) and (.metadata.name | startswith("kube-") | not) and .metadata.name != "default" and ({{if ne .var_network_policies_namespaces_exempt_regex "None"}}.metadata.name | test("{{.var_network_policies_namespaces_exempt_regex}}") | not{{else}}true{{end}})) | .metadata.name]'</pre> | ||
Namespaces matching the variable <tt>ocp4-var-network-policies-namespaces-exempt-regex</tt> regex are excluded from this check. | ||
2. For each of these namespaces, review the network policies: | ||
<pre>$ oc get networkpolicies -n $namespace -o yaml</pre> |
57 changes: 57 additions & 0 deletions
57
applications/openshift/networking/configure_egress_ip_node_assignable/rule.yml
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,57 @@ | ||
documentation_complete: true | ||
|
||
title: Check Egress IPs Assignable to Nodes | ||
|
||
description: -| | ||
<p> | ||
The OpenShift Container Platform egress IP address functionality allows you to ensure that the | ||
traffic from one or more pods in one or more namespaces has a consistent source IP address for | ||
services outside the cluster network. | ||
</p> | ||
<p> | ||
The necessary labeling on the designated nodes is configurable without reboot via | ||
<pre>$ oc label nodes $NODENAME k8s.ovn.org/egress-assignable="" </pre> for details see the | ||
Red Hat Documentation | ||
{{{ weblink(link="https://docs.redhat.com/en/documentation/openshift_container_platform/4.17/html/networking/ovn-kubernetes-network-plugin#nw-egress-ips-about_configuring-egress-ips-ovn") }}} | ||
</p> | ||
|
||
rationale: -| | ||
By using egress IPs you can provide a consistent IP to external services and configure special | ||
firewall rules which precisely select this IP. This allows for more control on external systems. | ||
Furthermore you can bind the IPs to specific nodes, which handle all the network connections to | ||
achieve a better separation of duties between the different nodes. | ||
|
||
identifiers: | ||
cce@ocp4: CCE-86787-9 | ||
|
||
severity: medium | ||
|
||
ocil_clause: 'Check Egress IPs Assignable to Nodes' | ||
|
||
ocil: |- | ||
Run the following command to see if nodes are assignable for egress IPs | ||
<pre>$ oc get --raw /api/v1/nodes | jq '.items[] | select(.metadata.labels."k8s.ovn.org/egress-assignable" != null) | .metadata.name'</pre> | ||
This commands prints the name of each node which is configured to get egress IPs assigned. If | ||
the output is empty, there are no nodes available. | ||
{{% set old_jqfilter = 'if any(.items[]?; .metadata.labels."k8s.ovn.org/egress-assignable" != null) then true else false end' %}} | ||
{{% set jqfilter = '[ .items[] | .metadata.labels["k8s.ovn.org/egress-assignable"] != null ]' %}} | ||
|
||
|
||
warnings: | ||
- general: |- | ||
{{{ openshift_filtered_cluster_setting({'/api/v1/nodes': jqfilter}) | indent(8) }}} | ||
template: | ||
name: yamlfile_value | ||
vars: | ||
ocp_data: "true" | ||
filepath: |- | ||
{{{ openshift_filtered_path('/api/v1/nodes', jqfilter) }}} | ||
yamlpath: '[:]' | ||
check_existence: at_least_one_exists | ||
entity_check: "at least one" | ||
values: | ||
- value: 'true' | ||
type: "string" | ||
entity_check: "at least one" |
9 changes: 9 additions & 0 deletions
9
...ns/openshift/networking/configure_egress_ip_node_assignable/tests/ocp4/e2e-remediation.sh
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,9 @@ | ||
#!/bin/bash | ||
set -xe | ||
|
||
echo "Labeling Node for egress IP" | ||
|
||
NODENAME=`oc get node | tail -1 | cut -d" " -f1` | ||
oc label node $NODENAME k8s.ovn.org/egress-assignable="" | ||
|
||
sleep 5 |
3 changes: 3 additions & 0 deletions
3
applications/openshift/networking/configure_egress_ip_node_assignable/tests/ocp4/e2e.yml
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,3 @@ | ||
--- | ||
default_result: FAIL | ||
result_after_remediation: PASS |
39 changes: 39 additions & 0 deletions
39
applications/openshift/networking/configure_network_bandwidth/rule.yml
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,39 @@ | ||
documentation_complete: true | ||
|
||
title: 'Limiting Network Bandwidth in Pods' | ||
|
||
description: |- | ||
Network bandwidth, SHOULD be appropriately reserved and limited. | ||
ocil: |- | ||
Network bandwidth is limited at the pod level and can be determined separately according | ||
to incoming and outgoing network bandwidth. | ||
For more information about limiting network bandwidth on the pod level please refer to the Red Hat documentation: | ||
{{{ weblink(link="https://docs.openshift.com/container-platform/4.17/nodes/pods/nodes-pods-configuring.html#nodes-pods-configuring-bandwidth_nodes-pods-configuring") }}} | ||
Out of the documetation use the example for the network bandwidth configuration of a pod: | ||
<pre> | ||
kind: Pod | ||
apiVersion: v1 | ||
metadata: | ||
name: hello-openshift | ||
annotations: | ||
kubernetes.io/ingress-bandwidth: 2M | ||
kubernetes.io/egress-bandwidth: 1M | ||
spec: | ||
containers: | ||
- image: openshift/hello-openshift | ||
name: hello-openshift | ||
</pre> | ||
severity: unknown | ||
|
||
identifiers: | ||
cce@ocp4: CCE-87610-2 | ||
|
||
ocil_clause: 'Limiting Pod network bandwidth on OCP 4' | ||
|
||
rationale: |- | ||
Extend pod configuration with network bandwidth annotations to prevent | ||
a bad actor or a malfunction in the pod to consume all the bandwidth in the cluster. | ||
A network bandwidth limitation on the pod level can mitigate the bearing onto the cluster. |
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 |
---|---|---|
|
@@ -55,4 +55,3 @@ template: | |
values: | ||
- value: "true" | ||
operation: "pattern match" | ||
|
Oops, something went wrong.