Skip to content

Commit

Permalink
Merge pull request #76 from pomo-mondreganto/ctfcup-2022
Browse files Browse the repository at this point in the history
Working & tested version, regular maintenance
  • Loading branch information
pomo-mondreganto authored Dec 10, 2022
2 parents c5341a0 + 9bd5d23 commit 3801774
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
release:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down
56 changes: 6 additions & 50 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- BLITZ
- CLASSIC

runs-on: "ubuntu-20.04"
runs-on: "ubuntu-22.04"
timeout-minutes: 15
env:
TEST: 1
Expand Down Expand Up @@ -64,8 +64,8 @@ jobs:
export $(find ./docker_config -name "*.env" -exec egrep -v '^#' {} \; | xargs)
./control.py start
docker ps
docker-compose ps
docker-compose logs -f initializer
docker compose ps
docker compose logs -f initializer
python tests/wait_for_start.py
./control.py rd ps
env | sort
Expand All @@ -76,7 +76,7 @@ jobs:
run: ./control.py rd logs --tail 2000

backend_linter:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -96,7 +96,7 @@ jobs:
flake8: true

frontend_linter:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -124,52 +124,8 @@ jobs:
working-directory: front
run: yarn build

test_kube:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup python
uses: actions/setup-python@v2
with:
python-version: "3.9"

- name: Install skaffold
run: |
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/v1.19.0/skaffold-linux-amd64
chmod +x skaffold
sudo mv skaffold /usr/local/bin
- name: Setup Minikube
uses: manusa/[email protected]
with:
minikube version: "v1.17.1"
kubernetes version: "v1.19.3"
github token: ${{ secrets.GITHUB_TOKEN }}

- name: Install cli requirements
run: pip install -r cli/requirements.txt

- name: Copy test config
run: python tests/setup_forcad.py

- name: Setup configuration
run: ./control.py kube setup

- name: Kustomize build
uses: karancode/kustomize-github-action@master
with:
kustomize_version: "3.9.2"
kustomize_build_dir: "deploy"
env:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Skaffold build
run: ./control.py kube build

terraform_checks:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
defaults:
run:
working-directory: deploy/terraform
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ Config file (`config.yml`) is split into five main parts:
* `checkers_path` (optional, default `/checkers/`): path to checkers inside Docker container. Do not change unless
you've changed the `celery` image.

* `volga_attacks_mode` (optional, default `false`): refuse to accept flags if the attacker's service is down.

* **admin** contains credentials to access celery visualization (`/flower/` on scoreboard) and admin panel:

* `username: forcad`
Expand Down
3 changes: 2 additions & 1 deletion backend/lib/helpers/singleton.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import json
from abc import ABCMeta, abstractmethod
from typing import TypeVar, Generic, Dict, Any
Expand All @@ -12,7 +13,7 @@ class Singleton(Generic[T], metaclass=ABCMeta):
@classmethod
def __get_key(cls, data: Dict[str, Any]):
rep = json.dumps(data, sort_keys=True)
return f'{cls.__module__}.{cls.__name__}-{rep}'
return f'{os.getpid()}.{cls.__module__}.{cls.__name__}-{rep}'

@staticmethod
@abstractmethod
Expand Down
32 changes: 16 additions & 16 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ async-timeout==4.0.2
autopep8==1.6.0
bidict==0.21.2
billiard==3.6.4.0
celery==5.2.3
celery==5.2.7
certifi==2020.12.5
charset-normalizer==2.1.0
click==8.0.3
Expand All @@ -13,42 +13,42 @@ click-repl==0.2.0
Deprecated==1.2.13
dnspython==1.16.0
eventlet==0.30.2
Flask==2.1.3
Flask==2.2.2
Flask-Cors==3.0.10
Flask-SocketIO==5.2.0
flower==1.1.0
Flask-SocketIO==5.3.2
flower==1.2.0
greenlet==1.1.2
gunicorn==20.1.0
hiredis==2.0.0
humanize==3.12.0
idna==3.3
importlib-metadata==4.12.0
itsdangerous==2.0.1
Jinja2==3.0.3
Jinja2==3.1.2
kombu==5.2.3
MarkupSafe==2.0.1
MarkupSafe==2.1.1
packaging==21.3
prometheus-client==0.14.1
prometheus-flask-exporter==0.20.2
prometheus-client==0.15.0
prometheus-flask-exporter==0.21.0
prompt-toolkit==3.0.18
psycopg2==2.9.3
psycopg2==2.9.5
pycodestyle==2.8.0
pydantic==1.9.1
pydantic==1.10.2
pyparsing==3.0.6
python-dateutil==2.8.1
python-engineio==4.3.3
python-socketio==5.7.1
pytz==2021.3
PyYAML==5.4.1
redis==4.3.4
python-socketio==5.7.2
pytz==2022.6
PyYAML==6.0
redis==4.3.5
requests==2.28.1
six==1.16.0
toml==0.10.2
tornado==6.1
typing-extensions==3.10.0.0
typing_extensions==4.4.0
urllib3==1.26.10
vine==5.0.0
wcwidth==0.2.5
Werkzeug==2.0.2
Werkzeug==2.2.2
wrapt==1.13.3
zipp==3.8.1
2 changes: 1 addition & 1 deletion cli/base/print_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@click.command('print_tokens', help='Print team tokens')
def print_tokens():
command = [
'docker-compose',
'docker', 'compose',
'-f', FULL_COMPOSE_PATH,
'exec', '-T', 'ticker',
'python3', '/app/scripts/print_tokens.py',
Expand Down
4 changes: 2 additions & 2 deletions cli/base/reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
def reset():
utils.print_bold('Trying to wipe the database')
command = [
'docker-compose',
'docker', 'compose',
'-f', constants.FULL_COMPOSE_PATH,
'run', 'initializer',
'python3', '/app/scripts/reset_db.py',
Expand All @@ -23,7 +23,7 @@ def reset():

utils.print_bold('Bringing down services')
command = [
'docker-compose',
'docker', 'compose',
'-f', constants.FULL_COMPOSE_PATH,
'down', '-v',
'--remove-orphans',
Expand Down
2 changes: 1 addition & 1 deletion cli/base/run_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

@click.command(
'rd',
help='Run docker-compose command with correct compose files',
help='Run docker compose command with correct compose files',
context_settings=dict(
ignore_unknown_options=True,
),
Expand Down
2 changes: 2 additions & 0 deletions cli/kube/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ def clean():

terraform_cache_path = constants.TERRAFORM_DIR / '.terraform'
utils.remove_dir(terraform_cache_path)

utils.remove_dir(constants.DOCKER_VOLUMES_DIR)
2 changes: 1 addition & 1 deletion cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def get_output(command: List[str], cwd=None, env=None) -> str:

def run_docker(args: List[str]):
base = [
'docker-compose',
'docker', 'compose',
'-f', constants.BASE_COMPOSE_FILE,
]

Expand Down
6 changes: 3 additions & 3 deletions docker-compose-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ version: '2.4'
x-celery-test: &celery-test
build:
context: .
dockerfile: ./docker_config/celery/Dockerfile.fast
dockerfile: ./docker_config/celery/Dockerfile
args:
version: ${FORCAD_VERSION:-latest}
restart: "no"

x-service-test: &service-test
build:
context: .
dockerfile: ./docker_config/services/Dockerfile.fast
dockerfile: ./docker_config/services/Dockerfile
args:
version: ${FORCAD_VERSION:-latest}
restart: "no"
Expand All @@ -26,7 +26,7 @@ services:
initializer:
build:
context: .
dockerfile: ./docker_config/initializer/Dockerfile.fast
dockerfile: ./docker_config/initializer/Dockerfile
args:
version: ${FORCAD_VERSION:-latest}
restart: "no"
Expand Down
4 changes: 2 additions & 2 deletions scripts/release_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ pushd "${BASE_DIR}" >/dev/null

IMAGE="ghcr.io/pomo-mondreganto/forcad_base:${VERSION}"

echo "[*] Building ${IMAGE}"
docker buildx build --platform linux/amd64,linux/arm64 -t "${IMAGE}" -f docker_config/base_images/backend.Dockerfile "$*" "${BASE_DIR}"
echo "[*] Building ${IMAGE}, base dir ${BASE_DIR}"
docker buildx build --platform linux/amd64,linux/arm64 -t "${IMAGE}" -f docker_config/base_images/backend.Dockerfile "$@" "${BASE_DIR}"

popd >/dev/null

Expand Down
4 changes: 2 additions & 2 deletions scripts/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export $(find ./docker_config -name "*.env" -exec egrep -v '^#' {} \; | xargs)
./control.py build
./control.py start
docker ps
docker-compose ps
docker-compose logs -f initializer
docker compose ps
docker compose logs -f initializer
python tests/wait_for_start.py
./control.py rd ps
env | sort
Expand Down
2 changes: 1 addition & 1 deletion tests/wait_for_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def wait_for_initializer():
result = int(subprocess.check_output(command).decode().strip())
if result != 0:
print(f'Error in container {name}')
subprocess.run(['docker-compose', 'logs'], cwd=PROJECT_DIR)
subprocess.run(['docker', 'compose', 'logs'], cwd=PROJECT_DIR)
sys.exit(1)


Expand Down

0 comments on commit 3801774

Please sign in to comment.