Skip to content

Commit

Permalink
NVSHAS-6097/7821: Import/Export of Vulnerability/Compliance Profiles
Browse files Browse the repository at this point in the history
(cherry picked from commit 5069f75)
  • Loading branch information
andsont committed Nov 24, 2023
1 parent 26921cb commit 48f1bbd
Show file tree
Hide file tree
Showing 5 changed files with 482 additions and 2 deletions.
118 changes: 118 additions & 0 deletions charts/core/templates/crd-role-least.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -296,4 +296,122 @@ userNames:
- system:serviceaccount:{{ .Release.Namespace }}:controller
{{- end }}

---

# ClusterRole for NeuVector to manage compliance CRD profiles
{{- if $oc3 }}
apiVersion: authorization.openshift.io/v1
{{- else if (semverCompare ">=1.8-0" (substr 1 -1 .Capabilities.KubeVersion.GitVersion)) }}
apiVersion: rbac.authorization.k8s.io/v1
{{- else }}
apiVersion: v1
{{- end }}
kind: ClusterRole
metadata:
name: neuvector-binding-nvcomplianceprofiles
labels:
chart: {{ template "neuvector.chart" . }}
release: {{ .Release.Name }}
heritage: Helm
rules:
- apiGroups:
- neuvector.com
resources:
- nvcomplianceprofiles
verbs:
- get
- list
- delete

---

# ClusterRoleBinding for NeuVector to manage compliance CRD profiles
{{- if $oc3 }}
apiVersion: authorization.openshift.io/v1
{{- else if (semverCompare ">=1.8-0" (substr 1 -1 .Capabilities.KubeVersion.GitVersion)) }}
apiVersion: rbac.authorization.k8s.io/v1
{{- else }}
apiVersion: v1
{{- end }}
kind: ClusterRoleBinding
metadata:
name: neuvector-binding-nvcomplianceprofiles
labels:
chart: {{ template "neuvector.chart" . }}
release: {{ .Release.Name }}
heritage: Helm
roleRef:
{{- if not $oc3 }}
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
{{- end }}
name: neuvector-binding-nvcomplianceprofiles
subjects:
- kind: ServiceAccount
name: controller
namespace: {{ .Release.Namespace }}
{{- if $oc3 }}
userNames:
- system:serviceaccount:{{ .Release.Namespace }}:controller
{{- end }}

---

# ClusterRole for NeuVector to manage vulnerability CRD profiles
{{- if $oc3 }}
apiVersion: authorization.openshift.io/v1
{{- else if (semverCompare ">=1.8-0" (substr 1 -1 .Capabilities.KubeVersion.GitVersion)) }}
apiVersion: rbac.authorization.k8s.io/v1
{{- else }}
apiVersion: v1
{{- end }}
kind: ClusterRole
metadata:
name: neuvector-binding-nvvulnerabilityprofiles
labels:
chart: {{ template "neuvector.chart" . }}
release: {{ .Release.Name }}
heritage: Helm
rules:
- apiGroups:
- neuvector.com
resources:
- nvvulnerabilityprofiles
verbs:
- get
- list
- delete

---

# ClusterRoleBinding for NeuVector to manage vulnerability CRD profiles
{{- if $oc3 }}
apiVersion: authorization.openshift.io/v1
{{- else if (semverCompare ">=1.8-0" (substr 1 -1 .Capabilities.KubeVersion.GitVersion)) }}
apiVersion: rbac.authorization.k8s.io/v1
{{- else }}
apiVersion: v1
{{- end }}
kind: ClusterRoleBinding
metadata:
name: neuvector-binding-nvvulnerabilityprofiles
labels:
chart: {{ template "neuvector.chart" . }}
release: {{ .Release.Name }}
heritage: Helm
roleRef:
{{- if not $oc3 }}
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
{{- end }}
name: neuvector-binding-nvvulnerabilityprofiles
subjects:
- kind: ServiceAccount
name: controller
namespace: {{ .Release.Namespace }}
{{- if $oc3 }}
userNames:
- system:serviceaccount:{{ .Release.Namespace }}:controller
{{- end }}

{{- end }}
118 changes: 118 additions & 0 deletions charts/core/templates/crd-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -296,4 +296,122 @@ userNames:
- system:serviceaccount:{{ .Release.Namespace }}:{{ .Values.serviceAccount }}
{{- end }}

---

# ClusterRole for NeuVector to manage compliance CRD profiles
{{- if $oc3 }}
apiVersion: authorization.openshift.io/v1
{{- else if (semverCompare ">=1.8-0" (substr 1 -1 .Capabilities.KubeVersion.GitVersion)) }}
apiVersion: rbac.authorization.k8s.io/v1
{{- else }}
apiVersion: v1
{{- end }}
kind: ClusterRole
metadata:
name: neuvector-binding-nvcomplianceprofiles
labels:
chart: {{ template "neuvector.chart" . }}
release: {{ .Release.Name }}
heritage: Helm
rules:
- apiGroups:
- neuvector.com
resources:
- nvcomplianceprofiles
verbs:
- get
- list
- delete

---

# ClusterRoleBinding for NeuVector to manage compliance CRD profiles
{{- if $oc3 }}
apiVersion: authorization.openshift.io/v1
{{- else if (semverCompare ">=1.8-0" (substr 1 -1 .Capabilities.KubeVersion.GitVersion)) }}
apiVersion: rbac.authorization.k8s.io/v1
{{- else }}
apiVersion: v1
{{- end }}
kind: ClusterRoleBinding
metadata:
name: neuvector-binding-nvcomplianceprofiles
labels:
chart: {{ template "neuvector.chart" . }}
release: {{ .Release.Name }}
heritage: Helm
roleRef:
{{- if not $oc3 }}
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
{{- end }}
name: neuvector-binding-nvcomplianceprofiles
subjects:
- kind: ServiceAccount
name: {{ .Values.serviceAccount }}
namespace: {{ .Release.Namespace }}
{{- if $oc3 }}
userNames:
- system:serviceaccount:{{ .Release.Namespace }}:{{ .Values.serviceAccount }}
{{- end }}

---

# ClusterRole for NeuVector to manage vulnerability CRD profiles
{{- if $oc3 }}
apiVersion: authorization.openshift.io/v1
{{- else if (semverCompare ">=1.8-0" (substr 1 -1 .Capabilities.KubeVersion.GitVersion)) }}
apiVersion: rbac.authorization.k8s.io/v1
{{- else }}
apiVersion: v1
{{- end }}
kind: ClusterRole
metadata:
name: neuvector-binding-nvvulnerabilityprofiles
labels:
chart: {{ template "neuvector.chart" . }}
release: {{ .Release.Name }}
heritage: Helm
rules:
- apiGroups:
- neuvector.com
resources:
- nvvulnerabilityprofiles
verbs:
- get
- list
- delete

---

# ClusterRoleBinding for NeuVector to manage vulnerability CRD profiles
{{- if $oc3 }}
apiVersion: authorization.openshift.io/v1
{{- else if (semverCompare ">=1.8-0" (substr 1 -1 .Capabilities.KubeVersion.GitVersion)) }}
apiVersion: rbac.authorization.k8s.io/v1
{{- else }}
apiVersion: v1
{{- end }}
kind: ClusterRoleBinding
metadata:
name: neuvector-binding-nvvulnerabilityprofiles
labels:
chart: {{ template "neuvector.chart" . }}
release: {{ .Release.Name }}
heritage: Helm
roleRef:
{{- if not $oc3 }}
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
{{- end }}
name: neuvector-binding-nvvulnerabilityprofiles
subjects:
- kind: ServiceAccount
name: {{ .Values.serviceAccount }}
namespace: {{ .Release.Namespace }}
{{- if $oc3 }}
userNames:
- system:serviceaccount:{{ .Release.Namespace }}:{{ .Values.serviceAccount }}
{{- end }}

{{- end }}
122 changes: 122 additions & 0 deletions charts/core/templates/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,128 @@ spec:
type: object
{{- end }}
---
{{- if (semverCompare ">=1.19-0" (substr 1 -1 .Capabilities.KubeVersion.GitVersion)) }}
apiVersion: apiextensions.k8s.io/v1
{{- else }}
apiVersion: apiextensions.k8s.io/v1beta1
{{- end }}
kind: CustomResourceDefinition
metadata:
name: nvcomplianceprofiles.neuvector.com
labels:
chart: {{ template "neuvector.chart" . }}
release: {{ .Release.Name }}
heritage: Helm
spec:
group: neuvector.com
names:
kind: NvComplianceProfile
listKind: NvComplianceProfileList
plural: nvcomplianceprofiles
singular: nvcomplianceprofile
scope: Cluster
{{- if (semverCompare "<1.19-0" (substr 1 -1 .Capabilities.KubeVersion.GitVersion)) }}
version: v1
{{- end }}
versions:
- name: v1
served: true
storage: true
{{- if (semverCompare ">=1.19-0" (substr 1 -1 .Capabilities.KubeVersion.GitVersion)) }}
schema:
openAPIV3Schema:
properties:
spec:
properties:
templates:
properties:
disable_system:
type: boolean
entries:
items:
properties:
tags:
items:
type: string
type: array
test_number:
type: string
required:
- test_number
type: object
type: array
required:
- entries
type: object
type: object
type: object
{{- end }}
---
{{- if (semverCompare ">=1.19-0" (substr 1 -1 .Capabilities.KubeVersion.GitVersion)) }}
apiVersion: apiextensions.k8s.io/v1
{{- else }}
apiVersion: apiextensions.k8s.io/v1beta1
{{- end }}
kind: CustomResourceDefinition
metadata:
name: nvvulnerabilityprofiles.neuvector.com
labels:
chart: {{ template "neuvector.chart" . }}
release: {{ .Release.Name }}
heritage: Helm
spec:
group: neuvector.com
names:
kind: NvVulnerabilityProfile
listKind: NvVulnerabilityProfileList
plural: nvvulnerabilityprofiles
singular: nvvulnerabilityprofile
scope: Cluster
{{- if (semverCompare "<1.19-0" (substr 1 -1 .Capabilities.KubeVersion.GitVersion)) }}
version: v1
{{- end }}
versions:
- name: v1
served: true
storage: true
{{- if (semverCompare ">=1.19-0" (substr 1 -1 .Capabilities.KubeVersion.GitVersion)) }}
schema:
openAPIV3Schema:
properties:
spec:
properties:
profile:
properties:
entries:
items:
properties:
comment:
type: string
days:
type: integer
domains:
items:
type: string
type: array
images:
items:
type: string
type: array
name:
type: string
required:
- name
type: object
type: array
required:
- entries
type: object
required:
- profile
type: object
type: object
{{- end }}
---
apiVersion: v1
kind: Service
metadata:
Expand Down
Loading

0 comments on commit 48f1bbd

Please sign in to comment.