From 4a9b2e42addc3119d4f73bd56ce56062524a1cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milio=20Gonzalez?= Date: Sun, 16 Nov 2025 14:07:52 -0500 Subject: [PATCH] =?UTF-8?q?Remove=20`ctf/schemas`=20directory=20and=20use?= =?UTF-8?q?=20the=20CTF=E2=80=99s=20schemas=20when=20running=20`ctf=20vali?= =?UTF-8?q?date`=20instead.=20The=20schemas=20are=20already=20in=20the=20`?= =?UTF-8?q?templates`=20directory=20and=20we=20need=20the=20`schemas`=20di?= =?UTF-8?q?rectory=20in=20the=20CTF=20directory,=20so=20that=20IDEs=20can?= =?UTF-8?q?=20use=20the=20schemas=20to=20highlight=20errors=20and=20have?= =?UTF-8?q?=20autocompletion.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ctf/schemas/post.json | 143 ----------------------------- ctf/schemas/track.yaml.json | 173 ------------------------------------ ctf/utils.py | 2 +- 3 files changed, 1 insertion(+), 317 deletions(-) delete mode 100644 ctf/schemas/post.json delete mode 100644 ctf/schemas/track.yaml.json diff --git a/ctf/schemas/post.json b/ctf/schemas/post.json deleted file mode 100644 index f548068..0000000 --- a/ctf/schemas/post.json +++ /dev/null @@ -1,143 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "description": "", - "type": "object", - "properties": { - "type": { - "description": "Type of post. Use `topic` for the initial message of a track, and use `post` for subsequent posts (for example posts after a flag is submitted). `posts` is for multiple posts in one file (post).", - "type": "string", - "enum": [ - "post", - "posts", - "topic" - ] - }, - "topic": { - "description": "The discourse topic to post this post into. For a given track, this should always have the same value across posts.", - "type": "string", - "minLength": 1 - }, - "trigger": { - "description": "Defines a custom trigger to post a message after a specific action happened, for example a flag is submitted.", - "type": "object", - "properties": { - "type": { - "description": "Type of trigger: use `flag` to post after a given flag is submitted (the value of the flag should be set in the `tag` property.)", - "type": "string", - "enum": [ - "flag" - ] - }, - "tag": { - "description": "Value of the trigger. For a flag trigger, this is the flag value.", - "type": "string", - "minLength": 1 - } - }, - "required": [ - "type", - "tag" - ] - }, - "api": { - "type": "object", - "properties": { - "user": { - "description": "The discourse user this post is posted by.", - "type": "string", - "enum": ["nsec","system","theChief","theMuscle","theFace","theFixer","theMechanic"] - } - }, - "required": [ - "user" - ] - }, - "title": { - "description": "The discourse title of the topic. This should be the same across posts of the same track.", - "type": "string", - "minLength": 1 - }, - "body": { - "description": "Content of the post. Markdown is supported.", - "type": "string", - "minLength": 1 - }, - "posts": { - "description": "", - "type": "array", - "items": { - "type": "object", - "properties": { - "api": { - "type": "object", - "properties": { - "user": { - "description": "The discourse user this post is posted by.", - "type": "string", - "minLength": 1 - } - }, - "required": [ - "user" - ] - }, - "body": { - "description": "Content of the post. Markdown is supported.", - "type": "string", - "minLength": 1 - } - }, - "required": [ - "api", - "body" - ] - } - } - }, - "if": { - "properties": { - "type": { - "const": "topic" - } - } - }, - "then": { - "required": [ - "type", - "api", - "title", - "body" - ] - }, - "else": { - "if": { - "properties": { - "type": { - "const": "post" - } - } - }, - "then": { - "required": [ - "type", - "api", - "body" - ] - }, - "else": { - "if": { - "properties": { - "type": { - "const": "posts" - } - } - }, - "then": { - "required": [ - "type", - "posts" - ] - } - } - } -} \ No newline at end of file diff --git a/ctf/schemas/track.yaml.json b/ctf/schemas/track.yaml.json deleted file mode 100644 index 16c0443..0000000 --- a/ctf/schemas/track.yaml.json +++ /dev/null @@ -1,173 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "description": "", - "type": "object", - "additionalProperties": false, - "properties": { - "name": { - "type": "string", - "minLength": 1, - "description": "Name of the track." - }, - "description": { - "type": "string", - "minLength": 1, - "description": "Description of the track." - }, - "integrated_with_scenario": { - "type": "boolean", - "description": "Set to true only if the track has been integrated with the CTF scenario. This means that Eric Boivin wrote/modified the posts." - }, - "contacts": { - "description": "Handles or real names. Ex: Émilio Gonzalez or Res260", - "type": "object", - "properties": { - "additionalProperties": false, - "dev": { - "description": "Who helped develop the track.", - "type": "array", - "uniqueItems": true, - "items": { - "type": "string" - } - }, - "qa": { - "description": "Who helped do quality assurance for the track.", - "type": "array", - "uniqueItems": true, - "items": { - "type": "string" - } - }, - "support": { - "description": "Who can provide support during the CTF for the track.", - "type": "array", - "uniqueItems": true, - "items": { - "type": "string" - } - } - }, - "required": [ - "dev", - "qa", - "support" - ] - }, - "services": { - "description": "List of network services used by the track.", - "type": "array", - "uniqueItems": true, - "items": { - "required": [ - "name", - "address", - "port", - "check" - ], - "properties": { - "additionalProperties": false, - "name": { - "description": "Name of the network service. Example: Tomcat Web Server. Must be unique in the track. Only use lowercase letters, numbers and dashes.", - "type": "string", - "minLength": 1, - "pattern": "^[a-zA-Z0-9-]+$" - }, - "address": { - "description": "IPv6 address of the network service.", - "type": "string", - "minLength": 36, - "maxLength": 39 - }, - "port": { - "description": "Port number where the network service listens on.", - "type": "number" - }, - "check": { - "description": "Type of check to do to make sure this service is up and alert us during the CTF if it's down.", - "type": "string", - "enum": ["http", "https", "ssh", "tcp"] - }, - "dev_port_mapping": { - "type": "integer", - "minimum": 1, - "maximum": 65535, - "description": "During development, this service will be accessible from localhost:. This allows to access the services outside the host (for example from the Windows Host if using WSL or from your host machine if using GitHub Codespaces)." - } - } - } - }, - "flags": { - "description": "The list of flags in the track.", - "type": "array", - "minItems": 0, - "maxItems": 20, - "uniqueItems": true, - "items": { - "description": "A flag definition.", - "type": "object", - "required": ["flag", "value", "return_string"], - "additionalProperties": false, - "properties": { - "flag": { - "type": "string", - "description": "The flag string. Ex: FLAG-SalutLaGang.", - "minLength": 5, - "maxLength": 200 - }, - "value": { - "type": "integer", - "description": "The value of the flag. Minimum: 0.", - "minimum": 0, - "maximum": 20 - }, - "description": { - "type": "string", - "description": "INTERNAL description of the flag. Example: Free flag in source of index.php.", - "minLength": 1 - }, - "return_string": { - "type": "string", - "description": "The text the participants see AFTER they submit the flag. Example: [mytrackname] 1/1 Good job! Track completed.", - "minLength": 1 - }, - "cfss": { - "type": "string", - "description": "The CFSS string based on https://github.com/res260/cfss", - "pattern": "^CFSS:[0-9]\\.[0-9][0-9]?/TS:[LBIA]/E:[LMH]/HSFC:[NY]=[0-9][0-9]?-[0-9][0-9]?$" - }, - "tags": { - "type": "object", - "description": "Askgod tags for this flag. Use tag `discourse: sometriggername` to define triggers for posts in the posts/ directory.", - "additionalProperties": true, - "properties": { - "discourse": { - "type": "string", - "description": "Discourse trigger for this flag. This value can be used in a discourse post defined in the posts/ directory to post a message when this flag is submitted.", - "pattern": "^[a-z][a-z0-9_]{0,61}[a-z0-9]$" - }, - "ui_sound": { - "type": "string", - "description": "Fireworks sound trigger for this flag. This value can be used to trigger a specific sound in the timeline when this flag is submitted. The chosen file can be any of the default ones which can be found at https://github.com/nsec/askgod-webui/blob/master/components/Fireworks.vue#L72-L88 or new ones added in \"challenges/your-track/files/askgod/sounds/*.mp3\".", - "pattern": "^[a-zA-Z0-9_-]{1,251}\\.[a-zA-Z0-9]{2,5}$" - }, - "ui_gif": { - "type": "string", - "description": "Fireworks gif trigger for this flag. This value can be used to trigger a specific gif in the timeline when this flag is submitted. The chosen file can be any of the default ones which can be found at https://github.com/nsec/askgod-webui/blob/master/components/Fireworks.vue#L39-L70 or new ones added in \"challenges/your-track/files/askgod/gifs/*.gif\".", - "pattern": "^[a-zA-Z0-9_-]{1,251}\\.[a-zA-Z0-9]{2,5}$" - } - } - } - } - } - } - }, - "required": [ - "name", - "description", - "integrated_with_scenario", - "contacts", - "services", - "flags" - ] - } diff --git a/ctf/utils.py b/ctf/utils.py index 8a93b30..9ccfb34 100644 --- a/ctf/utils.py +++ b/ctf/utils.py @@ -299,7 +299,7 @@ def get_ctf_script_templates_directory() -> str: def get_ctf_script_schemas_directory() -> str: - return os.path.join(get_ctf_script_root_directory(), "schemas") + return os.path.join(find_ctf_root_directory(), "schemas") def remove_ctf_script_root_directory_from_path(path: str) -> str: