Skip to content

Commit b64e5ef

Browse files
authored
DVO-131: Fix default configuration with already watched rules (#261)
* Fix existing yaml files with pre-approved whitelist * Fix default configuration if no ConfigMap is set * Update documentation with default config * Add missing default checks * Fix spelling
1 parent 3b8fe9f commit b64e5ef

File tree

5 files changed

+75
-64
lines changed

5 files changed

+75
-64
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,20 @@ DVO performs validation checks using kube-linter. The checks configuration is mi
105105

106106
To configure DVO with a different set of checks, create a ConfigMap in the cluster with the new checks configuration. An example of a configuration ConfigMap can be found [here](./deploy/openshift/configmap.yaml).
107107

108+
If no custom configuration is found (the ConfigMap does not exist or does not contain a check declaration), the operator enables the following checks by default:
109+
* "host-ipc"
110+
* "host-network"
111+
* "host-pid"
112+
* "non-isolated-pod"
113+
* "pdb-max-unavailable"
114+
* "pdb-min-available"
115+
* "privilege-escalation-container"
116+
* "privileged-container"
117+
* "run-as-non-root"
118+
* "unsafe-sysctls"
119+
* "unset-cpu-requirements"
120+
* "unset-memory-requirements"
121+
108122
**constraint**: Currently, the configuration isn't continuously monitored and is only checked at startup. If a new set of checks is configured in a ConfigMap, the pod running DVO will need to be rebooted.
109123

110124
### Enabling checks

deploy/openshift/configmap.yaml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@ metadata:
88
data:
99
deployment-validation-operator-config.yaml: |-
1010
checks:
11-
# if doNotAutoAddDefaults is true, default checks are not automatically added.
12-
doNotAutoAddDefaults: false
13-
14-
# addAllBuiltIn, if set, adds all built-in checks. This allows users to
15-
# explicitly opt-out of checks that are not relevant using Exclude.
16-
# Takes precedence over doNotAutoAddDefaults, if both are set.
17-
addAllBuiltIn: true
18-
19-
exclude: ["access-to-create-pods", "access-to-secrets", "cluster-admin-role-binding", "default-service-account", "deprecated-service-account-field", "docker-sock", "drop-net-raw-capability", "env-var-secret", "exposed-services", "latest-tag", "mismatching-selector", "no-extensions-v1beta", "no-liveness-probe", "no-read-only-root-fs", "no-readiness-probe", "no-rolling-update-strategy", "privileged-ports", "read-secret-from-env-var", "required-annotation-email", "required-label-owner", "sensitive-host-mounts", "ssh-port", "unsafe-proc-mount", "use-namespace", "wildcard-in-rules", "writable-host-mount"]
11+
doNotAutoAddDefaults: true
12+
addAllBuiltIn: false
13+
include:
14+
- "host-ipc"
15+
- "host-network"
16+
- "host-pid"
17+
- "non-isolated-pod"
18+
- "pdb-max-unavailable"
19+
- "pdb-min-available"
20+
- "privilege-escalation-container"
21+
- "privileged-container"
22+
- "run-as-non-root"
23+
- "unsafe-sysctls"
24+
- "unset-cpu-requirements"
25+
- "unset-memory-requirements"

deploy/openshift/deployment-validation-operator-olm.yaml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,21 @@ objects:
4545
data:
4646
deployment-validation-operator-config.yaml: |-
4747
checks:
48-
# if doNotAutoAddDefaults is true, default checks are not automatically added.
49-
doNotAutoAddDefaults: false
50-
51-
# addAllBuiltIn, if set, adds all built-in checks. This allows users to
52-
# explicitly opt-out of checks that are not relevant using Exclude.
53-
# Takes precedence over doNotAutoAddDefaults, if both are set.
54-
addAllBuiltIn: true
55-
56-
exclude: ["access-to-create-pods", "access-to-secrets", "cluster-admin-role-binding", "default-service-account", "deprecated-service-account-field", "docker-sock", "drop-net-raw-capability", "env-var-secret", "exposed-services", "latest-tag", "mismatching-selector", "no-extensions-v1beta", "no-liveness-probe", "no-read-only-root-fs", "no-readiness-probe", "no-rolling-update-strategy", "privileged-ports", "read-secret-from-env-var", "required-annotation-email", "required-label-owner", "sensitive-host-mounts", "ssh-port", "unsafe-proc-mount", "use-namespace", "wildcard-in-rules", "writable-host-mount"]
48+
doNotAutoAddDefaults: true
49+
addAllBuiltIn: false
50+
include:
51+
- "host-ipc"
52+
- "host-network"
53+
- "host-pid"
54+
- "non-isolated-pod"
55+
- "pdb-max-unavailable"
56+
- "pdb-min-available"
57+
- "privilege-escalation-container"
58+
- "privileged-container"
59+
- "run-as-non-root"
60+
- "unsafe-sysctls"
61+
- "unset-cpu-requirements"
62+
- "unset-memory-requirements"
5763
- apiVersion: v1
5864
kind: Service
5965
metadata:

hack/olm-registry/olm-artifacts-template.yaml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,18 @@ objects:
151151
data:
152152
deployment-validation-operator-config.yaml: |-
153153
checks:
154-
# if doNotAutoAddDefaults is true, default checks are not automatically added.
155-
doNotAutoAddDefaults: false
156-
157-
# addAllBuiltIn, if set, adds all built-in checks. This allows users to
158-
# explicitly opt-out of checks that are not relevant using Exclude.
159-
# Takes precedence over doNotAutoAddDefaults, if both are set.
160-
addAllBuiltIn: true
161-
162-
exclude: ["access-to-create-pods", "access-to-secrets", "cluster-admin-role-binding", "default-service-account", "deprecated-service-account-field", "docker-sock", "drop-net-raw-capability", "env-var-secret", "exposed-services", "latest-tag", "mismatching-selector", "no-extensions-v1beta", "no-liveness-probe", "no-read-only-root-fs", "no-readiness-probe", "no-rolling-update-strategy", "privileged-ports", "read-secret-from-env-var", "required-annotation-email", "required-label-owner", "sensitive-host-mounts", "ssh-port", "unsafe-proc-mount", "use-namespace", "wildcard-in-rules", "writable-host-mount"]
154+
doNotAutoAddDefaults: true
155+
addAllBuiltIn: false
156+
include:
157+
- "host-ipc"
158+
- "host-network"
159+
- "host-pid"
160+
- "non-isolated-pod"
161+
- "pdb-max-unavailable"
162+
- "pdb-min-available"
163+
- "privilege-escalation-container"
164+
- "privileged-container"
165+
- "run-as-non-root"
166+
- "unsafe-sysctls"
167+
- "unset-cpu-requirements"
168+
- "unset-memory-requirements"

pkg/validations/validation_engine.go

Lines changed: 16 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,22 @@ func fileExists(filename string) bool {
5454
func (ve *validationEngine) LoadConfig(path string) error {
5555
if !fileExists(path) {
5656
log.Info(fmt.Sprintf("config file %s does not exist. Use default configuration", path))
57-
// legacy disabled checks
58-
ve.config.Checks.Exclude = getDisabledChecks()
59-
ve.config.Checks.AddAllBuiltIn = true
57+
// TODO - This hardcode will be removed when a ConfigMap is set by default in regular installation
58+
ve.config.Checks.DoNotAutoAddDefaults = true
59+
ve.config.Checks.Include = []string{
60+
"host-ipc",
61+
"host-network",
62+
"host-pid",
63+
"non-isolated-pod",
64+
"pdb-max-unavailable",
65+
"pdb-min-available",
66+
"privilege-escalation-container",
67+
"privileged-container",
68+
"run-as-non-root",
69+
"unsafe-sysctls",
70+
"unset-cpu-requirements",
71+
"unset-memory-requirements",
72+
}
6073

6174
return nil
6275
}
@@ -212,37 +225,3 @@ func getIncompatibleChecks() []string {
212225
//"non-isolated-pod",
213226
}
214227
}
215-
216-
// getDisabledChecks returns an array of kube-linter check names that are disabled for DVO
217-
// These checks are disabled as they do not have supporting Openshift documentation
218-
// 38 checks... 47 checks according to kube-linter website
219-
func getDisabledChecks() []string {
220-
return []string{
221-
"access-to-create-pods",
222-
"access-to-secrets",
223-
"cluster-admin-role-binding",
224-
"default-service-account",
225-
"deprecated-service-account-field",
226-
"docker-sock",
227-
"drop-net-raw-capability",
228-
"env-var-secret",
229-
"exposed-services",
230-
"latest-tag",
231-
"mismatching-selector",
232-
"no-extensions-v1beta",
233-
"no-liveness-probe",
234-
"no-read-only-root-fs",
235-
"no-readiness-probe",
236-
"no-rolling-update-strategy",
237-
"privileged-ports",
238-
"read-secret-from-env-var",
239-
"required-annotation-email",
240-
"required-label-owner",
241-
"sensitive-host-mounts",
242-
"ssh-port",
243-
"unsafe-proc-mount",
244-
"use-namespace",
245-
"wildcard-in-rules",
246-
"writable-host-mount",
247-
}
248-
}

0 commit comments

Comments
 (0)