Skip to content

add ctfd modules - #213

Merged
ColdHeat merged 2 commits into
CTFd:masterfrom
vellvoid:add-modules
Jul 16, 2026
Merged

add ctfd modules#213
ColdHeat merged 2 commits into
CTFd:masterfrom
vellvoid:add-modules

Conversation

@vellvoid

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread ctfcli/core/challenge.py Outdated
@ColdHeat
ColdHeat merged commit fc6d6f0 into CTFd:master Jul 16, 2026
6 checks passed
@ColdHeat
ColdHeat requested a review from Copilot July 16, 2026 19:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 module handling to Challenge.sync(), Challenge.create(), and normalization/verification logic.
  • Extend the challenge spec example YAML with documentation and a module field.
  • 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 thread ctfcli/core/challenge.py
Comment on lines +1156 to +1158
# Assign module
if challenge.get("module") and "module" not in ignore:
self._set_module()
Comment thread ctfcli/core/challenge.py
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 thread ctfcli/core/challenge.py
Comment on lines +137 to +139
if key == "module" and value is None:
return True

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants