Skip to content

Commit d260b9b

Browse files
authored
Merge pull request #89 from commjoen/helm-chart
Helm cleanup
2 parents 3412cec + 7a2f518 commit d260b9b

File tree

2,876 files changed

+132
-1020115
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,876 files changed

+132
-1020115
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
strategy:
3131
fail-fast: false
3232
matrix:
33-
language: [ 'go', 'javascript' ]
33+
language: [ 'javascript' ]
3434
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
3535
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
3636

.github/workflows/publish.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ jobs:
3030
strategy:
3131
matrix:
3232
component:
33-
- unusued-progress-watchdog
3433
- cleaner
3534
- wrongsecrets-balancer
3635
steps:

.github/workflows/test.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
on: [push, pull_request]
2+
permissions:
3+
contents: read
24
name: "Run Tests"
35
jobs:
46
cleaner:
@@ -46,14 +48,3 @@ jobs:
4648
run: |
4749
cd wrongsecrets-balancer
4850
npm test -- --ci --color --verbose
49-
#disabled as for now: we cannot use it yet
50-
# progressWatchdog:
51-
# name: ProgressWatchdog
52-
# runs-on: ubuntu-latest
53-
# steps:
54-
# - uses: actions/checkout@v3
55-
# - name: "Test ProgressWatchdog"
56-
# run: |
57-
# cd progress-watchdog
58-
# go vet
59-
# go test -cover

build-an-deploy.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,21 @@ echo "For example docker-desktop with its included k8s cluster"
77
echo "Usage: ./build-an-deploy.sh"
88

99
source ./scripts/check-available-commands.sh
10-
checkCommandsAvailable helm docker kubectl
10+
checkCommandsAvailable helm docker kubectl yq
1111

1212
version="$(uuidgen)"
13-
13+
WRONGSECRETS_IMAGE=$(cat helm/wrongsecrets-ctf-party/values.yaml| yq '.wrongsecrets.image')
14+
WRONGSECRETS_TAG=$(cat helm/wrongsecrets-ctf-party/values.yaml| yq '.wrongsecrets.tag')
15+
WEBTOP_IMAGE=$(cat helm/wrongsecrets-ctf-party/values.yaml| yq '.virtualdesktop.image')
16+
WEBTOP_TAG=$(cat helm/wrongsecrets-ctf-party/values.yaml| yq '.virtualdesktop.tag')
17+
echo "Pulling in required images to actually run $WRONGSECRETS_IMAGE:$WRONGSECRETS_TAG & $WEBTOP_IMAGE:$WEBTOP_TAG."
18+
echo "If you see an authentication failure: pull them manually by the following 2 commands"
19+
echo "'docker pull $WRONGSECRETS_IMAGE:$WRONGSECRETS_TAG'"
20+
echo "'docker pull jeroenwillemsen/jeroenwillemsen/$WEBTOP_IMAGE:$WEBTOP_TAG'" &
21+
docker pull $WRONGSECRETS_IMAGE:$WRONGSECRETS_TAG &
22+
docker pull jeroenwillemsen/jeroenwillemsen/$WEBTOP_IMAGE:$WEBTOP_TAG &
1423
docker build -t local/wrongsecrets-balancer:$version ./wrongsecrets-balancer &
1524
docker build -t local/cleaner:$version ./cleaner &
16-
1725
wait
1826

1927
helm upgrade --install mj ./helm/wrongsecrets-ctf-party --set="imagePullPolicy=Never" --set="balancer.repository=local/wrongsecrets-balancer" --set="balancer.tag=$version" --set="wrongsecretsCleanup.repository=local/cleaner" --set="wrongsecretsCleanup.tag=$version"

cleaner/src/main.js

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
const { KubeConfig, AppsV1Api, CoreV1Api } = require('@kubernetes/client-node');
1+
const { KubeConfig, AppsV1Api } = require('@kubernetes/client-node');
22

33
const { parseTimeDurationString, msToHumanReadable } = require('./time');
44

5-
const Namespace = process.env['NAMESPACE'];
6-
75
const kc = new KubeConfig();
86
kc.loadFromCluster();
97

108
const k8sAppsApi = kc.makeApiClient(AppsV1Api);
11-
const k8sCoreApi = kc.makeApiClient(CoreV1Api);
129

1310
const MaxInactiveDuration = process.env['MAX_INACTIVE_DURATION'];
1411
const MaxInactiveDurationInMs = parseTimeDurationString(MaxInactiveDuration);
@@ -36,7 +33,7 @@ async function main() {
3633
};
3734

3835
console.log(
39-
`Looking for WrongSecerets Instances which have been inactive for more than ${MaxInactiveDuration}.`
36+
`Looking for Instances & namespaces which have been inactive for more than ${MaxInactiveDuration}.`
4037
);
4138
const instances = await k8sAppsApi.listDeploymentForAllNamespaces(
4239
true,
@@ -51,7 +48,7 @@ async function main() {
5148
for (const instance of instances.body.items) {
5249
const instanceName = instance.metadata.name;
5350
const lastConnectTimestamps = parseInt(
54-
instance.metadata.annotations['wrongsecrets.owasp.dev/lastRequest'],
51+
instance.metadata.annotations['wrongsecrets-ctf-party/lastRequest'],
5552
10
5653
);
5754

@@ -60,33 +57,26 @@ async function main() {
6057
const currentTime = new Date().getTime();
6158

6259
const timeDifference = currentTime - lastConnectTimestamps;
63-
60+
var teamname = instance.metadata.labels.team;
6461
if (timeDifference > MaxInactiveDurationInMs) {
6562
console.log(
66-
`Deleting Instance: '${instanceName}'. Instance hasn't been used in ${msToHumanReadable(
63+
`Instance: '${instanceName}'. Instance hasn't been used in ${msToHumanReadable(
6764
timeDifference
6865
)}.`
6966
);
67+
console.log(`Instance belongs to namespace ${teamname}`);
7068
try {
71-
await k8sAppsApi.deleteNamespacedDeployment(instanceName, Namespace);
69+
console.log(`not yet implemented, but would be deleting namespace ${teamname} now`);
70+
// await k8sAppsApi.deleteNamespacedDeployment(instanceName, teamname);
7271
counts.successful.deployments++;
7372
} catch (error) {
7473
counts.failed.deployments++;
75-
console.error(
76-
`Failed to delete deployment: '${instanceName}' from namespace '${Namespace}'`
77-
);
74+
console.error(`Failed to delete namespace '${teamname}'`);
7875
console.error(error);
7976
}
80-
try {
81-
await k8sCoreApi.deleteNamespacedService(instanceName, Namespace);
82-
counts.successful.services++;
83-
} catch (error) {
84-
counts.failed.services++;
85-
console.error(`Failed to delete service: '${instanceName}' from namespace '${Namespace}'`);
86-
}
8777
} else {
8878
console.log(
89-
`Not deleting Instance: '${instanceName}'. Been last active ${msToHumanReadable(
79+
`Not deleting Instance: '${instanceName}' from '${teamname}'. Been last active ${msToHumanReadable(
9080
timeDifference
9181
)} ago.`
9282
);

guides/k8s/k8s.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Example Setup with kubernetes(k8s)
22

33
**WARNING:** It takes into account that you already have k8s cluster setup.
4+
**WARNING-2:** this document is not yet up to date, it will be fixed in [https://github.com/commjoen/wrongsecrets-ctf-party/issues/79](https://github.com/commjoen/wrongsecrets-ctf-party/issues/79).
5+
46

57
## Prerequisites
68

guides/production-notes/production-notes.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ To ensure MultiJuicer runs as smoothly during your CTF's / trainings / workshops
44

55
1. Set `.balancer.cookie.cookieParserSecret` to a random alpha-numeric value (recommended length 24 chars), this value is used to sign cookies. If you don't set this, each `helm upgrade` you run will generate a new one, which invalidates all user sessions, forcing users to rejoin their team.
66
2. As you are running this with https (right?), you should set `balancer.cookie.secure` to `true`. This marks the cookie used to associate a browser with a team to transmitted via https only.
7-
3. Make sure the value you have configured for `juiceShop.maxInstances` fits your CTF / training / whatever you are running. The default is set to only allow 10 instances. Set to -1 to remove any restrictions.
7+
3. Make sure the value you have configured for `wrongsecrets.maxInstances` & `virtualdesktop.maxInstances` fits your CTF / training / whatever you are running. The default is set to only allow 10 instances. Set to -1 to remove any restrictions.
88
4. Set `balancer.replicas` to at least 2, so that you have at least one fall back JuiceBalancer when one crashes or the node it lives on goes down.
99
5. When running a CTF with JuiceShop challenge flags, make sure to change `juiceShop.ctfKey` from the default. Otherwise users will be able to generate their own flags relatively easily. See
1010
6. When using prometheus metrics, e.g. when you have followed the [Monitoring SetUp Guide](https://github.com/iteratec/multi-juicer/blob/main/guides/monitoring-setup/monitoring.md) you'll want to change `balancer.metrics.basicAuth.password` to a non default values. Otherwise users can use the default value to access the technical metrics of the JuiceBalancer pods.
11+
7. If you host this CTF in a public domain, change the `balancer.env.REACT_APP_ACCESS_PASSWORD` to a password you communicate to your users at the start of teh CTF.
12+
8. Make sure to rotate the `balancer.env.REACT_APP_CREATE_TEAM_HMAC_KEY` HMAC key for anti-infra-creation-fuzzing as well into something else than 'hardcodedkey' when you see players generating 100s of instances in minutes.
1113

1214
## TLDR
1315

@@ -22,8 +24,12 @@ balancer:
2224
metrics:
2325
basicAuth:
2426
password: "ROTATE_THIS_YOU_LAZY_ASS"
27+
env:
28+
REACT_APP_ACCESS_PASSWORD: 'CHANGE_THIS_ASS_WELL'
29+
REACT_APP_CREATE_TEAM_HMAC_KEY: 'PLEASE_CHANGE_ME'
2530

2631
juiceShop:
2732
maxInstances: 42
2833
ctfKey: "DONT_LET_ME_FIND_YOU_USING_THIS_EXACT_VALUE"
2934
```
35+

helm/wrongsecrets-ctf-party/Chart.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v2
22
name: wrongsecrets-ctf-party
33
description: Run Multi User "Capture the Flags" or Security Trainings with OWASP Wrongsecrets
4-
icon: https://raw.githubusercontent.com/iteratec/multi-juicer/main/images/multijuicer-icon-only.png
4+
icon: https://github.com/commjoen/wrongsecrets/blob/master/icon.png?raw=true
55

66
home: https://github.com/
77
sources:
@@ -28,10 +28,10 @@ type: application
2828

2929
# This is the chart version. This version number should be incremented each time you make changes
3030
# to the chart and its templates, including the app version.
31-
version: 5.0.0-beta.0
31+
version: 0.1.0-alpha
3232

3333
# This is the version number of the application being deployed. This version number should be
3434
# incremented each time you make changes to the application.
35-
appVersion: 5.0.0-beta.0
35+
appVersion: 1.5.8
3636

3737
dependencies: []

helm/wrongsecrets-ctf-party/README.md.gotmpl

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
![MultiJuicer, Multi User Juice Shop Platform](https://raw.githubusercontent.com/iteratec/multi-juicer/main/images/multijuicer-cover.svg)
1+
![WrongSecrets CTF Party, to use WrongSecrets for CTF or online Education](https://raw.githubusercontent.com/commjoen/wrongsecrets/master/icon.png)
2+
_Powered by MultiJuicer_
23

3-
Running CTFs and Security Trainings with [OWASP Juice Shop](https://github.com/bkimminich/juice-shop) is usually quite tricky, Juice Shop just isn't intended to be used by multiple users at a time.
4-
Instructing everybody how to start Juice Shop on their own machine works ok, but takes away too much valuable time.
4+
Running CTFs and Security Trainings with [OWASP WrongSecrets](https://github.com/commjoen/wrongsecrets) is usually quite tricky, WrongSecrets can be used by multiple users at one time, but this can cause issues when people start fuzzing.
5+
Instructing everybody how to start WrongSecrets on their own machine works ok, but takes away too much valuable time.
6+
Next, installing the additional tools required to learn basics of reverse-engineering might take to much time as well.
57

6-
MultiJuicer gives you the ability to run separate Juice Shop instances for every participant on a central kubernetes cluster, to run events without the need for local Juice Shop instances.
8+
WrongSecrets CTF Party gives you the ability to run separate WrongSecrets instances for every participant on a central kubernetes cluster, to run events without the need for local WrongSecrets instances.
79

810
**What it does:**
911

10-
- dynamically create new Juice Shop instances when needed
11-
- runs on a single domain, comes with a LoadBalancer sending the traffic to the participants Juice Shop instance
12+
- dynamically create new WrongSecrets instance when needed
13+
- dynamically create new WrongSecret virtual desktop instances with all the addiontal tooling required to do the CTF/training when needed
14+
- runs on a single domain, comes with a LoadBalancer sending the traffic to the participants WrongSecrets instance
1215
- backup and auto apply challenge progress in case of Juice Shop container restarts
1316
- cleanup old & unused instances automatically
1417

18+
It follows the same architecture as MultiJuicer below:
1519
![MultiJuicer, High Level Architecture Diagram](https://raw.githubusercontent.com/iteratec/multi-juicer/main/high-level-architecture.svg)
1620

1721
## Configuration

helm/wrongsecrets-ctf-party/archived-templates/unusued-progress-watchdog/deployment.yaml

Lines changed: 0 additions & 49 deletions
This file was deleted.

helm/wrongsecrets-ctf-party/archived-templates/unusued-progress-watchdog/role.yaml

Lines changed: 0 additions & 11 deletions
This file was deleted.

helm/wrongsecrets-ctf-party/archived-templates/unusued-progress-watchdog/rolebinding.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

helm/wrongsecrets-ctf-party/archived-templates/unusued-progress-watchdog/service-account.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.

helm/wrongsecrets-ctf-party/archived-templates/unusued-progress-watchdog/service.yaml

Lines changed: 0 additions & 17 deletions
This file was deleted.

helm/wrongsecrets-ctf-party/templates/cleanup/role.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ rules:
1515
verbs: ['get', 'delete']
1616
- apiGroups: [''] # "" indicates the core API group
1717
resources: ['namespaces']
18-
verbs: ['get', 'delete']
18+
verbs: ['get', 'delete', 'list']
1919
{{- end }}

helm/wrongsecrets-ctf-party/templates/wrongsecrets-balancer/config-map.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ data:
2424
"enabled": true
2525
},
2626
{{- end }}
27-
"juiceShop": {
27+
"wrongsecrets": {
2828
"image": {{ .Values.wrongsecrets.image | quote }},
2929
"tag": {{ .Values.wrongsecrets.tag | quote }},
3030
"imagePullPolicy": {{ .Values.imagePullPolicy | quote }},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ spec:
6161
- name: WRONGSECRETS_TAG
6262
value: {{ .Values.wrongsecrets.tag}}
6363
- name: WRONGSECRETS_DESKTOP_TAG
64-
value: 1.5.7
64+
value: 1.5.8
6565
- name: REACT_APP_CREATE_TEAM_HMAC_KEY
6666
value: hardcodedkey
6767
- name: SECRETS_MANAGER_SECRET_ID_1

0 commit comments

Comments
 (0)