Skip to content

Commit 8fe2496

Browse files
committed
Add logic key to challenge specification
1 parent 7393941 commit 8fe2496

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

ctfcli/core/challenge.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Challenge(dict):
4545
# fmt: off
4646
"name", "author", "category", "description", "attribution", "value",
4747
"type", "extra", "image", "protocol", "host",
48-
"connection_info", "healthcheck", "attempts", "flags",
48+
"connection_info", "healthcheck", "attempts", "logic", "flags",
4949
"files", "topics", "tags", "files", "hints",
5050
"requirements", "next", "state", "version",
5151
# fmt: on
@@ -291,6 +291,9 @@ def _get_initial_challenge_payload(self, ignore: Tuple[str] = ()) -> Dict:
291291
if "connection_info" not in ignore:
292292
challenge_payload["connection_info"] = challenge.get("connection_info", None)
293293

294+
if "logic" not in ignore:
295+
challenge_payload["logic"] = challenge.get("logic", "any")
296+
294297
if "extra" not in ignore:
295298
challenge_payload = {**challenge_payload, **challenge.get("extra", {})}
296299

@@ -552,13 +555,16 @@ def _normalize_challenge(self, challenge_data: Dict[str, Any]):
552555
"type",
553556
"state",
554557
"connection_info",
558+
"logic",
555559
]
556560
for key in copy_keys:
557561
if key in challenge_data:
558562
challenge[key] = challenge_data[key]
559563

560564
challenge["description"] = challenge_data["description"].strip().replace("\r\n", "\n").replace("\t", "")
561-
challenge["attribution"] = challenge_data.get("attribution", "").strip().replace("\r\n", "\n").replace("\t", "")
565+
challenge["attribution"] = challenge_data.get("attribution", "")
566+
if challenge["attribution"]:
567+
challenge["attribution"] = challenge["attribution"].strip().replace("\r\n", "\n").replace("\t", "")
562568
challenge["attempts"] = challenge_data["max_attempts"]
563569

564570
for key in ["initial", "decay", "minimum"]:

ctfcli/spec/challenge-example.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ healthcheck: writeup/exploit.sh
5151
# Can be removed if unused
5252
attempts: 5
5353

54+
# Specifies flag processing behavior of challenge
55+
# Accept any flag (default): any
56+
# Require all flags to be provided: all
57+
# Require all team members to submit any flag: team
58+
logic: any
59+
5460
# Flags specify answers that your challenge use. You should generally provide at least one.
5561
# Can be removed if unused
5662
# Accepts strings or dictionaries of CTFd API data

0 commit comments

Comments
 (0)