Skip to content

Commit fc39866

Browse files
committed
feat: add generated documentation
1 parent 741b1a9 commit fc39866

File tree

11 files changed

+426
-9
lines changed

11 files changed

+426
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Terraform is used to manage resources that have lifecycles, configurations, to s
2323
That is the case of CTFd: it handles challenges that could be created, modified and deleted.
2424
With some work to leverage the unsteady CTFd's API, Terraform is now able to manage them as cloud resources bringing you to opportunity of **CTF as Code**.
2525

26-
It avoids shitty scripts, `ctfcli` and other tools that does not solve the problem of reproductibility, ease of deployment and resiliency.
26+
With a paradigm-shifting vision of setting up CTFs, the Terraform Provider for CTFd avoid shitty scripts, `ctfcli` and other tools that does not solve the problem of reproductibility, ease of deployment and resiliency.
2727

2828
## How to use it ?
2929

docs/data-sources/challenges.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "ctfd_challenges Data Source - terraform-provider-ctfd"
4+
subcategory: ""
5+
description: |-
6+
7+
---
8+
9+
# ctfd_challenges (Data Source)
10+
11+
12+
13+
14+
15+
<!-- schema generated by tfplugindocs -->
16+
## Schema
17+
18+
### Read-Only
19+
20+
- `challenges` (Attributes List) (see [below for nested schema](#nestedatt--challenges))
21+
- `id` (String) The ID of this resource.
22+
23+
<a id="nestedatt--challenges"></a>
24+
### Nested Schema for `challenges`
25+
26+
Read-Only:
27+
28+
- `category` (String) Category of the challenge that CTFd groups by on the web UI.
29+
- `connection_info` (String) Connection Information to connect to the challenge instance, usefull for pwn or web pentest.
30+
- `decay` (Number)
31+
- `description` (String) Description of the challenge, consider using multiline descriptions for better style.
32+
- `files` (Attributes List) List of files given to players to flag the challenge. (see [below for nested schema](#nestedatt--challenges--files))
33+
- `flags` (Attributes List) List of challenge flags that solves it. (see [below for nested schema](#nestedatt--challenges--flags))
34+
- `function` (String) Decay function to define how the challenge value evolve through solves, either linear or logarithmic.
35+
- `hints` (Attributes List) List of hints about the challenge displayed to the end-user. (see [below for nested schema](#nestedatt--challenges--hints))
36+
- `id` (String) Identifier of the challenge.
37+
- `initial` (Number)
38+
- `max_attempts` (Number) Maximum amount of attempts before being unable to flag the challenge.
39+
- `minimum` (Number)
40+
- `name` (String) Name of the challenge, displayed as it.
41+
- `requirements` (Attributes) List of required challenges that needs to get flagged before this one being accessible. Usefull for skill-trees-like strategy CTF. (see [below for nested schema](#nestedatt--challenges--requirements))
42+
- `state` (String) State of the challenge, either hidden or visible.
43+
- `tags` (List of String) List of challenge tags that will be displayed to the end-user. You could use them to give some quick insights of what a challenge involves.
44+
- `topics` (List of String) List of challenge topics that are displayed to the administrators for maintenance and planification.
45+
- `type` (String) Type of the challenge defining its layout, either standard or dynamic.
46+
- `value` (Number)
47+
48+
<a id="nestedatt--challenges--files"></a>
49+
### Nested Schema for `challenges.files`
50+
51+
Read-Only:
52+
53+
- `content` (String)
54+
- `contentb64` (String)
55+
- `id` (String)
56+
- `location` (String)
57+
- `name` (String)
58+
59+
60+
<a id="nestedatt--challenges--flags"></a>
61+
### Nested Schema for `challenges.flags`
62+
63+
Read-Only:
64+
65+
- `content` (String)
66+
- `data` (String)
67+
- `id` (String)
68+
- `type` (String)
69+
70+
71+
<a id="nestedatt--challenges--hints"></a>
72+
### Nested Schema for `challenges.hints`
73+
74+
Read-Only:
75+
76+
- `content` (String)
77+
- `cost` (Number)
78+
- `id` (String)
79+
- `requirements` (List of String)
80+
81+
82+
<a id="nestedatt--challenges--requirements"></a>
83+
### Nested Schema for `challenges.requirements`
84+
85+
Read-Only:
86+
87+
- `behavior` (String) Behavior if not unlocked, either hidden or anonymized.
88+
- `prerequisites` (List of String) List of the challenges ID.

docs/index.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "ctfd Provider"
4+
subcategory: ""
5+
description: |-
6+
Interact with a CTFd https://github.com/ctfd/ctfd.
7+
---
8+
9+
# ctfd Provider
10+
11+
Interact with a [CTFd](https://github.com/ctfd/ctfd).
12+
13+
## Example Usage
14+
15+
```terraform
16+
provider "ctfd" {
17+
url = "https://my-ctfd.lan"
18+
api_key = "ctfd_somerandomvalue"
19+
}
20+
```
21+
22+
<!-- schema generated by tfplugindocs -->
23+
## Schema
24+
25+
### Optional
26+
27+
- `api_key` (String, Sensitive) User API key. Could use `CTFD_API_KEY` environment variable instead. Despite being the most convenient way to authenticate yourself, we do not recommend it as you will probably generate a long-live token without any rotation policy.
28+
- `nonce` (String, Sensitive) User session nonce, comes with session. Could use `CTFD_NONCE` environment variable instead.
29+
- `session` (String, Sensitive) User session token, comes with nonce. Could use `CTFD_SESSION` environment variable instead.
30+
- `url` (String) CTFd base URL (e.g. `https://my-ctf.lan`). Could use `CTFD_URL` environment variable instead.

docs/resources/challenge.md

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "ctfd_challenge Resource - terraform-provider-ctfd"
4+
subcategory: ""
5+
description: |-
6+
7+
---
8+
9+
# ctfd_challenge (Resource)
10+
11+
12+
13+
## Example Usage
14+
15+
```terraform
16+
resource "ctfd_challenge" "http" {
17+
name = "HTTP Authentication"
18+
category = "network"
19+
description = <<-EOT
20+
Oh no ! I did not see my connection was no encrypted !
21+
I hope no one spied me...
22+
23+
Authors:
24+
- NicolasFgrx
25+
EOT
26+
value = 500
27+
initial = 500
28+
decay = 17
29+
minimum = 50
30+
state = "visible"
31+
function = "logarithmic"
32+
33+
flags = [{
34+
content = "24HIUT{Http_1s_n0t_s3cuR3}"
35+
}]
36+
37+
topics = [
38+
"Network"
39+
]
40+
tags = [
41+
"network",
42+
"http"
43+
]
44+
45+
hints = [{
46+
content = "HTTP exchanges are not ciphered."
47+
cost = 50
48+
}, {
49+
content = "Content is POSTed in HTTP :)"
50+
cost = 50
51+
}]
52+
53+
files = [{
54+
name = "capture.pcapng"
55+
contentb64 = filebase64("${path.module}/capture.pcapng")
56+
}]
57+
}
58+
```
59+
60+
<!-- schema generated by tfplugindocs -->
61+
## Schema
62+
63+
### Required
64+
65+
- `category` (String) Category of the challenge that CTFd groups by on the web UI.
66+
- `description` (String) Description of the challenge, consider using multiline descriptions for better style.
67+
- `name` (String) Name of the challenge, displayed as it.
68+
69+
### Optional
70+
71+
- `connection_info` (String) Connection Information to connect to the challenge instance, usefull for pwn or web pentest.
72+
- `decay` (Number)
73+
- `files` (Attributes List) List of files given to players to flag the challenge. (see [below for nested schema](#nestedatt--files))
74+
- `flags` (Attributes List) List of challenge flags that solves it. (see [below for nested schema](#nestedatt--flags))
75+
- `function` (String) Decay function to define how the challenge value evolve through solves, either linear or logarithmic.
76+
- `hints` (Attributes List) List of hints about the challenge displayed to the end-user. (see [below for nested schema](#nestedatt--hints))
77+
- `initial` (Number)
78+
- `max_attempts` (Number) Maximum amount of attempts before being unable to flag the challenge.
79+
- `minimum` (Number)
80+
- `requirements` (Attributes) List of required challenges that needs to get flagged before this one being accessible. Usefull for skill-trees-like strategy CTF. (see [below for nested schema](#nestedatt--requirements))
81+
- `state` (String) State of the challenge, either hidden or visible.
82+
- `tags` (List of String) List of challenge tags that will be displayed to the end-user. You could use them to give some quick insights of what a challenge involves.
83+
- `topics` (List of String) List of challenge topics that are displayed to the administrators for maintenance and planification.
84+
- `type` (String) Type of the challenge defining its layout, either standard or dynamic.
85+
- `value` (Number)
86+
87+
### Read-Only
88+
89+
- `id` (String) Identifier of the challenge.
90+
91+
<a id="nestedatt--files"></a>
92+
### Nested Schema for `files`
93+
94+
Required:
95+
96+
- `name` (String) Name of the file as displayed to end-users.
97+
98+
Optional:
99+
100+
- `content` (String, Sensitive) Raw content of the file, perfectly fit the use-cases of a .txt document or anything with a simple binary content. You could provide it from the file-system using `file("${path.module}/...")`.
101+
- `contentb64` (String, Sensitive) Base 64 content of the file, perfectly fit the use-cases of complex binaries. You could provide it from the file-system using `filebase64("${path.module}/...")`.
102+
103+
Read-Only:
104+
105+
- `id` (String) Identifier of the file, used internally to handle the CTFd corresponding object.
106+
- `location` (String) Location where the file is stored on the CTFd instance, for download purposes.
107+
108+
109+
<a id="nestedatt--flags"></a>
110+
### Nested Schema for `flags`
111+
112+
Required:
113+
114+
- `content` (String, Sensitive) The actual flag to match. Consider using the convention `MYCTF{value}` with `MYCTF` being the shortcode of your event's name and `value` depending on each challenge.
115+
116+
Optional:
117+
118+
- `data` (String) The flag sensitivity information, either case_sensitive or case_insensitive
119+
- `type` (String) The type of the flag, could be either static or regex
120+
121+
Read-Only:
122+
123+
- `id` (String) Identifier of the flag, used internally to handle the CTFd corresponding object.
124+
125+
126+
<a id="nestedatt--hints"></a>
127+
### Nested Schema for `hints`
128+
129+
Required:
130+
131+
- `content` (String) Content of the hint as displayed to the end-user.
132+
133+
Optional:
134+
135+
- `cost` (Number) Cost of the hint, and if any specified, the end-user will consume its own (or team) points to get it.
136+
- `requirements` (List of String) Other hints required to be consumed before getting this one. Usefull for cost-increasing hint strategies with more and more help.
137+
138+
Read-Only:
139+
140+
- `id` (String) Identifier of the hint, used internally to handle the CTFd corresponding object.
141+
142+
143+
<a id="nestedatt--requirements"></a>
144+
### Nested Schema for `requirements`
145+
146+
Optional:
147+
148+
- `behavior` (String) Behavior if not unlocked, either hidden or anonymized.
149+
- `prerequisites` (List of String) List of the challenges ID.
150+
151+
## Import
152+
153+
Import is supported using the following syntax:
154+
155+
```shell
156+
# Challenge can be imported by the CTFd ID (check URLs)
157+
terraform import ctfd_challenge.http 1
158+
```

examples/provider/provider.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
provider "ctfd" {
2+
url = "https://my-ctfd.lan"
3+
api_key = "ctfd_somerandomvalue"
4+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Challenge can be imported by the CTFd ID (check URLs)
2+
terraform import ctfd_challenge.http 1
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
resource "ctfd_challenge" "http" {
2+
name = "HTTP Authentication"
3+
category = "network"
4+
description = <<-EOT
5+
Oh no ! I did not see my connection was no encrypted !
6+
I hope no one spied me...
7+
8+
Authors:
9+
- NicolasFgrx
10+
EOT
11+
value = 500
12+
initial = 500
13+
decay = 17
14+
minimum = 50
15+
state = "visible"
16+
function = "logarithmic"
17+
18+
flags = [{
19+
content = "24HIUT{Http_1s_n0t_s3cuR3}"
20+
}]
21+
22+
topics = [
23+
"Network"
24+
]
25+
tags = [
26+
"network",
27+
"http"
28+
]
29+
30+
hints = [{
31+
content = "HTTP exchanges are not ciphered."
32+
cost = 50
33+
}, {
34+
content = "Content is POSTed in HTTP :)"
35+
cost = 50
36+
}]
37+
38+
files = [{
39+
name = "capture.pcapng"
40+
contentb64 = filebase64("${path.module}/capture.pcapng")
41+
}]
42+
}

go.mod

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,29 @@ go 1.21.3
44

55
require (
66
github.com/ctfer-io/go-ctfd v0.3.7
7+
github.com/hashicorp/terraform-plugin-docs v0.16.0
78
github.com/hashicorp/terraform-plugin-framework v1.4.2
89
github.com/hashicorp/terraform-plugin-go v0.19.1
910
github.com/hashicorp/terraform-plugin-log v0.9.0
1011
github.com/hashicorp/terraform-plugin-testing v1.6.0
1112
)
1213

1314
require (
15+
github.com/Masterminds/goutils v1.1.1 // indirect
16+
github.com/Masterminds/semver/v3 v3.1.1 // indirect
17+
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
1418
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
1519
github.com/agext/levenshtein v1.2.2 // indirect
1620
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
21+
github.com/armon/go-radix v1.0.0 // indirect
22+
github.com/bgentry/speakeasy v0.1.0 // indirect
1723
github.com/cloudflare/circl v1.3.3 // indirect
1824
github.com/fatih/color v1.13.0 // indirect
1925
github.com/golang/protobuf v1.5.3 // indirect
2026
github.com/google/go-cmp v0.6.0 // indirect
27+
github.com/google/uuid v1.3.1 // indirect
2128
github.com/gorilla/schema v1.2.1 // indirect
22-
github.com/hashicorp/errwrap v1.0.0 // indirect
29+
github.com/hashicorp/errwrap v1.1.0 // indirect
2330
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
2431
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
2532
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
@@ -37,15 +44,22 @@ require (
3744
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
3845
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
3946
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
40-
github.com/mattn/go-colorable v0.1.12 // indirect
41-
github.com/mattn/go-isatty v0.0.14 // indirect
47+
github.com/huandu/xstrings v1.3.2 // indirect
48+
github.com/imdario/mergo v0.3.15 // indirect
49+
github.com/mattn/go-colorable v0.1.13 // indirect
50+
github.com/mattn/go-isatty v0.0.16 // indirect
51+
github.com/mitchellh/cli v1.1.5 // indirect
4252
github.com/mitchellh/copystructure v1.2.0 // indirect
4353
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
4454
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
4555
github.com/mitchellh/mapstructure v1.5.0 // indirect
4656
github.com/mitchellh/reflectwalk v1.0.2 // indirect
4757
github.com/oklog/run v1.0.0 // indirect
4858
github.com/pkg/errors v0.9.1 // indirect
59+
github.com/posener/complete v1.2.3 // indirect
60+
github.com/russross/blackfriday v1.6.0 // indirect
61+
github.com/shopspring/decimal v1.3.1 // indirect
62+
github.com/spf13/cast v1.5.0 // indirect
4963
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
5064
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
5165
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect

0 commit comments

Comments
 (0)