Skip to content

WIP for porting #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 43 commits into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
faea1a3
working on porting multijuicer part 1 as of https://github.com/commjo…
commjoen Sep 4, 2022
4abe650
WIP at rebuilding everyting: does not work ATM
commjoen Sep 8, 2022
44d9188
wip for changing:
commjoen Sep 8, 2022
abbcd33
First attempt in setting things up
commjoen Sep 8, 2022
a6149bc
now can run just wrongsecrets for a given team in default namespace
commjoen Sep 8, 2022
14a094c
Added deployment of webdesktop, but cannot proxy to it yet
commjoen Sep 8, 2022
7486c42
fixed most of the routing
commjoen Sep 9, 2022
7348a5e
mall steps
commjoen Sep 9, 2022
2e706d6
Adds http-proxy-mioddleware and uses that to proxy to guacamole
mikewoudenberg Sep 9, 2022
127f92d
quickfix so that both ssystems work again
commjoen Sep 9, 2022
136e827
comment out not required code
commjoen Sep 9, 2022
7acbb19
First ui adoption
commjoen Sep 10, 2022
b8dc565
Fixed some of the linting and testing issues
commjoen Sep 10, 2022
7c69fb2
removed unused
commjoen Sep 10, 2022
ba4d565
removed unused component
commjoen Sep 10, 2022
35250d7
fix linting
commjoen Sep 10, 2022
21f7562
last lint fix
commjoen Sep 10, 2022
717a0f1
Small cleanups and updates (now have a desktop resstart buton for admins
commjoen Sep 11, 2022
8b06f55
Fixed some tests, add better debugging
commjoen Sep 12, 2022
a4c188f
Fixed tests
commjoen Sep 12, 2022
4f0589c
Fixed hardening wrongsecrets deployment
commjoen Sep 12, 2022
ce6f1ca
fix security contexts for webdesktop
commjoen Sep 12, 2022
8328a15
updated aws LB yaml
commjoen Sep 12, 2022
9c65de1
few more fixes
commjoen Sep 12, 2022
977deef
wip
commjoen Sep 12, 2022
1a37df9
first attempt for namespacing
commjoen Sep 13, 2022
e08526b
namespacing works, now need ot check for deployment
commjoen Sep 13, 2022
584288b
small fixes
commjoen Sep 13, 2022
caa80d1
small cleanups and trying to get the dpeloyments run
commjoen Sep 13, 2022
477c4ea
deployments fixed as our owner now is cross-namespace / clsuter wide
commjoen Sep 13, 2022
2d5874c
fixed the proxying osmehwat at least
commjoen Sep 13, 2022
8b00ec2
Added namespacing support, admin updates, now all are isolated a bit …
commjoen Sep 13, 2022
e55b370
Merge pull request #2 from commjoen/namespacing
commjoen Sep 13, 2022
6f1e2a7
Migrate cleaner to use all namespaces
commjoen Sep 13, 2022
d75c9a0
Fixes for the cleaner for now
commjoen Sep 13, 2022
33b7715
cleanup of wrong formatting{
commjoen Sep 13, 2022
8215d78
Added env var rendering for customization of the CTF
commjoen Sep 14, 2022
d5bdf42
first setup for k8s
commjoen Sep 14, 2022
2f339ed
wip
commjoen Sep 14, 2022
1ae9eb9
added k8s supporting files
commjoen Sep 14, 2022
02026a0
fix test
commjoen Sep 14, 2022
e749787
fix tet2
commjoen Sep 14, 2022
98d8081
Merge pull request #3: Added K8s deployment support.
commjoen Sep 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
run: |
sudo snap install yq
- name: "Patch Chart.yaml to the current released version"
working-directory: helm/multi-juicer/
working-directory: helm/wrongsecrets-ctf-party/
run: |
RELEASE_VERSION="${GITHUB_REF#refs/*/}"
# Remove leading 'v' from git tag to create valid semver
Expand All @@ -30,9 +30,9 @@ jobs:
strategy:
matrix:
component:
- progress-watchdog
- unusued-progress-watchdog
- cleaner
- juice-balancer
- wrongsecrets-balancer
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
29 changes: 15 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,29 @@ jobs:
- uses: actions/checkout@master
- name: "Install & Build BalancerUI"
run: |
cd juice-balancer/ui
cd wrongsecrets-balancer/ui
npm ci
npm run build
- name: Install Balancer
run: |
cd juice-balancer
cd wrongsecrets-balancer
npm ci
- name: Run Linter
run: |
cd juice-balancer
cd wrongsecrets-balancer
npm run lint
- name: Test Balancer
run: |
cd juice-balancer
cd wrongsecrets-balancer
npm test -- --ci --color --verbose
progressWatchdog:
name: ProgressWatchdog
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: "Test ProgressWatchdog"
run: |
cd progress-watchdog
go vet
go test -cover
#disabled as for now: we cannot use it yet
# progressWatchdog:
# name: ProgressWatchdog
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@master
# - name: "Test ProgressWatchdog"
# run: |
# cd progress-watchdog
# go vet
# go test -cover
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/aws.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/azure/azureSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/wrongsecrets-ctf-party.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions ATTRIBUTION
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Original Attirbution file of Multijuicer from which we Forked:

MultiJuicer uses multiple Icons / Emojis from OpenMoji: https://openmoji.org/

The Logo was originally created by [Straight outta Mane](https://en.99designs.de/profiles/2794862) via [99Desgins](https://en.99designs.de/logo-brand-guide/contests/create-juicy-logo-open-source-project-multijuicer-1075365/entries).
10 changes: 6 additions & 4 deletions build-an-deploy.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#!/usr/bin/env bash

echo "This Script canbe used to 'easily' build all MultiJuicer Components and install them to a local kubernetes cluster"
echo "This Script can be used to 'easily' build all WrongSecrets CTF party Components and install them to a local kubernetes cluster"
echo "For this to work the local kubernetes cluster must have access to the same local registry / image cache which 'docker build ...' writes its image to"
echo "For example docker-desktop with its included k8s cluster"

echo "Usage: ./build-and-deploy.sh"

version="$(uuidgen)"

docker build -t local/juice-balancer:$version ./juice-balancer &
docker build -t local/wrongsecrets-balancer:$version ./wrongsecrets-balancer &
docker build -t local/cleaner:$version ./cleaner &
docker build -t local/progress-watchdog:$version ./progress-watchdog &
#docker build -t local/unusued-progress-watchdog:$version ./unusued-progress-watchdog &

wait

helm upgrade --install mj ./helm/multi-juicer --set="imagePullPolicy=Never" --set="balancer.repository=local/juice-balancer" --set="balancer.tag=$version" --set="progressWatchdog.repository=local/progress-watchdog" --set="progressWatchdog.tag=$version" --set="juiceShopCleanup.repository=local/cleaner" --set="juiceShopCleanup.tag=$version"
#helm upgrade --install mj ./helm/wrongsecrets-ctf-party --set="imagePullPolicy=Never" --set="balancer.repository=local/wrongsecrets-balancer" --set="balancer.tag=$version" --set="progressWatchdog.repository=local/unusued-progress-watchdog" --set="progressWatchdog.tag=$version" --set="wrongsecretsCleanup.repository=local/cleaner" --set="wrongsecretsCleanup.tag=$version"
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"
#helm upgrade --install mj ./helm/wrongsecrets-ctf-party --set="imagePullPolicy=Always" --set="balancer.repository=jeroenwillemsen/wrongsecrets-balancer" --set="balancer.tag=0.1" --set="wrongsecretsCleanup.repository=jeroenwillemsen/wrongsecrets-ctf-cleaner" --set="wrongsecretsCleanup.tag=0.1"
8 changes: 4 additions & 4 deletions cleaner/cleaner-cover.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion cleaner/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cleaner",
"version": "1.0.0",
"description": "k8s ChronJob for cleaning up unused Juice Shop instances.",
"description": "k8s ChronJob for cleaning up unused WrongSecrets instances.",
"main": "src/main.js",
"scripts": {
"test": "jest",
Expand Down
4 changes: 4 additions & 0 deletions cleaner/readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#WrongSecrets CTF Cleaner

This is a port from the Multijuice Cleaner. Original readme:

![Cleaner Cover](./cleaner-cover.svg)

Cleaner is a sub component of MultiJuicer, a kubernetes Jobs which is responsible for cleaning up Juice Shop instances which haven't been used for some time.
13 changes: 6 additions & 7 deletions cleaner/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,22 @@ async function main() {
};

console.log(
`Looking for Juice Shop Instances which have been inactive for more than ${MaxInactiveDuration}.`
`Looking for WrongSecerets Instances which have been inactive for more than ${MaxInactiveDuration}.`
);
const instances = await k8sAppsApi.listNamespacedDeployment(
Namespace,
const instances = await k8sAppsApi.listDeploymentForAllNamespaces(
true,
undefined,
undefined,
undefined,
'app=juice-shop'
'app in (wrongsecrets, virtualdesktop)',
200
);

console.log(`Found ${instances.body.items.length} instances. Checking their activity.`);

for (const instance of instances.body.items) {
const instanceName = instance.metadata.name;
const lastConnectTimestamps = parseInt(
instance.metadata.annotations['multi-juicer.iteratec.dev/lastRequest'],
instance.metadata.annotations['wrongsecrets.owasp.dev/lastRequest'],
10
);

Expand Down Expand Up @@ -99,7 +98,7 @@ async function main() {

main()
.then((counts) => {
console.log('Finished Juice Shop Instance Cleanup');
console.log('Finished WrongSecrets Instance Cleanup');
console.log('');
console.log('Successful deletions:');
console.log(` Deployments: ${counts.successful.deployments}`);
Expand Down
32 changes: 16 additions & 16 deletions guides/aws/aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This example expects you to have the following cli tools setup.
# First we'll need a cluster, you can create one using the eksctl cli.
# This will take a couple of minutes
eksctl create cluster \
--name multi-juicer \
--name wrongsecrets-ctf-party \
--version 1.21 \
--nodegroup-name standard-workers \
--node-type t3.medium \
Expand All @@ -25,22 +25,22 @@ eksctl create cluster \
--node-ami auto

# After completion verify that your kubectl context has been updated:
# Should print something like: Administrator@multi-juicer.eu-central-1.eksctl.io
# Should print something like: Administrator@wrongsecrets-ctf-party.eu-central-1.eksctl.io
kubectl config current-context
```

## Step 2. Installing MultiJuicer via helm

```sh
# You'll need to add the multi-juicer helm repo to your helm repos
helm repo add multi-juicer https://iteratec.github.io/multi-juicer/
# You'll need to add the wrongsecrets-ctf-party helm repo to your helm repos
helm repo add wrongsecrets-ctf-party https://iteratec.github.io/multi-juicer/

helm install multi-juicer multi-juicer/multi-juicer
helm install wrongsecrets-ctf-party wrongsecrets-ctf-party/wrongsecrets-ctf-party

# kubernetes will now spin up the pods
# to verify every thing is starting up, run:
kubectl get pods
# This should show you two pods a juice-balancer pod and a progress-watchdog pod
# This should show you two pods a wrongsecrets-balancer pod and a unusued-progress-watchdog pod
# Wait until both pods are ready
```

Expand All @@ -51,7 +51,7 @@ This step is optional, but helpful to catch errors quicker.
```sh
# lets test out if the app is working correctly before proceeding
# for that we can port forward the JuiceBalancer service to your local machine
kubectl port-forward service/juice-balancer 3000:3000
kubectl port-forward service/wrongsecrets-balancer 3000:3000

# Open up your browser for localhost:3000
# You should be able to see the MultiJuicer Balancer UI
Expand All @@ -64,15 +64,15 @@ kubectl port-forward service/juice-balancer 3000:3000
# Go back to localhost:3000/balancer
# To log in as the admin log in as the team "admin"
# The password for the team gets autogenerated if not specified, you can extract it from the kubernetes secret:
kubectl get secrets juice-balancer-secret -o=jsonpath='{.data.adminPassword}' | base64 --decode
kubectl get secrets wrongsecrets-balancer-secret -o=jsonpath='{.data.adminPassword}' | base64 --decode
```

## Step 4. Add Ingress to expose the app to the world

Create a loadbalancer which is exposed is achieved by running the following command:

```sh
kubectl create -f https://raw.githubusercontent.com/iteratec/multi-juicer/main/guides/aws/loadbalancer.yaml
kubectl create -f https://raw.githubusercontent.com/commjoen/wrongsecrets-ctf-party/firstport-activities/guides/aws/loadbalancer.yaml
```

You can get the LoadBalancer's DNS record either from the AWS console, or by running:
Expand All @@ -81,9 +81,9 @@ You can get the LoadBalancer's DNS record either from the AWS console, or by run
kubectl get services

# NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
# juice-balancer ClusterIP 10.100.29.23 <none> 3000/TCP 3m14s
# wrongsecrets-balancer ClusterIP 10.100.29.23 <none> 3000/TCP 3m14s
# kubernetes ClusterIP 10.100.0.1 <none> 443/TCP 11h
# multi-juicer-service-loadbalancer LoadBalancer 10.100.134.210 YOUR_DNS_RECORD_WILL_BE_HERE.eu-north-1.elb.amazonaws.com 80:32111/TCP 3m13s
# wrongsecrets-ctf-party-service-loadbalancer LoadBalancer 10.100.134.210 YOUR_DNS_RECORD_WILL_BE_HERE.eu-north-1.elb.amazonaws.com 80:32111/TCP 3m13s
```

Use `kubectl get pods`to see the pods you have successfully running, which should be similar to
Expand All @@ -92,8 +92,8 @@ Use `kubectl get pods`to see the pods you have successfully running, which shoul
kubectl get pods
# NAME READY STATUS RESTARTS AGE
# cleanup-job-ID-ID 0/1 Completed 0 48m
# juice-balancer-ID-ID 1/1 Running 0 80m
# progress-watchdog-ID-ID 1/1 Running 0 80m
# wrongsecrets-balancer-ID-ID 1/1 Running 0 80m
# unusued-progress-watchdog-ID-ID 1/1 Running 0 80m


kubectl get pods -n kube-system
Expand All @@ -110,11 +110,11 @@ kubectl get pods -n kube-system
## Step 5. Deinstallation

```sh
helm delete multi-juicer
helm delete wrongsecrets-ctf-party

# Delete the loadbalancer setup
kubectl delete -f kubectl create -f https://raw.githubusercontent.com/iteratec/multi-juicer/main/guides/aws/loadbalancer.yaml
kubectl delete -f kubectl create -f https://raw.githubusercontent.com/commjoen/wrongsecrets-ctf-party/firstport-activities/guides/aws/loadbalancer.yaml

# Delete the kubernetes cluster
eksctl delete cluster multi-juicer
eksctl delete cluster wrongsecrets-ctf-party
```
6 changes: 3 additions & 3 deletions guides/aws/loadbalancer.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: multi-juicer-service-loadbalancer
name: wrongsecrets-balancer-public
spec:
type: LoadBalancer
selector:
app.kubernetes.io/name: multi-juicer
app.kubernetes.io/instance: multi-juicer
app.kubernetes.io/name: wrongsecrets-ctf-party
app.kubernetes.io/instance: wrongsecrets-ctf-party
ports:
- protocol: TCP
port: 80
Expand Down
Loading