diff --git a/ctf_status.env.example b/.env.example similarity index 55% rename from ctf_status.env.example rename to .env.example index eeb2eb7..488b473 100644 --- a/ctf_status.env.example +++ b/.env.example @@ -1,22 +1,21 @@ -# cp to ctf_status.env and chmod 600 (a plain .env next to the script works too) +# cp .env.example .env && chmod 600 .env # --- GitLab: the group holding one repo per challenge ----------------------- GITLAB_GROUP_URL=https://gitlab.lrz.de/h4tum-ctf/h4tum-ctf-2026/challenges # fine-grained personal access token, scoped to that group, with # Project: Read (list the repos) -# Repository: Read (download each README.md) +# Repository: Read (download README.md and description.yml, list the files) GITLAB_TOKEN=glpat-xxxxxxxxxxxxxxxxxxxx -# --- HedgeDoc: the existing note that gets overwritten every run ------------ -# full URL of the note (its permission must be "freely" so an anonymous -# run may write to it), e.g. https://hedgedoc.cit.tum.de/AbCdEf123 +# --- HedgeDoc: the existing note that --update overwrites ------------------- +# full URL of the note; its permission must be "freely" so an anonymous run +# may write to it HEDGEDOC_NOTE= # YAML front-matter tags written at the top of the note HEDGEDOC_TAGS=Logistics, h4tum CTF 2026 # --- deployment repo: --challs keeps in it up to date -------- -# one clone URL per line for every challenge at Testing Ready or beyond. The -# token additionally needs, on this project: Repository: Read + Repository: Write +# the token additionally needs, on this project: Repository: Read + Write CHALLS_REPO_URL=https://gitlab.lrz.de/h4tum-ctf/h4tum-ctf-deployment/ctf-deployment CHALLS_PATH=2026/challs.txt CHALLS_BRANCH=main diff --git a/.gitignore b/.gitignore index 3d47cce..9bdb4db 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ __pycache__/ -ctf_status.env *.md.out .env diff --git a/README.md b/README.md index 9388acb..de3569a 100644 --- a/README.md +++ b/README.md @@ -1,198 +1,126 @@ -# ctf_status.py +# CTF challenge status tracker -Reads the `README.md` of every repo in the GitLab challenges group (REST API, no -clone) and shows which categories have challenges in which state, at which -difficulty — in the terminal and as a HedgeDoc note. A status of Testing Ready -or beyond is only believed if the repo backs it up (see -[Checking the repo](#checking-the-repo)). +Tracks the progress of the h4tum CTF challenges. It reads every repo in the +GitLab challenges group, works out each challenge's status, category and +difficulty from its `README.md`, and checks that challenges marked as ready +really are. The result goes to: -Needs `requests` and `PyYAML` (`python-requests python-yaml` on Arch, -`python3-requests python3-yaml` on Debian). +- **a HedgeDoc note**: an overview of all challenges, refreshed every 30 minutes +- **`challs.txt` in the deployment repo**: the clone URLs of every challenge + ready for infra testing, updated daily +- **the terminal**: the same overview, for a quick look -## Setup +## Requirements + +- Python 3.9+ +- [`requests`](https://pypi.org/project/requests/) and [`PyYAML`](https://pypi.org/project/PyYAML/) + (`python-requests python-yaml` on Arch, `python3-requests python3-yaml` on Debian) + +## Configuration ```sh -cp ctf_status.env.example ctf_status.env && chmod 600 ctf_status.env -$EDITOR ctf_status.env # GitLab group URL + token, HedgeDoc note +cp .env.example .env && chmod 600 .env ``` -## Use - -```sh -./ctf_status.py # terminal summary -./ctf_status.py -o overview.md # + HedgeDoc markdown to a file -./ctf_status.py --stdout | wl-copy # straight to clipboard, paste into HedgeDoc -./ctf_status.py --update # overwrite the note in HEDGEDOC_NOTE -./ctf_status.py --update # ... or an explicit one -``` - -The token is a fine-grained personal access token on the challenges group with -**Project: Read** (to list the repos) and **Repository: Read** (to download the -READMEs and `description.yml`, and to list the repo's files). A plain `.env` with `GL_PAT=` / `GITLAB_URL=` is read as well. - -## Keeping a HedgeDoc note up to date - -`--update` overwrites an **existing** note in place, so the URL you share stays the -same. Every run rewrites the whole body, starting with - -``` ---- -tags: Logistics, h4tum CTF 2026 ---- -``` - -and a `**Last updated:**