security(Apps): Improve Snyk hardening advisory (#1208)
* Harden postgresql by removing the migration initcontainer * Harden initcontainers * Harden serviceaccounts and RBAC * hmm * fix
This commit is contained in:
@@ -22,4 +22,4 @@ name: common-test
|
|||||||
sources:
|
sources:
|
||||||
- https://github.com/truecharts/apps/tree/master/charts/library/common-test
|
- https://github.com/truecharts/apps/tree/master/charts/library/common-test
|
||||||
type: application
|
type: application
|
||||||
version: 3.2.0
|
version: 3.3.0
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
image:
|
||||||
|
repository: traefik/whoami
|
||||||
|
pullPolicy: IfNotPresent
|
||||||
|
tag: v1.6.1@sha256:2c52bb2c848038a33e40415c300b655d7976bafaf033ecf4a6679cb9e1715917
|
||||||
|
|
||||||
|
service:
|
||||||
|
main:
|
||||||
|
ports:
|
||||||
|
main:
|
||||||
|
port: 8080
|
||||||
|
|
||||||
|
args:
|
||||||
|
- --port
|
||||||
|
- '8080'
|
||||||
|
|
||||||
|
rbac:
|
||||||
|
enabled: true
|
||||||
|
rules:
|
||||||
|
- apiGroups:
|
||||||
|
- ""
|
||||||
|
resources:
|
||||||
|
- services
|
||||||
|
- endpoints
|
||||||
|
- secrets
|
||||||
|
verbs:
|
||||||
|
- get
|
||||||
|
- list
|
||||||
|
- watch
|
||||||
|
- apiGroups:
|
||||||
|
- extensions
|
||||||
|
- networking.k8s.io
|
||||||
|
resources:
|
||||||
|
- ingresses
|
||||||
|
- ingressclasses
|
||||||
|
verbs:
|
||||||
|
- get
|
||||||
|
- list
|
||||||
|
- watch
|
||||||
|
- apiGroups:
|
||||||
|
- extensions
|
||||||
|
- networking.k8s.io
|
||||||
|
resources:
|
||||||
|
- ingresses/status
|
||||||
|
verbs:
|
||||||
|
- update
|
||||||
|
- apiGroups:
|
||||||
|
- traefik.containo.us
|
||||||
|
resources:
|
||||||
|
- ingressroutes
|
||||||
|
- ingressroutetcps
|
||||||
|
- ingressrouteudps
|
||||||
|
- middlewares
|
||||||
|
- middlewaretcps
|
||||||
|
- tlsoptions
|
||||||
|
- tlsstores
|
||||||
|
- traefikservices
|
||||||
|
- serverstransports
|
||||||
|
verbs:
|
||||||
|
- get
|
||||||
|
- list
|
||||||
|
- watch
|
||||||
|
|
||||||
|
serviceAccount:
|
||||||
|
create: true
|
||||||
@@ -25,9 +25,7 @@ Secondary entrypoint and primary loader for the common chart
|
|||||||
{{- /* Build the templates */ -}}
|
{{- /* Build the templates */ -}}
|
||||||
{{- include "common.pvc" . }}
|
{{- include "common.pvc" . }}
|
||||||
|
|
||||||
{{- if .Values.serviceAccount.create -}}
|
|
||||||
{{- include "common.serviceAccount" . }}
|
{{- include "common.serviceAccount" . }}
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
{{- if .Values.controller.enabled }}
|
{{- if .Values.controller.enabled }}
|
||||||
{{- if eq .Values.controller.type "deployment" }}
|
{{- if eq .Values.controller.type "deployment" }}
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ roleRef:
|
|||||||
kind: ClusterRole
|
kind: ClusterRole
|
||||||
name: {{ include "common.names.fullname" . }}
|
name: {{ include "common.names.fullname" . }}
|
||||||
subjects:
|
subjects:
|
||||||
{{- if .Values.serviceAccount }}
|
|
||||||
- kind: ServiceAccount
|
- kind: ServiceAccount
|
||||||
name: {{ include "common.names.serviceAccountName" . }}
|
name: {{ include "common.names.serviceAccountName" . }}
|
||||||
namespace: {{ .Release.Namespace }}
|
namespace: {{ .Release.Namespace }}
|
||||||
@@ -50,5 +49,4 @@ subjects:
|
|||||||
{{- with .Values.rbac.subjects }}
|
{{- with .Values.rbac.subjects }}
|
||||||
{{- toYaml . | nindent 2 }}
|
{{- toYaml . | nindent 2 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|||||||
@@ -2,11 +2,12 @@
|
|||||||
The ServiceAccount object to be created.
|
The ServiceAccount object to be created.
|
||||||
*/}}
|
*/}}
|
||||||
{{- define "common.serviceAccount" }}
|
{{- define "common.serviceAccount" }}
|
||||||
|
{{- if .Values.serviceAccount.create }}
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: ServiceAccount
|
kind: ServiceAccount
|
||||||
metadata:
|
metadata:
|
||||||
name: {{ include "common.names.serviceAccountName" . }}
|
name: {{ default (include "common.names.fullname" .) .Values.serviceAccount.name }}
|
||||||
labels:
|
labels:
|
||||||
{{- include "common.labels" . | nindent 4 }}
|
{{- include "common.labels" . | nindent 4 }}
|
||||||
{{- with .Values.serviceAccount.annotations }}
|
{{- with .Values.serviceAccount.annotations }}
|
||||||
@@ -14,3 +15,4 @@ metadata:
|
|||||||
{{- toYaml . | nindent 4 }}
|
{{- toYaml . | nindent 4 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|||||||
@@ -15,10 +15,15 @@ before chart installation.
|
|||||||
image: {{ .Values.alpineImage.repository }}:{{ .Values.alpineImage.tag }}
|
image: {{ .Values.alpineImage.repository }}:{{ .Values.alpineImage.tag }}
|
||||||
securityContext:
|
securityContext:
|
||||||
runAsUser: 0
|
runAsUser: 0
|
||||||
runAsGroup: 0
|
privileged: false
|
||||||
privileged: true
|
allowPrivilegeEscalation: false
|
||||||
allowPrivilegeEscalation: true
|
capabilities:
|
||||||
runAsNonRoot: false
|
drop:
|
||||||
|
- ALL
|
||||||
|
resources:
|
||||||
|
{{- with .Values.resources }}
|
||||||
|
{{- toYaml . | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
command:
|
command:
|
||||||
- "/bin/sh"
|
- "/bin/sh"
|
||||||
- "-c"
|
- "-c"
|
||||||
|
|||||||
@@ -6,6 +6,14 @@ This template ensures pods with postgresql dependency have a delayed start
|
|||||||
{{- if .Values.postgresql.enabled }}
|
{{- if .Values.postgresql.enabled }}
|
||||||
- name: postgresql-init
|
- name: postgresql-init
|
||||||
image: "{{ .Values.postgresqlImage.repository}}:{{ .Values.postgresqlImage.tag }}"
|
image: "{{ .Values.postgresqlImage.repository}}:{{ .Values.postgresqlImage.tag }}"
|
||||||
|
securityContext:
|
||||||
|
capabilities:
|
||||||
|
drop:
|
||||||
|
- ALL
|
||||||
|
resources:
|
||||||
|
{{- with .Values.resources }}
|
||||||
|
{{- toYaml . | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
command:
|
command:
|
||||||
- "sh"
|
- "sh"
|
||||||
- "-c"
|
- "-c"
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ name: postgresql
|
|||||||
sources:
|
sources:
|
||||||
- https://www.postgresql.org/
|
- https://www.postgresql.org/
|
||||||
type: application
|
type: application
|
||||||
version: 3.0.22
|
version: 4.0.0
|
||||||
annotations:
|
annotations:
|
||||||
truecharts.org/catagories: |
|
truecharts.org/catagories: |
|
||||||
- database
|
- database
|
||||||
|
|||||||
@@ -16,30 +16,6 @@ service:
|
|||||||
## TODO: Fix the backup-on-upgrade system
|
## TODO: Fix the backup-on-upgrade system
|
||||||
enableUpgradeBackup: false
|
enableUpgradeBackup: false
|
||||||
|
|
||||||
initContainers:
|
|
||||||
migrate-db:
|
|
||||||
image: "{{ .Values.alpineImage.repository}}:{{ .Values.alpineImage.tag }}"
|
|
||||||
securityContext:
|
|
||||||
runAsUser: 0
|
|
||||||
privileged: true
|
|
||||||
|
|
||||||
runAsNonRoot: false
|
|
||||||
command:
|
|
||||||
- /bin/sh
|
|
||||||
- -cx
|
|
||||||
- |
|
|
||||||
echo 'trying to migrate old db to new location...'
|
|
||||||
mkdir -p /bitnami/postgresql/data
|
|
||||||
mv -f /bitnami/postgresql/old/* /bitnami/postgresql/data/ || true
|
|
||||||
chown -R {{ .Values.podSecurityContext.runAsUser }}:{{ .Values.podSecurityContext.fsGroup }} /bitnami/postgresql/data
|
|
||||||
chmod 775 /bitnami/postgresql/data
|
|
||||||
imagePullPolicy: IfNotPresent
|
|
||||||
volumeMounts:
|
|
||||||
- name: db
|
|
||||||
mountPath: /bitnami/postgresql/old
|
|
||||||
- name: data
|
|
||||||
mountPath: /bitnami/postgresql
|
|
||||||
|
|
||||||
podSecurityContext:
|
podSecurityContext:
|
||||||
runAsGroup: 0
|
runAsGroup: 0
|
||||||
|
|
||||||
|
|||||||
@@ -262,10 +262,7 @@ rbac:
|
|||||||
|
|
||||||
# -- The service account the pods will use to interact with the Kubernetes API
|
# -- The service account the pods will use to interact with the Kubernetes API
|
||||||
serviceAccount:
|
serviceAccount:
|
||||||
enabled: true
|
create: true
|
||||||
# If set, an existing service account is used
|
|
||||||
# If not set, a service account is created automatically using the fullname template
|
|
||||||
name: ""
|
|
||||||
|
|
||||||
# -- SCALE Middleware Handlers
|
# -- SCALE Middleware Handlers
|
||||||
middlewares:
|
middlewares:
|
||||||
|
|||||||
Reference in New Issue
Block a user