Skip to content

Commit 153e419

Browse files
authored
Merge pull request #249 from osamamagdy/cleanup-helm-chart
fix: clean balancer
2 parents 91d467b + 2a269f8 commit 153e419

File tree

5 files changed

+120
-117
lines changed

5 files changed

+120
-117
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
# WARNING: File managed by eadf-bot, changes committed to individual repo will be overwritten
21
repos:
32
- repo: https://github.com/pre-commit/pre-commit-hooks
43
rev: v4.3.0
54
hooks:
65
- id: check-yaml
7-
exclude: ^helm/wrongsecrets-ctf-party/templates/
6+
exclude: ^(helm/wrongsecrets-ctf-party/templates/|helm/test.tmp.yaml)
7+
- id: check-yaml
8+
files: ^helm/test.tmp.yaml
9+
args:
10+
- --allow-multiple-documents
811
- id: end-of-file-fixer
912
exclude: ^(src/test/resources/yourkey.txt|src/test/resources/secondkey.txt)
1013
- id: trailing-whitespace

helm/package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "charts",
3+
"version": "v1.0.0",
4+
"description": "WrongSecrets helm chart",
5+
"main": "index.js",
6+
"scripts": {
7+
"build": "helm package ./wrongsecrets-ctf-party",
8+
"subcharts": "helm dependency update ./wrongsecrets-ctf-party",
9+
"lint": "helm lint ./wrongsecrets-ctf-party",
10+
"validate": "npm run lint && npm run test",
11+
"template": "helm template --debug -f ./test-values.yaml myrelease ./wrongsecrets-ctf-party -n myns > test.tmp.yaml",
12+
"dry-run": "helm install --dry-run -f ./test-values.yaml unknown ./wrongsecrets-ctf-party",
13+
"doc": "helm-docs -s file",
14+
"preversion": "git fetch --prune --prune-tags && npm run lint && npm run build",
15+
"version": " export version=v$(node -p -e 'require(`./package.json`).version') && export app_version=$(echo $version | cut -d. -f2-).0 && yq e -i '.version=strenv(version)' ./wrongsecrets-ctf-party/Chart.yaml && yq e -i '.appVersion=strenv(app_version)' ./wrongsecrets-ctf-party/Chart.yaml && git add . ",
16+
"postversion": "git push && git push --tags"
17+
},
18+
"repository": {
19+
"type": "git",
20+
"url": "[email protected]:OWASP/wrongsecrets-ctf-party.git"
21+
},
22+
"author": "WrongSecrets",
23+
"license": "Apache License 2.0",
24+
"homepage": "https://owasp.org/www-project-wrongsecrets/"
25+
}

helm/wrongsecrets-ctf-party/templates/wrongsecrets-balancer/deployment.yaml

Lines changed: 24 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -19,55 +19,35 @@ spec:
1919
app: wrongsecrets-balancer
2020
{{- include "wrongsecrets-ctf-party.selectorLabels" . | nindent 8 }}
2121
spec:
22-
securityContext:
23-
runAsUser: 1000
24-
runAsGroup: 3000
25-
fsGroup: 2000
26-
seccompProfile:
27-
type: RuntimeDefault
2822
serviceAccountName: wrongsecrets-balancer
23+
{{- with .Values.balancer.podSecurityContext }}
24+
securityContext:
25+
{{- omit . "enabled" | toYaml | nindent 8 }}
26+
{{- end }}
2927
containers:
3028
- name: {{ .Chart.Name }}
3129
image: '{{ .Values.balancer.repository }}:{{ .Values.balancer.tag | default (printf "v%s" .Chart.Version) }}'
3230
imagePullPolicy: {{ .Values.imagePullPolicy | quote }}
3331
ports:
3432
- name: http
35-
containerPort: 3000
33+
containerPort: {{ .Values.balancer.containerPort }}
34+
{{- if .Values.balancer.livenessProbe }}
3635
livenessProbe:
37-
httpGet:
38-
path: /balancer/
39-
port: http
36+
{{- toYaml .Values.balancer.livenessProbe | nindent 12 }}
37+
{{- end }}
38+
{{- if .Values.balancer.readinessProbe }}
4039
readinessProbe:
41-
httpGet:
42-
path: /balancer/
43-
port: http
40+
{{- toYaml .Values.balancer.readinessProbe | nindent 12 }}
41+
{{- end }}
4442
env:
45-
- name: REACT_APP_MOVING_GIF_LOGO
46-
value: {{ .Values.balancer.env.REACT_APP_MOVING_GIF_LOGO }}
47-
- name: REACT_APP_ACCESS_PASSWORD
48-
value: {{ .Values.balancer.env.REACT_APP_ACCESS_PASSWORD }}
49-
- name: REACT_APP_HEROKU_WRONGSECRETS_URL
50-
value: {{ .Values.balancer.env.REACT_APP_HEROKU_WRONGSECRETS_URL }}
51-
- name: REACT_APP_CTFD_URL
52-
value: {{ .Values.balancer.env.REACT_APP_CTFD_URL }}
53-
- name: REACT_APP_S3_BUCKET_URL
54-
value: {{ .Values.balancer.env.REACT_APP_S3_BUCKET_URL }}
55-
- name: K8S_ENV
56-
value: {{ .Values.balancer.env.K8S_ENV }}
57-
- name: IRSA_ROLE
58-
value: {{ .Values.balancer.env.IRSA_ROLE }} #REPLACE WITH THE ACTUAL AWS ROLE IF IN AWS MODE
43+
{{- range $k, $v := .Values.balancer.env}}
44+
- name: {{ $k }}
45+
value: {{ $v | quote }}
46+
{{- end }}
5947
- name: WRONGSECRETS_TAG
6048
value: {{ .Values.wrongsecrets.tag}}
6149
- name: WRONGSECRETS_DESKTOP_TAG
6250
value: {{ .Values.virtualdesktop.tag }}
63-
- name: REACT_APP_CREATE_TEAM_HMAC_KEY
64-
value: hardcodedkey
65-
- name: SECRETS_MANAGER_SECRET_ID_1
66-
value: {{ .Values.balancer.env.SECRETS_MANAGER_SECRET_ID_1 }}
67-
- name: SECRETS_MANAGER_SECRET_ID_2
68-
value: {{ .Values.balancer.env.SECRETS_MANAGER_SECRET_ID_2 }}
69-
- name: CHALLENGE33_VALUE
70-
value: {{ .Values.balancer.env.CHALLENGE33_VALUE }}
7151
- name: COOKIEPARSER_SECRET
7252
valueFrom:
7353
secretKeyRef:
@@ -90,27 +70,20 @@ spec:
9070
name: wrongsecrets-balancer-secret
9171
key: metricsBasicAuthPassword
9272
{{- end }}
73+
{{- with .Values.balancer.containerSecurityContext }}
9374
securityContext:
94-
allowPrivilegeEscalation: false
95-
readOnlyRootFilesystem: true
96-
runAsNonRoot: true
97-
capabilities:
98-
drop:
99-
- ALL
100-
add:
101-
- CAP_NET_ADMIN
102-
- CAP_NET_BIND_SERVICE
103-
seccompProfile:
104-
type: RuntimeDefault
75+
{{- omit . "enabled" | toYaml | nindent 12 }}
76+
{{- end }}
77+
{{- if .Values.balancer.volumeMounts }}
10578
volumeMounts:
106-
- name: config-volume
107-
mountPath: /home/app/config/
79+
{{- toYaml .Values.balancer.volumeMounts | nindent 12 }}
80+
{{- end }}
10881
resources:
10982
{{- toYaml .Values.balancer.resources | nindent 12 }}
83+
{{- if .Values.balancer.volumes }}
11084
volumes:
111-
- name: config-volume
112-
configMap:
113-
name: wrongsecrets-balancer-config
85+
{{- toYaml .Values.balancer.volumes | nindent 8 }}
86+
{{- end }}
11487
{{- with .Values.nodeSelector }}
11588
nodeSelector:
11689
{{- toYaml . | nindent 8 }}

helm/wrongsecrets-ctf-party/templates/wrongsecrets-balancer/service.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ metadata:
55
labels:
66
{{- include "wrongsecrets-ctf-party.labels" . | nindent 4 }}
77
spec:
8-
type: {{ .Values.balancer.service.type }}
98
{{- if (or (eq .Values.balancer.service.type "ClusterIP") (empty .Values.balancer.service.type)) }}
109
type: ClusterIP
1110
{{- if .Values.balancer.service.clusterIP }}

helm/wrongsecrets-ctf-party/values.yaml

Lines changed: 66 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,23 @@
22
# This is a YAML-formatted file.
33
# Declare variables to be passed into your templates.
44

5-
imagePullPolicy: Always
5+
imagePullPolicy: IfNotPresent
66
nodeSelector: {}
77

88
ingress:
9+
# -- If true, Wrongsecrets will create an Ingress object for the balancer service.
10+
# Useful if you want to expose the balancer service externally for example with a loadbalancer in order to view any webpages that are hosted on the balancer service.
911
enabled: false
12+
# -- Annotations to be added to the ingress object.
1013
annotations: {}
1114
# kubernetes.io/ingress.class: nginx
1215
# kubernetes.io/tls-acme: "true"
16+
# -- Hostnames to your Wrongsecrets balancer installation.
1317
hosts:
1418
- host: wrongsecrets-ctf-party.local
1519
paths:
1620
- "/"
21+
# -- TLS configuration for Wrongsecrets balancer
1722
tls: []
1823
# - secretName: chart-example-tls
1924
# hosts:
@@ -37,6 +42,8 @@ balancer:
3742
tag: 1.6.5aws
3843
# -- Number of replicas of the wrongsecrets-balancer deployment. Changing this in a commit? PLEASE UPDATE THE GITHUB WORKLFOWS THEN!(NUMBER OF "TRUE")
3944
replicas: 2
45+
# -- Port to expose on the balancer pods which the container listens on
46+
containerPort: 3000
4047
service:
4148
# -- Kubernetes service type
4249
type: ClusterIP
@@ -48,30 +55,30 @@ balancer:
4855
loadBalancerSourceRanges: null
4956
# -- IP address to assign to load balancer (if supported)
5057
externalIPs: null
58+
# -- Probes settings for the balancer pods
59+
# -- livenessProbe: Checks if the balancer pod is still alive
60+
livenessProbe:
61+
httpGet:
62+
path: /balancer/
63+
port: http # -- Port to expose on the balancer pods which the container listens on. It is named http to be the same as the containerPort
64+
# -- readinessProbe: Checks if the balancer pod is ready to receive traffic
65+
readinessProbe:
66+
httpGet:
67+
path: /balancer/
68+
port: http # -- Port to expose on the balancer pods which the container listens on. It is named http to be the same as the containerPort
69+
# -- Resource limits and requests for the balancer pods
5170
resources:
5271
requests:
5372
memory: 256Mi
5473
cpu: 400m
5574
limits:
5675
memory: 1024Mi
5776
cpu: 1000m
58-
securityContext:
59-
allowPrivilegeEscalation: false
60-
readOnlyRootFilesystem: true
61-
runAsNonRoot: true
62-
capabilities:
63-
drop:
64-
- ALL
65-
add:
66-
- CAP_NET_ADMIN
67-
- CAP_NET_BIND_SERVICE
68-
seccompProfile:
69-
type: RuntimeDefault
70-
# -- Optional Configure kubernetes scheduling affinity for the created JuiceShops (see: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity)
77+
# -- Optional Configure kubernetes scheduling affinity for the created wrongsecrets instances (see: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity)
7178
affinity: {}
72-
# -- Optional Configure kubernetes toleration for the created JuiceShops (see: https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/)
79+
# -- Optional Configure kubernetes toleration for the created wrongsecrets instances (see: https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/)
7380
tolerations: []
74-
# -- If set to true this skips setting ownerReferences on the teams JuiceShop Deployment and Services. This lets MultiJuicer run in older kubernetes cluster which don't support the reference type or the app/v1 deployment type
81+
# -- If set to true this skips setting ownerReferences on the teams wrongsecrets Deployment and Services. This lets MultiJuicer run in older kubernetes cluster which don't support the reference type or the app/v1 deployment type
7582
skipOwnerReference: false
7683
env:
7784
REACT_APP_MOVING_GIF_LOGO: "https://i.gifer.com/9kGQ.gif" #displayed at the frontend when you enter the CTF
@@ -98,11 +105,37 @@ balancer:
98105
username: prometheus-scraper
99106
# -- Should be changed when metrics are enabled.
100107
password: ERzCT4pwBDxfCKRGmfrMa8KQ8sXf8GKy
101-
102-
##TODO:
103-
#1. UPDATE WRONGSECRETS TO DEFINITION WHERE K8S IS USED FOR AWS!
104-
#2. UPDATE VIRTUALDESKTOP TO DEFINITION WHERE IT CN BE USED
105-
#3. ADD VAULT INSTANCE PER TEAM!
108+
podSecurityContext:
109+
# -- If true, sets the securityContext on the created pods. This is required for the podSecurityPolicy to work
110+
enabled: true
111+
runAsUser: 1000
112+
runAsGroup: 3000
113+
fsGroup: 2000
114+
seccompProfile:
115+
type: RuntimeDefault
116+
containerSecurityContext:
117+
# -- If true, sets the securityContext on the created containers. This is required for the podSecurityPolicy to work
118+
enabled: true
119+
allowPrivilegeEscalation: false
120+
readOnlyRootFilesystem: true
121+
runAsNonRoot: true
122+
capabilities:
123+
drop:
124+
- ALL
125+
add:
126+
- CAP_NET_ADMIN
127+
- CAP_NET_BIND_SERVICE
128+
seccompProfile:
129+
type: RuntimeDefault
130+
volumeMounts:
131+
# -- If true, creates a volumeMount for the created pods. This is required for the podSecurityPolicy to work
132+
- name: config-volume
133+
mountPath: /home/app/config/
134+
volumes:
135+
# -- If true, creates a volume for the created pods. This is required for the podSecurityPolicy to work
136+
- name: config-volume
137+
configMap:
138+
name: wrongsecrets-balancer-config
106139

107140
wrongsecrets:
108141
# -- Specifies how many Wrongsecrets instances should start at max. Set to -1 to remove the max Wrongsecrets instance cap
@@ -112,32 +145,22 @@ wrongsecrets:
112145
tag: 1.6.5-no-vault
113146
# -- Change the key when hosting a CTF event. This key gets used to generate the challenge flags. See: https://github.com/OWASP/wrongsecrets#ctf
114147
ctfKey: "[email protected]!9uR_K!NfkkTr"
115-
# -- Specify a custom Juice Shop config.yaml. See the JuiceShop Config Docs for more detail: https://pwning.owasp-juice.shop/part1/customization.html#yaml-configuration-file
148+
# -- Specify a custom Wrongsecrets config.yaml. See the Wrongsecrets Docs for any needed ENVs: https://github.com/OWASP/wrongsecrets
116149
# @default -- See values.yaml for full details
117150
config: |
118151
K8S_ENV: aws
119-
# application:
120-
# logo: https://raw.githubusercontent.com/iteratec/multi-juicer/main/images/multijuicer-icon-only-padding.png
121-
# favicon: https://raw.githubusercontent.com/iteratec/multi-juicer/main/wrongsecrets-balancer/ui/public/favicon.ico
122-
# showVersionNumber: false
123-
# showGitHubLinks: false
124-
# challenges:
125-
# showHints: true
126-
# hackingInstructor:
127-
# isEnabled: true
128-
# ctf:
129-
# showFlagsInNotifications: false
130-
# -- Specify a custom NODE_ENV for JuiceShop. If value is changed to something other than 'wrongsecrets-ctf-party' it's not possible to set a custom config via `juiceShop.config`.
152+
# "aws" is for using the cluster with eks and "k8s" is for using the cluster with miniKube which will enable specific challenges
153+
# -- Specify a custom NODE_ENV for Wrongsecrets. If value is changed to something other than 'wrongsecrets-ctf-party' it's not possible to set a custom config via `wrongsecrets-balancer-config`.
131154
nodeEnv: "wrongsecrets-ctf-party"
132-
# -- Optional resources definitions to set for each JuiceShop instance
155+
# -- Optional resources definitions to set for each Wrongsecrets instance
133156
resources:
134157
requests:
135158
cpu: 256Mi
136159
memory: 300Mi
137160
# limits:
138161
# cpu: 100m
139162
# memory: 200Mi
140-
# -- Optional securityContext definitions to set for each JuiceShop instance
163+
# -- Optional securityContext definitions to set for each Wrongsecrets instance
141164
securityContext:
142165
allowPrivilegeEscalation: false
143166
readOnlyRootFilesystem: true
@@ -147,7 +170,7 @@ wrongsecrets:
147170
- ALL
148171
seccompProfile:
149172
type: RuntimeDefault
150-
# -- Optional environment variables to set for each JuiceShop instance (see: https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/)
173+
# -- Optional environment variables to set for each Wrongsecrets instance (see: https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/)
151174
env:
152175
- name: K8S_ENV
153176
value: k8s
@@ -161,43 +184,23 @@ wrongsecrets:
161184
secretKeyRef:
162185
name: funnystuff
163186
key: funnier
164-
# env:
165-
# - name: FOO
166-
# valueFrom:
167-
# secretKeyRef:
168-
# key: FOO
169-
# name: secret-resource
170187
# -- Optional mount environment variables from configMaps or secrets (see: https://kubernetes.io/docs/tasks/inject-data-application/distribute-credentials-secure/#configure-all-key-value-pairs-in-a-secret-as-container-environment-variables)
171188
envFrom: []
172-
# -- Optional Volumes to set for each JuiceShop instance (see: https://kubernetes.io/docs/concepts/storage/volumes/)
189+
# -- Optional Volumes to set for each Wrongsecrets instance (see: https://kubernetes.io/docs/concepts/storage/volumes/)
173190
volumes: []
174-
# create config map with a custom logo via: kubectl create configmap custom-logo --from-file custom.png=your-logo.png
175-
# then switch out the logo parameter in the wrongsecrets config section above to the mounted filename.
176-
# volumes:
177-
# - name: logo
178-
# configMap:
179-
# name: custom-logo
180-
# -- Optional VolumeMounts to set for each JuiceShop instance (see: https://kubernetes.io/docs/concepts/storage/volumes/)
181-
volumeMounts: []
182-
# volumeMounts:
183-
# - name: logo
184-
# mountPath: /wrongsecrets/frontend/dist/frontend/assets/public/images/custom.png
185-
# subPath: custom.png
186-
# readOnly: true
187-
188-
# -- Optional Configure kubernetes scheduling affinity for the created JuiceShops (see: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity)
191+
# -- Optional Configure kubernetes scheduling affinity for the created Wrongsecrets instances (see: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity)
189192
affinity: {}
190-
# -- Optional Configure kubernetes toleration for the created JuiceShops (see: https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/)
193+
# -- Optional Configure kubernetes toleration for the created Wrongsecrets instances (see: https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/)
191194
tolerations: []
192195

193-
# -- Optional Can be used to configure the runtime class for the JuiceShop pods to add an additional layer of isolation to reduce the impact of potential container escapes. (see: https://kubernetes.io/docs/concepts/containers/runtime-class/)
196+
# -- Optional Can be used to configure the runtime class for the Wrongsecrets instances pods to add an additional layer of isolation to reduce the impact of potential container escapes. (see: https://kubernetes.io/docs/concepts/containers/runtime-class/)
194197
runtimeClassName: null
195198

196-
# Deletes unused JuiceShop instances after a configurable period of inactivity
199+
# Deletes unused Wrongsecrets instances after a configurable period of inactivity
197200

198201
#the virtual desktop for the deploymebt
199202
virtualdesktop:
200-
# -- Specifies how many JuiceShop instances MultiJuicer should start at max. Set to -1 to remove the max Juice Shop instance cap
203+
# -- Specifies how many Wrongsecrets instances MultiJuicer should start at max. Set to -1 to remove the max Juice Shop instance cap
201204
maxInstances: 500
202205
# -- Juice Shop Image to use
203206
image: jeroenwillemsen/wrongsecrets-desktop-k8s

0 commit comments

Comments
 (0)