-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(plugins): update kubernetes iac polices
- Loading branch information
Showing
37 changed files
with
414 additions
and
49 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
3 changes: 0 additions & 3 deletions
3
plugins/go/veinmind-iac/rules/kubernetes/apiserver_10250_wrong_settings.rego
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
6 changes: 2 additions & 4 deletions
6
plugins/go/veinmind-iac/rules/kubernetes/apiserver_anonymous_wrong_settings.rego
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 |
---|---|---|
@@ -1,12 +1,10 @@ | ||
package brightMirror.kubernetes | ||
|
||
import data.common | ||
import future.keywords.in | ||
import future.keywords.contains | ||
import future.keywords.if | ||
|
||
risks[res]{ | ||
input.metadata.name=="system:anonymous" | ||
input.kind=="ClusterRoleBinding" | ||
input.roleRef.name=="cluster-admin" | ||
input.subjects[i].name=="system:anonymous" | ||
res := common.result({"original":"UnSafeSettings:`metadata.name`,`roleRef.name`", "Path": input.Path}, "KN-006") | ||
} |
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: 6 additions & 3 deletions
9
plugins/go/veinmind-iac/rules/kubernetes/dashboard_skip_login.rego
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 |
---|---|---|
@@ -1,11 +1,14 @@ | ||
package brightMirror.kubernetes | ||
|
||
import data.common | ||
import future.keywords.in | ||
import future.keywords.contains | ||
import future.keywords.if | ||
|
||
risks[res]{ | ||
contains(input.spec.containers[0].args[i],"enable-skip-login") | ||
contains(input.spec.containers[_].args[i],"enable-skip-login") | ||
res := common.result({"original":"UnSafeSettings:`spec.containers.args`", "Path": input.Path}, "KN-008") | ||
} | ||
|
||
risks[res]{ | ||
contains(input.spec.template.spec.containers[_].args[i],"enable-skip-login") | ||
res := common.result({"original":"UnSafeSettings:`spec.containers.args`", "Path": input.Path}, "KN-008") | ||
} |
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
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
17 changes: 13 additions & 4 deletions
17
plugins/go/veinmind-iac/rules/kubernetes/pod_container_selinux.rego
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 |
---|---|---|
@@ -1,8 +1,17 @@ | ||
package brightMirror.kubernetes | ||
|
||
import data.common | ||
import future.keywords.every | ||
|
||
#risks[res] { | ||
# securityContexts | ||
# res := kubernetes.result(securityContexts, "KN-004") | ||
#} | ||
default allow=false | ||
|
||
allowValuesSeLinuxOptionsType:=["container_t","container_init_t","container_kvm_t"] | ||
|
||
risks[res]{ | ||
inner := input.spec.containers[i] | ||
type := inner.securityContext.seLinuxOptions.type | ||
every val in allowValuesSeLinuxOptionsType { | ||
val != type | ||
} | ||
res:= common.result({"original":"UnSafeSettings:`spec.containers.securityContext.seLinuxOptions.type`", "Path": input.Path},"KN-004") | ||
} |
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,8 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: nginx-pod | ||
spec: | ||
containers: | ||
- name: nginx-container | ||
image: nginx:latest |
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,20 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: hello-privileged | ||
spec: | ||
containers: | ||
- command: | ||
- sh | ||
- "-c" | ||
- echo 'Hello' && sleep 1h | ||
image: busybox:v1.26.0 | ||
name: hello | ||
securityContext: | ||
seccompProfile: | ||
type: Localhost | ||
runAsNonRoot: true | ||
capabilities: | ||
drop: | ||
- ALL | ||
allowPrivilegeEscalations: true |
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,21 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
annotations: | ||
container.apparmor.security.beta.kubernetes.io/hello: custom | ||
name: hello-apparmor | ||
spec: | ||
containers: | ||
- command: | ||
- sh | ||
- "-c" | ||
- echo 'Hello AppArmor!' && sleep 1h | ||
image: busybox:v1.26.0 | ||
name: hello | ||
securityContext: | ||
seccompProfile: | ||
type: Localhost | ||
runAsNonRoot: true | ||
capabilities: | ||
drop: | ||
- ALL |
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,21 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: hello-selinux | ||
spec: | ||
containers: | ||
- command: | ||
- sh | ||
- "-c" | ||
- echo 'Hello' && sleep 1h | ||
image: busybox:v1.26.0 | ||
name: hello | ||
securityContext: | ||
seccompProfile: | ||
type: Localhost | ||
runAsNonRoot: true | ||
capabilities: | ||
drop: | ||
- ALL | ||
seLinuxOptions: | ||
type: custom |
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,13 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: kube-apiserver | ||
spec: | ||
containers: | ||
- name: kube-apiserver | ||
image: k8s.gcr.io/kube-apiserver:v1.17.0 | ||
command: | ||
- kube-apiserver | ||
args: | ||
- --insecure-port=8080 | ||
- --insecure-bind-address=0.0.0.0 |
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,12 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: anonymous-cluster-admin | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: cluster-admin | ||
subjects: | ||
- apiGroup: rbac.authorization.k8s.io | ||
kind: User | ||
name: system:anonymous |
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,11 @@ | ||
apiVersion: kubelet.config.k8s.io/v1beta1 | ||
kind: KubeletConfiguration | ||
authentication: | ||
anonymous: | ||
enabled: true | ||
webhook: | ||
enabled: false | ||
x509: | ||
clientCAFile: "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" | ||
authorization: | ||
mode: AlwaysAllow |
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,33 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
k8s-app: kubernetes-dashboard | ||
name: kubernetes-dashboard | ||
namespace: kube-system | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
k8s-app: kubernetes-dashboard | ||
template: | ||
metadata: | ||
labels: | ||
k8s-app: kubernetes-dashboard | ||
spec: | ||
containers: | ||
- name: kubernetes-dashboard | ||
image: kubernetesui/dashboard:v2.2.0 | ||
args: | ||
- --enable-skip-login | ||
ports: | ||
- containerPort: 8443 | ||
name: dashboard | ||
protocol: TCP | ||
volumeMounts: | ||
- mountPath: /certs | ||
name: kubernetes-dashboard-certs | ||
volumes: | ||
- name: kubernetes-dashboard-certs | ||
secret: | ||
secretName: kubernetes-dashboard-certs |
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 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: etcd | ||
namespace: kube-system | ||
spec: | ||
containers: | ||
- name: etcd | ||
image: quay.io/coreos/etcd:v3.4.15 | ||
command: | ||
- etcd | ||
args: | ||
- --name=etcd-node | ||
- --listen-client-urls=http://0.0.0.0:2379 | ||
- --advertise-client-urls=http://localhost:2379 | ||
- --listen-peer-urls=http://0.0.0.0:2380 | ||
- --initial-advertise-peer-urls=http://localhost:2380 | ||
- --initial-cluster=etcd-node=http://localhost:2380 | ||
- --initial-cluster-token=etcd-cluster | ||
- --initial-cluster-state=new | ||
- --peer-client-cert-auth=true | ||
ports: | ||
- containerPort: 2379 | ||
name: client | ||
- containerPort: 2380 | ||
name: peer |
Oops, something went wrong.