Skip to content

Commit 52a646c

Browse files
LaibaBareeraafdesk
andauthored
Add rh 1.4 (#1922)
* add CIS Benchmark for eks-v1.7 * fix failed test cases * added eks 1.7 for supported kubernetes version * added eks 1.7 for supported kubernetes version * fix failed test cases * add test cases for it * fix * add test case for eks 1.5 * change methodoloy * fix the issue mentioned in pr * fix linter error * Update cmd/util.go Co-authored-by: afdesk <[email protected]> * fix the failed test * add cis benchmark for red hat openshift containre v1.4 * fix failed test cases * fix checks for rh-1.4 * mark scored true to manual test if they have test cases * fix check 1.2.4 * rebase the changes in go.sum --------- Co-authored-by: afdesk <[email protected]>
1 parent 0333e55 commit 52a646c

File tree

10 files changed

+2587
-3
lines changed

10 files changed

+2587
-3
lines changed

cfg/config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ version_mapping:
297297
"ocp-3.10": "rh-0.7"
298298
"ocp-3.11": "rh-0.7"
299299
"ocp-4.0": "rh-1.0"
300+
"ocp-4.17": "rh-1.4"
300301
"aks-1.0": "aks-1.0"
301302
"aks-1.7": "aks-1.7"
302303
"ack-1.0": "ack-1.0"
@@ -457,6 +458,12 @@ target_mapping:
457458
- "controlplane"
458459
- "policies"
459460
- "etcd"
461+
"rh-1.4":
462+
- "master"
463+
- "node"
464+
- "controlplane"
465+
- "policies"
466+
- "etcd"
460467
"eks-stig-kubernetes-v1r6":
461468
- "node"
462469
- "controlplane"

cfg/rh-1.4/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
## Version-specific settings that override the values in cfg/config.yaml

cfg/rh-1.4/controlplane.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
controls:
3+
version: rh-1.4
4+
id: 3
5+
text: "Control Plane Configuration"
6+
type: "controlplane"
7+
groups:
8+
- id: 3.1
9+
text: "Authentication and Authorization"
10+
checks:
11+
- id: 3.1.1
12+
text: "Client certificate authentication should not be used for users (Manual)"
13+
audit: |
14+
# To verify user authentication is enabled
15+
oc describe authentication
16+
# To verify that an identity provider is configured
17+
oc get identity
18+
# To verify that a custom cluster-admin user exists
19+
oc get clusterrolebindings -o=custom-columns=NAME:.metadata.name,ROLE:.roleRef.name,SUBJECT:.subjects[*].kind | grep cluster-admin | grep User
20+
# To verity that kbueadmin is removed, no results should be returned
21+
oc get secrets kubeadmin -n kube-system
22+
type: manual
23+
remediation: |
24+
Configure an identity provider for the OpenShift cluster.
25+
Understanding identity provider configuration | Authentication | OpenShift
26+
Container Platform 4.5. Once an identity provider has been defined,
27+
you can use RBAC to define and apply permissions.
28+
After you define an identity provider and create a new cluster-admin user,
29+
remove the kubeadmin user to improve cluster security.
30+
scored: false
31+
32+
- id: 3.2
33+
text: "Logging"
34+
checks:
35+
- id: 3.2.1
36+
text: "Ensure that a minimal audit policy is created (Manual)"
37+
audit: |
38+
#To view kube apiserver log files
39+
oc adm node-logs --role=master --path=kube-apiserver/
40+
#To view openshift apiserver log files
41+
oc adm node-logs --role=master --path=openshift-apiserver/
42+
#To verify kube apiserver audit config
43+
oc get configmap config -n openshift-kube-apiserver -ojson | jq -r '.data["config.yaml"]' | jq '.auditConfig[]?'
44+
#To verify openshift apiserver audit config
45+
oc get configmap config -n openshift-apiserver -ojson | jq -r '.data["config.yaml"]' | jq '.auditConfig[]?'
46+
type: manual
47+
remediation: |
48+
No remediation required.
49+
scored: false
50+
51+
- id: 3.2.2
52+
text: "Ensure that the audit policy covers key security concerns (Manual)"
53+
audit: |
54+
#To verify openshift apiserver audit config
55+
oc get configmap config -n openshift-kube-apiserver -ojson | jq -r '.data["config.yaml"]' | jq '.auditConfig.policyConfiguration.rules[]?'
56+
#To verify kube apiserver audit config
57+
oc get configmap config -n openshift-apiserver -ojson | jq -r '.data["config.yaml"]' | jq '.auditConfig.policyConfiguration.rules[]?'
58+
type: manual
59+
remediation: |
60+
In OpenShift 4.6 and higher, if appropriate for your needs,
61+
modify the audit policy.
62+
scored: false

cfg/rh-1.4/etcd.yaml

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
---
2+
controls:
3+
version: rh-1.4
4+
id: 2
5+
text: "Etcd"
6+
type: "etcd"
7+
groups:
8+
- id: 2
9+
text: "Etcd"
10+
checks:
11+
- id: 2.1
12+
text: "Ensure that the --cert-file and --key-file arguments are set as appropriate (Manual)"
13+
audit: |
14+
# Get the node name where the pod is running
15+
NODE_NAME=$(oc get pod "$HOSTNAME" -o=jsonpath='{.spec.nodeName}')
16+
# Get the pod name in the openshift-etcd namespace
17+
POD_NAME=$(oc get pods -n openshift-etcd -l app=etcd --field-selector spec.nodeName="$NODE_NAME" -o jsonpath='{.items[0].metadata.name}' 2>/dev/null)
18+
if [ -z "$POD_NAME" ]; then
19+
echo "No matching file found on the current node."
20+
else
21+
# Execute the stat command
22+
oc exec -n openshift-etcd -c etcd "$POD_NAME" -- ps -o command= -C etcd | sed 's/.*\(--cert-file=[^ ]*\).*/\1/'
23+
oc exec -n openshift-etcd -c etcd "$POD_NAME" -- ps -o command= -C etcd | sed 's/.*\(--key-file=[^ ]*\).*/\1/'
24+
fi
25+
use_multiple_values: true
26+
tests:
27+
test_items:
28+
- flag: "file"
29+
compare:
30+
op: regex
31+
value: '\/etc\/kubernetes\/static-pod-certs\/secrets\/etcd-all-(serving|certs)\/etcd-serving-.*\.(?:crt|key)'
32+
remediation: |
33+
OpenShift does not use the etcd-certfile or etcd-keyfile flags.
34+
Certificates for etcd are managed by the etcd cluster operator.
35+
scored: true
36+
37+
- id: 2.2
38+
text: "Ensure that the --client-cert-auth argument is set to true (Manual)"
39+
audit: |
40+
# Get the node name where the pod is running
41+
NODE_NAME=$(oc get pod "$HOSTNAME" -o=jsonpath='{.spec.nodeName}')
42+
# Get the pod name in the openshift-etcd namespace
43+
POD_NAME=$(oc get pods -n openshift-etcd -l app=etcd --field-selector spec.nodeName="$NODE_NAME" -o jsonpath='{.items[0].metadata.name}' 2>/dev/null)
44+
if [ -z "$POD_NAME" ]; then
45+
echo "No matching file found on the current node."
46+
else
47+
# Execute the stat command
48+
oc exec -n openshift-etcd -c etcd "$POD_NAME" -- ps -o command= -C etcd | sed 's/.*\(--client-cert-auth=[^ ]*\).*/\1/'
49+
fi
50+
use_multiple_values: true
51+
tests:
52+
test_items:
53+
- flag: "--client-cert-auth"
54+
compare:
55+
op: eq
56+
value: true
57+
remediation: |
58+
This setting is managed by the cluster etcd operator. No remediation required."
59+
scored: true
60+
61+
- id: 2.3
62+
text: "Ensure that the --auto-tls argument is not set to true (Manual)"
63+
audit: |
64+
# Returns 0 if found, 1 if not found
65+
# Get the node name where the pod is running
66+
NODE_NAME=$(oc get pod "$HOSTNAME" -o=jsonpath='{.spec.nodeName}')
67+
# Get the pod name in the openshift-etcd namespace
68+
POD_NAME=$(oc get pods -n openshift-etcd -l app=etcd --field-selector spec.nodeName="$NODE_NAME" -o jsonpath='{.items[0].metadata.name}' 2>/dev/null)
69+
if [ -z "$POD_NAME" ]; then
70+
echo "No matching file found on the current node."
71+
else
72+
# Execute the stat command
73+
oc exec -n openshift-etcd -c etcd "$POD_NAME" -- ps -o command= -C etcd | grep -- --auto-tls=true 2>/dev/null ; echo exit_code=$?
74+
fi
75+
use_multiple_values: true
76+
tests:
77+
test_items:
78+
- flag: "exit_code"
79+
compare:
80+
op: eq
81+
value: "1"
82+
remediation: |
83+
This setting is managed by the cluster etcd operator. No remediation required.
84+
scored: true
85+
86+
- id: 2.4
87+
text: "Ensure that the --peer-cert-file and --peer-key-file arguments are set as appropriate (Manual)"
88+
audit: |
89+
# Get the node name where the pod is running
90+
NODE_NAME=$(oc get pod "$HOSTNAME" -o=jsonpath='{.spec.nodeName}')
91+
# Get the pod name in the openshift-etcd namespace
92+
POD_NAME=$(oc get pods -n openshift-etcd -l app=etcd --field-selector spec.nodeName="$NODE_NAME" -o jsonpath='{.items[0].metadata.name}' 2>/dev/null)
93+
if [ -z "$POD_NAME" ]; then
94+
echo "No matching file found on the current node."
95+
else
96+
# Execute the stat command
97+
oc exec -n openshift-etcd -c etcd "$POD_NAME" -- ps -o command= -C etcd | sed 's/.*\(--peer-cert-file=[^ ]*\).*/\1/'
98+
oc exec -n openshift-etcd -c etcd "$POD_NAME" -- ps -o command= -C etcd | sed 's/.*\(--peer-key-file=[^ ]*\).*/\1/'
99+
fi
100+
use_multiple_values: true
101+
tests:
102+
test_items:
103+
- flag: "file"
104+
compare:
105+
op: regex
106+
value: '\/etc\/kubernetes\/static-pod-certs\/secrets\/etcd-all-(peer|certs)\/etcd-peer-.*\.(?:crt|key)'
107+
remediation: |
108+
None. This configuration is managed by the etcd operator.
109+
scored: true
110+
111+
- id: 2.5
112+
text: "Ensure that the --peer-client-cert-auth argument is set to true (Manual)"
113+
audit: |
114+
# Get the node name where the pod is running
115+
NODE_NAME=$(oc get pod "$HOSTNAME" -o=jsonpath='{.spec.nodeName}')
116+
# Get the pod name in the openshift-etcd namespace
117+
POD_NAME=$(oc get pods -n openshift-etcd -l app=etcd --field-selector spec.nodeName="$NODE_NAME" -o jsonpath='{.items[0].metadata.name}' 2>/dev/null)
118+
if [ -z "$POD_NAME" ]; then
119+
echo "No matching file found on the current node."
120+
else
121+
# Execute the stat command
122+
oc exec -n openshift-etcd -c etcd "$POD_NAME" -- ps -o command= -C etcd | sed 's/.*\(--peer-client-cert-auth=[^ ]*\).*/\1/'
123+
fi
124+
use_multiple_values: true
125+
tests:
126+
test_items:
127+
- flag: "--peer-client-cert-auth"
128+
compare:
129+
op: eq
130+
value: true
131+
remediation: |
132+
This setting is managed by the cluster etcd operator. No remediation required.
133+
scored: true
134+
135+
- id: 2.6
136+
text: "Ensure that the --peer-auto-tls argument is not set to true (Manual)"
137+
audit: |
138+
# Returns 0 if found, 1 if not found
139+
# Get the node name where the pod is running
140+
NODE_NAME=$(oc get pod "$HOSTNAME" -o=jsonpath='{.spec.nodeName}')
141+
# Get the pod name in the openshift-etcd namespace
142+
POD_NAME=$(oc get pods -n openshift-etcd -l app=etcd --field-selector spec.nodeName="$NODE_NAME" -o jsonpath='{.items[0].metadata.name}' 2>/dev/null)
143+
if [ -z "$POD_NAME" ]; then
144+
echo "No matching file found on the current node."
145+
else
146+
# Execute the stat command
147+
oc exec -n openshift-etcd -c etcd "$POD_NAME" -- ps -o command= -C etcd | grep -- --peer-auto-tls=true 2>/dev/null ; echo exit_code=$?
148+
fi
149+
use_multiple_values: true
150+
tests:
151+
test_items:
152+
- flag: "exit_code"
153+
compare:
154+
op: eq
155+
value: "1"
156+
remediation: |
157+
This setting is managed by the cluster etcd operator. No remediation required.
158+
scored: true
159+
160+
- id: 2.7
161+
text: "Ensure that a unique Certificate Authority is used for etcd (Manual)"
162+
audit: |
163+
# Get the node name where the pod is running
164+
NODE_NAME=$(oc get pod "$HOSTNAME" -o=jsonpath='{.spec.nodeName}')
165+
# Get the pod name in the openshift-etcd namespace
166+
POD_NAME=$(oc get pods -n openshift-etcd -l app=etcd --field-selector spec.nodeName="$NODE_NAME" -o jsonpath='{.items[0].metadata.name}' 2>/dev/null)
167+
if [ -z "$POD_NAME" ]; then
168+
echo "No matching file found on the current node."
169+
else
170+
# Execute the stat command
171+
oc exec -n openshift-etcd -c etcd "$POD_NAME" -- ps -o command= -C etcd | sed 's/.*\(--trusted-ca-file=[^ ]*\).*/\1/'
172+
oc exec -n openshift-etcd -c etcd "$POD_NAME" -- ps -o command= -C etcd | sed 's/.*\(--peer-trusted-ca-file=[^ ]*\).*/\1/'
173+
fi
174+
use_multiple_values: true
175+
tests:
176+
test_items:
177+
- flag: "file"
178+
compare:
179+
op: regex
180+
value: '\/etc\/kubernetes\/static-pod-certs\/configmaps\/(?:etcd-(?:serving|peer-client)-ca\/ca-bundle\.crt|etcd-all-bundles\/server-ca-bundle\.crt)'
181+
remediation: |
182+
None required. Certificates for etcd are managed by the OpenShift cluster etcd operator.
183+
scored: true

0 commit comments

Comments
 (0)