-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(kubernetes): Validate k8s spec type (#3483)
* validate spec type * added ut * updated ut assertion
- Loading branch information
Showing
10 changed files
with
45 additions
and
8 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
9 changes: 9 additions & 0 deletions
9
tests/kubernetes/checks/example_RootContainers/rootContainersFAILED-malformed-spec.yaml
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 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: pod1 | ||
spec: | ||
- containers: | ||
- name: main | ||
image: alpine | ||
command: ["/bin/sleep", "999999"] |
26 changes: 26 additions & 0 deletions
26
tests/kubernetes/checks/example_SecurityContexts/pod-container-FAILED_malformed_spec.yaml
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,26 @@ | ||
# Source: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: security-context-demo | ||
spec: | ||
- securityContext: | ||
runAsUser: 1000 | ||
runAsGroup: 3000 | ||
fsGroup: 2000 | ||
- volumes: | ||
- name: sec-ctx-vol | ||
emptyDir: {} | ||
- containers: | ||
- name: sec-ctx-demo | ||
image: busybox | ||
command: [ "sh", "-c", "sleep 1h" ] | ||
volumeMounts: | ||
- name: sec-ctx-vol | ||
mountPath: /data/demo | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
# https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ | ||
# cat /proc/1/status | ||
# allowPrivilegeEscalation: false means NoNewPrivs = 1 | ||
# https://www.kernel.org/doc/html/latest/userspace-api/no_new_privs.html |
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