Skip to content

Commit

Permalink
Site: Remove completion report
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnorNelson committed Sep 20, 2024
1 parent 03c011f commit 9f76a13
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 48 deletions.
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ services:
- MAC_KEY_FILE=${MAC_KEY_FILE}
- MAC_GUEST_CONTROL_FILE=${MAC_GUEST_CONTROL_FILE}
volumes:
- /data:/var/data
- /data/CTFd/logs:/var/log/CTFd
- /data/CTFd/uploads:/var/uploads
- /data/homes:/var/homes:shared
Expand Down
1 change: 0 additions & 1 deletion dojo_plugin/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
logger.setLevel(logging.INFO)

DOJOS_DIR = pathlib.Path("/var/dojos")
DATA_DIR = pathlib.Path("/var/data")

WORKSPACE_NODES = {
int(node_id): node_key
Expand Down
46 changes: 0 additions & 46 deletions dojo_plugin/pages/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from CTFd.cache import cache

from ..models import Dojos, DojoModules, DojoChallenges
from ..config import DATA_DIR
from ..utils.scores import dojo_scores, module_scores
from ..utils.awards import get_belts, get_viewable_emojis

Expand Down Expand Up @@ -53,48 +52,3 @@ def view_other_name(user_name):
@authed_only
def view_self():
return view_hacker(get_current_user())

@users.route("/hacker/completion-report/")
@authed_only
def create_completion_report():
user = get_current_user()
solves = (
dojo
.solves(user=user, ignore_visibility=True)
.join(DojoModules, and_(
DojoModules.dojo_id == DojoChallenges.dojo_id,
DojoModules.module_index == DojoChallenges.module_index))
.order_by(Solves.id)
.with_entities(Dojos.id, DojoModules.id, DojoChallenges.id, Solves.date)
for dojo in Dojos.viewable(user=user)
)
result = []
for dojo_id, module_id, challenge_id, date in itertools.chain.from_iterable(solves):
date = date.replace(tzinfo=datetime.timezone.utc)
result.append((dojo_id, module_id, challenge_id, date))
result.sort(key=lambda row: row[-1])

result = "".join(f"{dojo_id}/{module_id}/{challenge_id} @ {date}\n"
for dojo_id, module_id, challenge_id, date in result)
result_hash = hashlib.sha256(result.encode()).hexdigest()

completion_reports_dir = DATA_DIR / "completion-reports"
completion_reports_dir.mkdir(exist_ok=True)
completion_report_path = completion_reports_dir / f"{result_hash}.txt"
completion_report_path.write_text(result)

url = url_for("pwncollege_users.view_completion_report", hash=result_hash, _external=True)
return Response(url, mimetype="text")


@users.route("/hacker/completion-report/<hash>.txt")
def view_completion_report(hash):
if not re.match(r"^[0-9a-f]{64}$", hash):
abort(404)

completion_reports_dir = DATA_DIR / "completion-reports"
completion_report_path = completion_reports_dir / f"{hash}.txt"
if not completion_report_path.exists():
abort(404)

return Response(completion_report_path.read_text(), mimetype="text")

0 comments on commit 9f76a13

Please sign in to comment.