fix: conditional expressions should be at very top of additionalSchemaStrings (#1025)

This commit is contained in:
John Slivka
2024-01-03 14:17:04 -06:00
committed by GitHub
parent 0b765df04d
commit c8394bf9d7
8 changed files with 99 additions and 9 deletions
+2 -2
View File
@@ -37,10 +37,10 @@ schemaString: |
const: "cluster-admin"
additionalSchemaStrings:
rbac.authorization.k8s.io/ClusterRole: |
type: object
# Do not alert on default ClusterRoleBindings.
{{ if (ne .roleRef.name "view") }}
{{ if and (ne .metadata.name "cluster-admin") (not (hasPrefix .metadata.name "system:")) (ne .metadata.name "gce:podsecuritypolicy:calico-sa") }}
# Do not alert on default ClusterRoleBindings.
type: object
required: ["metadata", "rules"]
allOf:
- properties:
@@ -45,10 +45,10 @@ schemaString: |
const: "cluster-admin"
additionalSchemaStrings:
rbac.authorization.k8s.io/ClusterRole: |
type: object
# This schema is validated for all roleBindings, regardless of their roleRef.
{{ if eq .roleRef.kind "ClusterRole" }}
{{ if and (not (hasPrefix .metadata.name "system:")) (ne .metadata.name "gce:podsecuritypolicy:calico-sa") }}
# This schema is validated for all roleBindings, regardless of their roleRef.
type: object
required: ["metadata", "rules"]
allOf:
- properties:
@@ -43,10 +43,10 @@ schemaString: |
minLength: 1
additionalSchemaStrings:
rbac.authorization.k8s.io/ClusterRole: |
type: object
# This schema is validated for all roleBindings, regardless of their roleRef.
{{ if eq .roleRef.kind "ClusterRole" }}
{{ if and (not (hasPrefix .metadata.name "system:")) (ne .metadata.name "gce:podsecuritypolicy:calico-sa") }}
# This schema is validated for all roleBindings, regardless of their roleRef.
type: object
required: ["metadata", "rules"]
allOf:
- properties:
+2 -2
View File
@@ -46,10 +46,10 @@ schemaString: |
minLength: 1
additionalSchemaStrings:
rbac.authorization.k8s.io/Role: |
type: object
# This schema is validated for all roleBindings, regardless of their roleRef.
{{ if eq .roleRef.kind "Role" }}
{{ if and (not (hasPrefix .metadata.name "system:")) (ne .metadata.name "gce:podsecuritypolicy:calico-sa") }}
# This schema is validated for all roleBindings, regardless of their roleRef.
type: object
required: ["metadata", "rules"]
allOf:
- properties:
+1 -1
View File
@@ -4,6 +4,7 @@ go 1.20
require (
github.com/AlecAivazis/survey/v2 v2.3.7
github.com/fairwindsops/controller-utils v0.3.0
github.com/fairwindsops/insights-plugins/plugins/workloads v0.0.0-20230601204422-5c789e15990c
github.com/fatih/color v1.15.0
github.com/gobuffalo/packr/v2 v2.8.3
@@ -30,7 +31,6 @@ require (
github.com/emicklei/go-restful/v3 v3.10.1 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fairwindsops/controller-utils v0.3.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
@@ -0,0 +1,30 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: test
labels:
role: service
tier: backend
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: test
rules:
- apiGroups: [""]
resources: [services]
verbs: [get, list]
---
# check when there are no cluster roles present
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: test
roleRef:
kind: Role
name: test
apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
name: test
@@ -0,0 +1,30 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: test
labels:
role: service
tier: backend
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: test
rules:
- apiGroups: [""]
resources: [services]
verbs: [get, list]
---
# check when there are no cluster roles present
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: test
roleRef:
kind: Role
name: test
apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
name: test
@@ -0,0 +1,30 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: test
labels:
role: service
tier: backend
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: test
rules:
- apiGroups: [""]
resources: [services]
verbs: [get, list]
---
# check when there are no cluster roles present
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: test
roleRef:
kind: Role
name: test
apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
name: test