forked from ArmyCyberInstitute/cmgr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
swagger.yaml
455 lines (455 loc) · 13 KB
/
swagger.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
swagger: "2.0"
info:
description: "This is a minimal REST API for `cmgr` that allows front-ends for a CTF to remotely manage challenges and their templating for events. It is not intended to replace `cmgr` entirely as it does not currently expose the challenge update process."
version: "0.2.0"
title: "cmgrd"
contact:
email: "[email protected]"
license:
name: "Apache 2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
tags:
- name: "challenges"
description: "Management of templatable challenges as well as accessing their metadata."
- name: "builds"
description: "Management of challenges that have been templated with a concrete flag and associated artifacts."
- name: "instances"
description: "Management of challenge instances with which competitors can interact."
- name: "schemas"
description: "Management of schemas which group build and instance resources into a single declarative unit."
schemes:
- "http"
paths:
/challenges:
get:
parameters:
- name: "tags"
in: "query"
description: "Seach for available challenges limiting to given tags"
required: false
type: array
items:
type: string
tags: [challenges]
produces: ["application/json"]
summary: "Lists all available challenges"
responses:
"500":
description: "A database error occurred in `cmgr`"
"200":
description: "A list of all valid challenge identifiers"
schema:
type: "array"
items:
$ref: "#/definitions/ChallengeListElement"
/challenges/{challenge_id}:
parameters:
- name: "challenge_id"
in: "path"
description: "The identifier for the challenge"
required: true
type: "string"
get:
tags: [challenges]
produces: ["application/json"]
summary: "Gets the metadata for the challenge"
responses:
"404":
description: "Invalid path string to include invalid challenge identifier"
"500":
description: "A database error occurred in `cmgr`"
"200":
description: "The metadata for the challenge"
schema:
$ref: "#/definitions/ChallengeMetadata"
post:
tags: [challenges]
produces: ["application/json"]
summary: "Builds templated versions of the challenge"
description: "Uses the flag format and seed to template out a new version of the challenge. This may take a signficant amount of time."
parameters:
- in: "body"
name: "body"
description: "templating information for `cmgr`"
required: true
schema:
$ref: "#/definitions/BuildChallengeRequest"
responses:
"404":
description: "Invalid path string to include invalid challenge identifier"
"500":
description: "A database error occurred in `cmgr`"
"200":
description: "A list of the new build IDs in the same order as seeds were given"
schema:
type: array
items:
type: integer
format: int64
/builds/{build_id}:
parameters:
- name: "build_id"
in: "path"
description: "The identifier for the build"
required: true
type: "string"
get:
tags: [builds]
produces: ["application/json"]
summary: "Gets the metadata for the build"
responses:
"404":
description: "Invalid path string to include invalid build identifier"
"500":
description: "A database error occurred in `cmgr`"
"200":
description: "The metadata for the build"
schema:
$ref: "#/definitions/BuildMetadata"
post:
tags: [builds]
produces: ["application/json"]
summary: "Starts an instance of the build"
responses:
"404":
description: "Invalid path string to include invalid build identifier"
"500":
description: "A database error occurred in `cmgr`"
"201":
description: "The identifier of the new instance"
schema:
type: integer
format: int64
delete:
tags: [builds]
produces: ["application/json"]
summary: "Destroys the build (releases resources)"
responses:
"404":
description: "Invalid path string to include invalid challenge identifier"
"500":
description: "A database error occurred in `cmgr`"
"204":
description: "Indicates successfully deleted"
/builds/{build_id}/{artifact}:
parameters:
- name: "build_id"
in: "path"
description: "The identifier for the build"
required: true
type: "string"
- name: "artifact"
in: "path"
description: "The name of the artifact to download ('artifacts.tar.gz' to download all of them in a bundle)"
required: true
type: "string"
get:
tags: [builds]
summary: "The requested artifact"
responses:
"404":
description: "The requested artifact does not exist"
"500":
description: "An error occurred while reading the artifact from disk"
"200":
description: "The artifact"
/instances/{instance_id}:
parameters:
- name: "instance_id"
in: "path"
description: "The identifier for the instance"
required: true
type: "string"
get:
tags: [instances]
produces: ["application/json"]
summary: "Gets the metadata for the instance"
responses:
"404":
description: "Invalid path string to include invalid instance identifier"
"500":
description: "A database error occurred in `cmgr`"
"200":
description: "The metadata for the instance"
schema:
$ref: "#/definitions/InstanceMetadata"
post:
tags: [instances]
produces: ["application/json"]
summary: "Runs the automated solver against the instance"
responses:
"404":
description: "Invalid path string to include invalid instance identifier"
"500":
description: "A database error occurred in `cmgr`. Could also indicate that the solve failed or does not exist."
"204":
description: "Indicates solve ran correctly"
delete:
tags: [instances]
produces: ["application/json"]
summary: "Stops an instance"
responses:
"404":
description: "Invalid path string to include invalid challenge identifier"
"500":
description: "A database error occurred in `cmgr` (may also indicate that there are live instances of the build)"
"204":
description: "Indicates successfully stopped"
/schemas:
get:
tags: [schemas]
produces: ["application/json"]
summary: "Gets the list of all current schemas"
responses:
"404":
description: "Invalid path string"
"500":
description: "A database error occurred in `cmgr` (currently includes bad build identifiers)"
"200":
description: "The list of schemas"
schema:
type: array
items:
type: string
post:
tags: [schemas]
produces: ["application/json"]
summary: "Creates a schema with the given definition"
parameters:
- in: "body"
name: "body"
description: "templating information for `cmgr`"
required: true
schema:
$ref: "#/definitions/SchemaDefinition"
responses:
"400":
description: "Value for 'schema_name' did not match the name in the schema definition"
"404":
description: "Invalid path string"
"500":
description: "A database error occurred in `cmgr` (currently includes bad build identifiers)."
"201":
description: "Indicates schema created successfully"
/schemas/{schema_name}:
parameters:
- name: "schema_name"
in: "path"
description: "The identifier for the schema"
required: true
type: "string"
get:
tags: [schemas]
produces: ["application/json"]
summary: "Gets the current deployed state of the schema"
responses:
"404":
description: "Invalid path string"
"500":
description: "A database error occurred in `cmgr` (currently includes bad build identifiers)"
"200":
description: "The metadata for all challenges, builds, and instances controlled or referenced by this schema"
schema:
$ref: "#/definitions/ChallengeMetadata"
post:
tags: [schemas]
produces: ["application/json"]
summary: "Updates the schema to match the given definition"
parameters:
- in: "body"
name: "body"
description: "templating information for `cmgr`"
required: true
schema:
$ref: "#/definitions/SchemaDefinition"
responses:
"400":
description: "Value for 'schema_name' did not match the name in the schema definition"
"404":
description: "Invalid path string"
"500":
description: "A database error occurred in `cmgr` (currently includes bad build identifiers)."
"204":
description: "Indicates schema updated successfully"
delete:
tags: [schemas]
produces: ["application/json"]
summary: "Deletes a schema and all of its associated builds and instances"
responses:
"404":
description: "Invalid path string"
"500":
description: "A database error occurred in `cmgr`"
"204":
description: "Indicates successfully removed"
definitions:
ChallengeListElement:
type: "object"
properties:
id:
type: string
source_checksum:
type: integer
format: int64
metadata_checksum:
type: integer
format: int64
solve_script:
type: boolean
ChallengeMetadata:
type: "object"
properties:
id:
type: string
name:
type: string
namespace:
type: string
challenge_type:
type: string
description:
type: string
details:
type: string
hints:
type: array
items:
type: string
source_checksum:
type: integer
format: int64
metadata_checksum:
type: integer
format: int64
path:
type: string
templatable:
type: boolean
port_map:
type: object
additionalProperties:
type: integer
format: int32
max_users:
type: integer
format: int32
category:
type: string
points:
type: integer
format: int32
tags:
type: array
items:
type: string
attributes:
type: object
additionalProperties:
type: string
solve_script:
type: boolean
builds:
type: array
items:
$ref: "#/definitions/BuildMetadata"
BuildMetadata:
type: object
properties:
id:
type: integer
format: int64
flag:
type: string
lookup_data:
type: object
additionalProperties:
type: string
seed:
type: integer
format: int32
format:
type: string
images:
type: array
items:
$ref: "#/definitions/Image"
has_artifacts:
type: boolean
last_solved:
type: integer
format: int64
challenge:
type: string
instances:
type: array
items:
$ref: "#/definitions/InstanceMetadata"
Image:
type: object
properties:
id:
type: integer
format: int64
docker_id:
type: string
ports:
type: array
items:
type: string
build:
type: integer
format: int64
InstanceMetadata:
type: object
properties:
id:
type: integer
format: int64
ports:
type: object
additionalProperties:
type: string
containers:
type: array
items:
type: string
last_solve:
type: integer
format: int64
build:
type: integer
format: int64
network:
type: string
BuildChallengeRequest:
type: object
properties:
flag_format:
type: string
seeds:
type: array
items:
type: integer
format: int32
SchemaDefinition:
type: object
properties:
name:
type: string
flag_format:
type: string
challenges:
type: object
additionalProperties:
$ref: "#/definitions/SchemaElement"
SchemaElement:
type: object
properties:
seeds:
type: array
items:
type: integer
format: int32
instance_count:
type: integer
format: int32