Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Parable allows a competitor end user to view a wide variety of information relev
Enigma has Discord integration and will automatically manage channels and roles. Competitors will be able to submit various requests through Discord to supplement their use of Parable, such as green team support and box reset requests.

## Details
Built on Python 3.13.0 with Django and FastAPI
Built on Python 3.13.0 with Flask

Highly extensible with a common framework for custom service checks

Expand All @@ -27,4 +27,4 @@ The following table lists the ports of each service:
|PostgreSQL|5432|
|Nginx|80,443|

Nginx should be the only service exposed
Nginx should be the only service exposed
5 changes: 3 additions & 2 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ services:
retries: 3
start_interval: 2s


parable:
container_name: parable
image: parable:latest
build: ./parable
build:
context: .
dockerfile: ./docker/parable/Dockerfile
ports:
- "5070:5070"
restart: no
Expand Down
96 changes: 0 additions & 96 deletions db_models/__init__.py

This file was deleted.

4 changes: 2 additions & 2 deletions docker/enigma/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ FROM python:3.13-alpine
WORKDIR /app

# Install requirements
COPY /enigma/requirements.txt /app/requirements.txt
COPY /requirements/enigma/requirements.txt /app/requirements.txt

RUN python -m pip install --no-cache-dir --upgrade pip
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt

# Copy modules
COPY /enigma /app/enigma
COPY /db_models /app/db_models
COPY /enigma_models /app/enigma_models

# Copy main.py
COPY /main/enigma/main.py /app/main.py
Expand Down
18 changes: 17 additions & 1 deletion docker/parable/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
# syntax=docker/dockerfile:1
FROM python:3.13-alpine

WORKDIR /app
WORKDIR /app

# Install requirements
COPY --from=ghcr.io/astral-sh/uv:0.5.31 /uv /uvx /bin/

COPY /requirements/parable/requirements.txt /app/requirements.txt
RUN uv pip install --system -r /app/requirements.txt

# Copy modules
COPY /parable /app/parable
COPY /enigma_models /app/enigma_models

# Copy main.py
COPY /main/parable/main.py /app/main.py

# Run main.py
CMD ["python", "main.py"]
2 changes: 1 addition & 1 deletion docker/praxos/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt

# Copy modules
COPY /praxos /app/praxos
COPY /db_models /app/db_models
COPY /enigma_models /app/enigma_models

# Copy main.py
COPY /main/praxos/main.py /app/main.py
Expand Down
2 changes: 1 addition & 1 deletion enigma/checks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __eq__(self, obj):
# This method is perhaps most important. It conducts a service check and returns a boolean to represent the result
# Note that conduct_service_check() will be called in a worker process, not the main thread
# Implementations of conduct_service_check() must check kwargs for check info
# This is used to properly target a team's box
# This is used to properly target a competitor's box
# e.x. If the pod networks are on 172.16.<identifier>.0, then conduct_service_check() will target 172.16.<identifier>.<box>
# e.x. If Team01 has identifier '32', and an SSHService is configured on Box 'examplebox' with host octet 5,
# then the worker process will target 172.16.32.5
Expand Down
9 changes: 8 additions & 1 deletion enigma/engine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@
load_dotenv(override=True)

postgres_settings = {
'user': getenv('POSTGRES_USER'),
'competitor': getenv('POSTGRES_USER'),
'password': getenv('POSTGRES_PASSWORD'),
'host': getenv('POSTGRES_HOST'),
'port': getenv('POSTGRES_PORT')
}

rabbitmq_settings = {
'competitor': getenv('RABBITMQ_DEFAULT_USER'),
'password': getenv('RABBITMQ_DEFAULT_PASSWORD'),
'host': getenv('RABBITMQ_HOST'),
'port': 5672
}

static_path = join(getcwd(), 'static')
checks_path = join(getcwd(), 'enigma')
8 changes: 5 additions & 3 deletions enigma/engine/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from enigma.logger import log

from enigma.broker import RabbitMQ
from enigma.engine.scoring import ScoringEngine, RvBScoringEngine
from enigma.engine.scoring import RvBScoringEngine

# TODO: Add event scheduler to create box score start times
class RvBCMD:
Expand Down Expand Up @@ -61,7 +61,7 @@ def decode_cmd(self, cmd):
case 'set_rounds':
if isinstance(self.engine, RvBScoringEngine):
if not self.engine.engine_lock:
self.rounds = cmd_args[1]
self.rounds = int(cmd_args[1])
log.info(f'Setting rounds to {self.rounds}')
else:
log.warning('Cannot change number of rounds while running!')
Expand Down Expand Up @@ -97,4 +97,6 @@ def decode_cmd(self, cmd):
else:
log.warning('Enigma is not running!')
else:
log.error('Engine does not exist!')
log.error('Engine does not exist!')
case _:
log.error('Unknown command!')
38 changes: 0 additions & 38 deletions enigma/engine/database.py

This file was deleted.

2 changes: 1 addition & 1 deletion enigma/engine/rabbitmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class RabbitMQ:

def __init__(self):
self.user = rabbitmq_settings['user']
self.user = rabbitmq_settings['competitor']
self.password = rabbitmq_settings['password']
self.host = rabbitmq_settings['host']
self.port = rabbitmq_settings['port']
Expand Down
18 changes: 9 additions & 9 deletions enigma/engine/scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from enigma.broker import RabbitMQ

from enigma.models.box import Box
from enigma.models.credlist import Credlist
from enigma_models.models.credlist import Credlist
from enigma.models.team import RvBTeam
from enigma.models.settings import Settings
from enigma_models.models.settings import Settings

class ScoringEngine:

Expand Down Expand Up @@ -90,9 +90,9 @@ def run(self, total_rounds: int = 0):
self.engine_lock = False

# Exporting end-of-scoring data
log.info('Exporting individual team score breakdowns')
log.info('Exporting individual competitor score breakdowns')
for team in self.teams:
team.export_breakdowns(f'team{team.identifier}_final', static_path)
team.export_breakdowns(f'competitor{team.identifier}_final', static_path)

# Score check methods

Expand Down Expand Up @@ -135,7 +135,7 @@ def score_services(self):
log.debug('Created score checks with check data')

# Presumed guilty check results
# reports = {team identifier: {service: [result, msg]}}
# reports = {competitor identifier: {service: [result, msg]}}
reports = {}
for team in self.teams:
team_results = {}
Expand All @@ -154,15 +154,15 @@ def score_services(self):
reports[result[0]][result[1]][1] = result[2]
log.debug('Scores updated, proceeding to tabulate scores')

# Tabulate scores for each team
# Tabulate scores for each competitor
for team in self.teams:
team.tabulate_scores(self.round, reports[team.identifier])

log.debug('Finished scoring services')

# Finds and applies check options for a service
def get_check_options(self, service: Service, team: RvBTeam):
log.debug(f'Creating check data for team {team.identifier} with service {service.name}')
log.debug(f'Creating check data for competitor {team.identifier} with service {service.name}')
check_options = []

# If check requires a credlist, get a random cred and add it to options
Expand Down Expand Up @@ -269,15 +269,15 @@ def update_comp(self):
log.info("RvB competition environment loaded")

log.info("Searching for RvB teams")
self.teams = RvBTeam.find_all(self.services)
self.teams = RvBTeam.find_all(services=self.services)

if len(self.teams) == 0:
self.teams_detected = False
log.info("No RvB teams found")
return
else:
self.teams_detected = True
log.info("RvB teams found, creating team credlists")
log.info("RvB teams found, creating competitor credlists")
for team in self.teams:
team.create_credlists(
self.credlists
Expand Down
3 changes: 2 additions & 1 deletion enigma/logger.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
from logging import FileHandler
from os import getenv, getcwd
from os.path import join

Expand Down Expand Up @@ -32,7 +33,7 @@ def write_log_header():
)

# Handlers for file and stream output
file_handler = logging.FileHandler(
file_handler = FileHandler(
log_file,
mode = 'a',
encoding = 'utf-8'
Expand Down
Loading
Loading