From 2983e6817b1a700db1185536b467f295fb53d689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milio=20Gonzalez?= Date: Sun, 5 Apr 2026 13:21:04 -0400 Subject: [PATCH 1/3] Fix badge generation + show help when no arg is given --- challenges/mock-track-apache-php/track.yaml | 28 ++++++++++++++++----- ctf/__main__.py | 3 ++- ctf/stats.py | 6 +++-- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/challenges/mock-track-apache-php/track.yaml b/challenges/mock-track-apache-php/track.yaml index 0996448..cd4da87 100644 --- a/challenges/mock-track-apache-php/track.yaml +++ b/challenges/mock-track-apache-php/track.yaml @@ -16,9 +16,25 @@ flags: cfss: "CFSS:0.3/TS:B/E:M/HSFC:N=4-7" tags: discourse: mock_track_apache_php_flag_1 -services: - - name: HTTP-80 - instance: mock-track-apache-php - address: '9000:d37e:c40b:c5e8:216:3eff:fed5:1ca1' - port: 80 - check: http +instances: + mock-track-apache-php: + image: "images:ubuntu/24.04" + profiles: + - "default" + - "containers" + type: "container" + description: "Mock Apache + PHP track" + # This second half of a MAC address was automatically generated. The first half is just below + hwaddr: "00:16:3e:6c:c3:c0" + # This is the subdomain value for this machine. Do NOT include .ctf, it will be automatically added. + # For example, if the value of the record is a.b.c, a DNS record will be created for a.b.c.ctf + record: "mock.track" + # This second half of the IPv6 is derived from the hwaddr. + ipv6: "9000:d37e:c40b:aa70:216:3eff:fe6c:c3c0" + config: {} + devices: [] + services: + - name: HTTP-80 + address: '9000:d37e:c40b:c5e8:216:3eff:fed5:1ca1' + port: 80 + check: http diff --git a/ctf/__main__.py b/ctf/__main__.py index 2c064d2..0606e1a 100644 --- a/ctf/__main__.py +++ b/ctf/__main__.py @@ -30,7 +30,8 @@ from ctf.version import app as version_app app = Typer( - help="CLI tool to manage CTF challenges as code. Run from the root CTF repo directory or set the CTF_ROOT_DIR environment variable to run the tool." + help="CLI tool to manage CTF challenges as code. Run from the root CTF repo directory or set the CTF_ROOT_DIR environment variable to run the tool.", + no_args_is_help=True, ) app.add_typer(validate_app) app.add_typer(init_app) diff --git a/ctf/stats.py b/ctf/stats.py index 9fb53ec..4e16c14 100644 --- a/ctf/stats.py +++ b/ctf/stats.py @@ -107,7 +107,9 @@ def stats( if number_of_flags > stats["most_flags_in_a_track"]: stats["most_flags_in_a_track"] = number_of_flags stats["number_of_flags"] += number_of_flags - stats["number_of_services"] += len(track_yaml["services"]) + instances = track_yaml.get("instances", {}).values() + services = track_yaml.get("services", []) + [service for instance in instances for service in instance.get("services", [])] + stats["number_of_services"] += len(services) stats["number_of_points_per_track"][track] = 0 for flag in track_yaml["flags"]: flags.append(flag["value"]) @@ -118,7 +120,7 @@ def stats( if flag["value"] not in stats["flag_count_per_value"]: stats["flag_count_per_value"][flag["value"]] = 0 stats["flag_count_per_value"][flag["value"]] += 1 - for service in track_yaml["services"]: + for service in services: if service["port"] not in stats["number_of_services_per_port"]: stats["number_of_services_per_port"][service["port"]] = 0 stats["number_of_services_per_port"][service["port"]] += 1 From e4b0263d672e65275806b8154e2a6d43623ea352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milio=20Gonzalez?= Date: Sun, 5 Apr 2026 13:23:44 -0400 Subject: [PATCH 2/3] ruff --- ctf/stats.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ctf/stats.py b/ctf/stats.py index 4e16c14..0a87c8e 100644 --- a/ctf/stats.py +++ b/ctf/stats.py @@ -108,7 +108,11 @@ def stats( stats["most_flags_in_a_track"] = number_of_flags stats["number_of_flags"] += number_of_flags instances = track_yaml.get("instances", {}).values() - services = track_yaml.get("services", []) + [service for instance in instances for service in instance.get("services", [])] + services = track_yaml.get("services", []) + [ + service + for instance in instances + for service in instance.get("services", []) + ] stats["number_of_services"] += len(services) stats["number_of_points_per_track"][track] = 0 for flag in track_yaml["flags"]: From 6bee90b395a87d1a6419fa12df098863ddc48e54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milio=20Gonzalez?= Date: Sun, 5 Apr 2026 13:29:40 -0400 Subject: [PATCH 3/3] fix --- challenges/mock-track-apache-php/track.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/challenges/mock-track-apache-php/track.yaml b/challenges/mock-track-apache-php/track.yaml index cd4da87..f2bf751 100644 --- a/challenges/mock-track-apache-php/track.yaml +++ b/challenges/mock-track-apache-php/track.yaml @@ -35,6 +35,5 @@ instances: devices: [] services: - name: HTTP-80 - address: '9000:d37e:c40b:c5e8:216:3eff:fed5:1ca1' port: 80 check: http