Skip to content

Commit 8604b82

Browse files
committed
Add ports.expose, type information to challenge reference
Signed-off-by: Robert Detjens <github@detjens.dev>
1 parent c54d86b commit 8604b82

File tree

2 files changed

+141
-19
lines changed

2 files changed

+141
-19
lines changed

docs/guides/challenge-quickstart.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,30 +101,30 @@ port the container is listening on, and either a port number or http subdomain.
101101
exposed at `<subdomain>.<challenges_domain>` with an HTTPS cert.
102102

103103
::: code-group
104-
```yaml [For TCP challenges] {8-10}
104+
```yaml [For TCP challenges] {8-11}
105105
pods:
106106
- name: main
107107
build:
108108
context: .
109109
dockerfile: Dockerfile
110110
replicas: 2
111111
ports:
112-
- internal: 31337 # the port the container listens on
112+
- internal: 31337 # <-- what your container listens on
113113
expose:
114-
tcp: 30124 # exposed at <challenges-domain>:30124
114+
tcp: 30124 # <-- would expose at chals.example.ctf:30124
115115
```
116116

117-
```yaml [For web challenges] {8-10}
117+
```yaml [For web challenges] {8-11}
118118
pods:
119119
- name: main
120120
build:
121121
context: .
122122
dockerfile: Dockerfile
123123
replicas: 2
124124
ports:
125-
- internal: 31337 # the port the container listens on
125+
- internal: 31337 # <-- what your container listens on
126126
expose:
127-
http: my-chal # exposed at https://my-chal.<challenges-domain>
127+
http: my-chal # <-- would expose at https://my-chal.chals.example.ctf
128128
```
129129
:::
130130

docs/reference/challenge-yaml-reference.md

Lines changed: 135 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,18 @@ title: <code>challenge.yaml</code> Reference
66

77
Challenge configuration is expected to be at `<category>/<name>/challenge.yaml`.
88

9+
There are some examples available on the [challenge quickstart guide](/guides/challenge-quickstart#examples).
10+
11+
Available fields:
12+
913
[[toc]]
1014

11-
## `name`
15+
`*` denotes required fields.
16+
17+
## `name`*
18+
19+
- type: `string`
20+
- no default
1221

1322
The name of the challenge, as shown to players in the frontend UI.
1423

@@ -19,7 +28,10 @@ name: notsh
1928
name: Revenge of the FIPS
2029
```
2130
22-
## `author`
31+
## `author`*
32+
33+
- type: `string`
34+
- no default
2335

2436
Author or authors of the challenge, as shown to players in the frontend UI. If there are multiple authors, specify them as one string.
2537

@@ -30,7 +42,10 @@ author: John Author
3042
author: Alice, Bob, and others
3143
```
3244

33-
## `description`
45+
## `description`*
46+
47+
- type: `string`
48+
- no default
3449

3550
Description and flavortext for the challenge, as shown to players in the frontend UI. Supports templating to include information about the challenge, such as the link or command to connect.
3651

@@ -58,6 +73,9 @@ description: |
5873

5974
## `category`
6075

76+
- type: `string`
77+
- default: from folder structure
78+
6179
The category for the challenge, parsed from the directory structure.
6280

6381
::: warning
@@ -66,6 +84,9 @@ This is automatically set from the expected directory structure of `<category>/<
6684

6785
## `difficulty`
6886

87+
- type: `integer`
88+
- no default
89+
6990
::: info
7091
Not implemented yet, does nothing
7192
:::
@@ -76,7 +97,10 @@ The difficulty from the challenge, used to set point values. Values correspond t
7697
difficulty: 1 # the current default
7798
```
7899
79-
## `flag`
100+
## `flag`*
101+
102+
- type: `string` | `dict`
103+
- no default
80104

81105
Where to find the flag for the challenge. The flag can be in a file, a regex, or a direct string.
82106

@@ -99,6 +123,9 @@ Regex flags are not implemented yet and setting one does nothing
99123

100124
## `provide`
101125

126+
- type: list of `string`/`dict`
127+
- default: `[]` (no files)
128+
102129
List of files to provide to the players on the frontend UI. These files can be from the challenge directory or from a container image built for a [challenge pod](#pods), and uploaded individually or zipped together.
103130

104131
If there are no files to upload for this challenge, this can be omitted or set to an empty array.
@@ -152,6 +179,9 @@ provide: []
152179

153180
### `.include`
154181

182+
- type: list of `string`
183+
- no default
184+
155185
File or list of files to upload individually, or include in a zip if `as` is set.
156186

157187
When uploading, only the basename is used and the path to the file is discarded.
@@ -160,16 +190,25 @@ If a provide item is specified as a single string, it is interpreted as an `incl
160190

161191
### `.as`
162192

193+
- type: `string`
194+
- no default
195+
163196
If `.include` is a single file, rename to this name while uploading.
164197

165198
If multiple files, zip them together into the given zip file.
166199

167200
### `.from`
168201

202+
- type: `string`
203+
- no default
204+
169205
Fetch these files from the corresponding [challenge pod](#pods) image.
170206

171207
## `pods`
172208

209+
- type: list of `dict`
210+
- default: `[]` (no pods)
211+
173212
Defines how to build and deploy any services needed for the challenge.
174213

175214
Challenge pods can be built from a local Dockerfile in the challenge folder or use an upstream image directly.
@@ -199,12 +238,18 @@ pods: []
199238

200239
### `.name`
201240

241+
- type: `string`
242+
- no default
243+
202244
Name of the pod, used to refer to this container as [a source for `provide` files](#provide) and for generated resource names.
203245

204246
Cannot contain spaces or punctuation, only alphanumeric and `-`.
205247

206248
### `.build`
207249

250+
- type: `string` | `dict`
251+
- no default
252+
208253
Build the container image for this pod from a local `Dockerfile`. Supports a subset of the [docker-compose build spec](https://docs.docker.com/reference/compose-file/build/#illustrative-example),
209254
either:
210255
- a string path to the build context folder
@@ -235,12 +280,18 @@ Conflicts with [`image`](#image).
235280
236281
### `.image`
237282

283+
- type: `string`
284+
- no default
285+
238286
Use an available container image for the pod instead of building one from source.
239287

240288
Conflicts with [`build`](#build).
241289

242290
### `.env`
243291

292+
- type: `dict`
293+
- default: `{}` (no envvars)
294+
244295
Any environment variables to set for the running pod. Specify as `name: value`.
245296

246297
```yaml
@@ -250,21 +301,38 @@ env:
250301

251302
### `.architecture`
252303

253-
Set the desired CPU architecture to run this pod on.
304+
- type: `string`
305+
- default: `"amd64"`
306+
307+
Set the desired CPU architecture to run this pod on. Kubernetes uses GOARCH architecture names.
254308

255309
```yaml
256-
architecture: amd64 # AKA x86_64; the default
257-
architecture: arm64 # for ARM
310+
architecture: amd64
311+
architecture: arm64
258312
```
259313

260314
### `.resources`
261315

262-
The resource usage request and limits for the pod. Kubernetes will make sure the requested resources will be available for this pod to use, and will also restart the pod if it goes over these limits.
316+
- type: `dict`
317+
- default: global default from `rcds.yaml`
318+
319+
The CPU and memory resources that will be reserved for this pod. Kubernetes will make sure the requested amounts will be available for this pod to use, and will also restart the pod if it goes over these limits.
320+
321+
Uses the [Kubernetes resource units](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#resource-units-in-kubernetes).
263322

264323
If not set, the default set in [`rcds.yaml`](rcds-yaml-reference#resources) is used.
265324

325+
```yaml
326+
resources:
327+
cpu: 1
328+
memory: 512Mi
329+
```
330+
266331
### `.replicas`
267332

333+
- type: `number`
334+
- default: `2`
335+
268336
How many instances of the pod to run. Traffic is load-balanced between instances.
269337

270338
Default is 2 and this is probably fine unless the challenge is very resource intensive.
@@ -275,14 +343,68 @@ replicas: 2 # the default
275343

276344
### `.ports`
277345

278-
Specfies how to expose this pod to players, either as a raw TCP port or HTTP at a specific domain.
346+
- type: list of `dict`
347+
- default: `[]`
348+
349+
List of ports to expose to players.
350+
351+
#### `.ports[].internal`
279352

280-
#### `.ports.internal`
353+
- type: `number`
354+
- no default
281355

282-
The port the container is listening on; i.e. `xinetd` or `nginx` etc.
356+
The port that the challenge container (i.e. `xinetd`/`nginx`/etc inside) is listening on.
283357

284-
#### `.ports.expose`
358+
#### `.ports[].expose`
285359

286-
How to expose the internal container port
360+
- type: `dict`
361+
- no default
362+
363+
How to expose the internal container port to players -- either as a TCP port or a subdirectory for web challenges. Must be one of the following:
364+
365+
**`.ports[].expose.tcp`**
366+
367+
- type: `number`
368+
- no default
369+
370+
The port to expose the challenge over raw TCP at on the challenge subdomain. Must be unique across all other exposed TCP challenges.
371+
372+
```yaml [For TCP challenges] {8-10}
373+
pods:
374+
- #...
375+
ports:
376+
- internal: 31337 # the port the container listens on
377+
expose:
378+
tcp: 30124 # exposed at <challenges-domain>:30124
379+
```
380+
381+
**`.ports[].expose.http`**
382+
383+
- type: `string`
384+
- no default
385+
386+
The subdomain to expose the challenge at as a website (port 80/443). This is prepended to the global challenge subdomain. The cluster will provision an SSL certificate for the site.
387+
388+
Must be a valid DNS domain name (alphanumeric, `_`, `-`).
389+
390+
```yaml [For web challenges] {8-10}
391+
pods:
392+
- name: main
393+
build:
394+
context: .
395+
dockerfile: Dockerfile
396+
replicas: 2
397+
ports:
398+
- internal: 31337 # the port the container listens on
399+
expose:
400+
http: my-chal # exposed at https://my-chal.<challenges-domain>
401+
```
287402

288403
### `.volume`
404+
405+
- type: `string`
406+
- no default
407+
408+
::: info
409+
Not implemented yet, does nothing
410+
:::

0 commit comments

Comments
 (0)