add ctfd modules - #213
Merged
Merged
Conversation
ColdHeat
reviewed
Jul 16, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds first-class support for CTFd “modules” to the challenge lifecycle so challenge.yml can control (or intentionally not control) module assignment during sync/create, and so normalized challenge data can resolve module IDs back to names.
Changes:
- Add
modulehandling toChallenge.sync(),Challenge.create(), and normalization/verification logic. - Extend the challenge spec example YAML with documentation and a
modulefield. - Add/extend tests covering module resolution, creation, removal, and comparison behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
tests/core/test_challenge.py |
Adds test coverage for module sync/create behavior and normalization/comparison. |
ctfcli/spec/challenge-example.yml |
Documents the new module field and its “null vs omitted” semantics. |
ctfcli/core/challenge.py |
Implements module assignment, module normalization, and module comparison in verify. |
ctfcli/cli/challenges.py |
Updates deploy-time sync ignore list to include module. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1156
to
+1158
| # Assign module | ||
| if challenge.get("module") and "module" not in ignore: | ||
| self._set_module() |
Comment on lines
+915
to
+923
| # Add module | ||
| module_id = challenge_data.get("module_id") | ||
| if module_id: | ||
| # Prefer the module name over the ID | ||
| r = self.api.get(f"/api/v1/modules/{module_id}") | ||
| r.raise_for_status() | ||
| challenge["module"] = (r.json().get("data") or {}).get("name", None) | ||
| else: | ||
| challenge["module"] = None |
Comment on lines
+137
to
+139
| if key == "module" and value is None: | ||
| return True | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.