Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

Commit 917e6e8

Browse files
authored
Merge pull request #58 from secureCodeBox/custom-hook-service-account
Allow Hooks to use custom ServiceAccounts
2 parents 46efea1 + 6938017 commit 917e6e8

File tree

13 files changed

+144
-19
lines changed

13 files changed

+144
-19
lines changed

hooks/declarative-subsequent-scans/templates/declerative-subsequent-scans-hook.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ spec:
1616
{{- else }}
1717
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
1818
{{- end }}
19-
{{- end }}
19+
{{- end }}
20+
serviceAccountName: declarative-combined-scans
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: RoleBinding
3+
metadata:
4+
annotations:
5+
description: DeclarativeCombinedScansHooks needs to have the rights to create new scans and the usual patch rules to update the scan status
6+
name: declarative-combined-scans
7+
namespace: {{ .Release.Namespace }}
8+
roleRef:
9+
apiGroup: rbac.authorization.k8s.io
10+
kind: Role
11+
name: declarative-combined-scans
12+
subjects:
13+
- kind: ServiceAccount
14+
name: declarative-combined-scans
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: Role
3+
metadata:
4+
annotations:
5+
description: DeclarativeCombinedScansHooks needs to have the rights to create new scans and the usual patch rules to update the scan status
6+
name: declarative-combined-scans
7+
namespace: {{ .Release.Namespace }}
8+
rules:
9+
- apiGroups:
10+
- execution.experimental.securecodebox.io
11+
resources:
12+
- scans
13+
verbs:
14+
- get
15+
- create
16+
- apiGroups:
17+
- execution.experimental.securecodebox.io
18+
resources:
19+
- scans/status
20+
verbs:
21+
- get
22+
- patch
23+
- apiGroups:
24+
- cascading.experimental.securecodebox.io
25+
resources:
26+
- cascadingrules
27+
verbs:
28+
- get
29+
- list
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
annotations:
5+
description: DeclarativeCombinedScansHooks needs to have the rights to create new scans and the usual patch rules to update the scan status
6+
name: declarative-combined-scans
7+
namespace: {{ .Release.Namespace }}

hooks/imperative-subsequent-scans/templates/imperative-subsequent-scans-hook.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ spec:
1717
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
1818
{{- end }}
1919
{{- end }}
20+
serviceAccountName: imperative-combined-scans
2021
env:
2122
- name: CASCADE_AMASS_NMAP
2223
value: {{ .Values.cascade.amassNmap | quote }}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: RoleBinding
3+
metadata:
4+
annotations:
5+
description: ImperativeCombinedScansHook needs to have the rights to create new scans and the usual patch rules to update the scan status
6+
name: imperative-combined-scans
7+
namespace: {{ .Release.Namespace }}
8+
roleRef:
9+
apiGroup: rbac.authorization.k8s.io
10+
kind: Role
11+
name: imperative-combined-scans
12+
subjects:
13+
- kind: ServiceAccount
14+
name: imperative-combined-scans
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: Role
3+
metadata:
4+
annotations:
5+
description: ImperativeCombinedScansHook needs to have the rights to create new scans and the usual patch rules to update the scan status
6+
name: imperative-combined-scans
7+
namespace: {{ .Release.Namespace }}
8+
rules:
9+
- apiGroups:
10+
- execution.experimental.securecodebox.io
11+
resources:
12+
- scans
13+
verbs:
14+
- get
15+
- list
16+
- create
17+
- apiGroups:
18+
- execution.experimental.securecodebox.io
19+
resources:
20+
- scans/status
21+
verbs:
22+
- get
23+
- patch
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
annotations:
5+
description: ImperativeCombinedScansHook needs to have the rights to create new scans and the usual patch rules to update the scan status
6+
name: imperative-combined-scans
7+
namespace: {{ .Release.Namespace }}

operator/apis/execution/v1/scancompletionhook.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ type ScanCompletionHookSpec struct {
4444
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
4545
Env []corev1.EnvVar `json:"env,omitempty"`
4646
Type HookType `json:"type"`
47+
// ServiceAccountName Name of the serviceAccount Name used. Should only be used if your hook needs specifc RBAC Access. Otherwise the hook is run using a "scan-completion-hook" service account. The service account should have at least "get" rights on scans.execution.experimental.securecodebox.io, and "get" & "patch" scans.execution.experimental.securecodebox.io/status
48+
ServiceAccountName *string `json:"serviceAccountName,omitempty"`
4749
}
4850

4951
// ScanCompletionHookStatus defines the observed state of ScanCompletionHook

operator/apis/execution/v1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)