Skip to content

Commit

Permalink
chore: doc, cleanup, minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pandatix committed Jun 2, 2024
1 parent 45df43e commit 778134c
Show file tree
Hide file tree
Showing 21 changed files with 410 additions and 256 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.PHONY: test-acc
test-acc:
TF_ACC=1 \
go test ./provider/ -v -run=^TestAcc_ -count=1 -coverprofile=cov.out -coverpkg "github.com/ctfer-io/terraform-provider-ctfd/provider,github.com/ctfer-io/terraform-provider-ctfd/provider/challenge,github.com/ctfer-io/terraform-provider-ctfd/provider/utils,github.com/ctfer-io/terraform-provider-ctfd/provider/validators"
go test ./provider/ -v -run=^TestAcc_ -count=1 -coverprofile=cov.out -coverpkg "github.com/ctfer-io/terraform-provider-ctfd/provider,github.com/ctfer-io/terraform-provider-ctfd/provider/utils,github.com/ctfer-io/terraform-provider-ctfd/provider/validators"

.PHONY: docs
docs:
Expand Down
37 changes: 0 additions & 37 deletions docs/data-sources/challenges.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ Read-Only:
- `connection_info` (String) Connection Information to connect to the challenge instance, useful for pwn or web pentest.
- `decay` (Number)
- `description` (String) Description of the challenge, consider using multiline descriptions for better style.
- `files` (Attributes List) List of files given to players to flag the challenge. (see [below for nested schema](#nestedatt--challenges--files))
- `flags` (Attributes List) List of challenge flags that solves it. (see [below for nested schema](#nestedatt--challenges--flags))
- `function` (String) Decay function to define how the challenge value evolve through solves, either linear or logarithmic.
- `hints` (Attributes List) List of hints about the challenge displayed to the end-user. (see [below for nested schema](#nestedatt--challenges--hints))
- `id` (String) Identifier of the challenge.
- `max_attempts` (Number) Maximum amount of attempts before being unable to flag the challenge.
- `minimum` (Number)
Expand All @@ -45,40 +42,6 @@ Read-Only:
- `type` (String) Type of the challenge defining its layout, either standard or dynamic.
- `value` (Number)

<a id="nestedatt--challenges--files"></a>
### Nested Schema for `challenges.files`

Read-Only:

- `content` (String)
- `contentb64` (String)
- `id` (String)
- `location` (String)
- `name` (String)


<a id="nestedatt--challenges--flags"></a>
### Nested Schema for `challenges.flags`

Read-Only:

- `content` (String)
- `data` (String)
- `id` (String)
- `type` (String)


<a id="nestedatt--challenges--hints"></a>
### Nested Schema for `challenges.hints`

Read-Only:

- `content` (String)
- `cost` (Number)
- `id` (String)
- `requirements` (List of String)


<a id="nestedatt--challenges--requirements"></a>
### Nested Schema for `challenges.requirements`

Expand Down
95 changes: 23 additions & 72 deletions docs/resources/challenge.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,37 @@ resource "ctfd_challenge" "http" {
state = "visible"
function = "logarithmic"
flags = [{
content = "CTF{some_flag}"
}]
topics = [
"Misc"
]
tags = [
"misc",
"basic"
]
}
hints = [{
content = "Some super-helpful hint"
cost = 50
}, {
content = "Even more helpful hint !"
cost = 50
}]
files = [{
name = "image.png"
contentb64 = filebase64(".../image.png")
}]
resource "ctfd_flag" "http_flag" {
challenge_id = ctfd_challenge.http.id
content = "CTF{some_flag}"
}
resource "ctfd_hint" "http_hint_1" {
challenge_id = ctfd_challenge.http.id
content = "Some super-helpful hint"
cost = 50
}
resource "ctfd_hint" "http_hint_2" {
challenge_id = ctfd_challenge.http.id
content = "Even more helpful hint !"
cost = 50
requirements = [ctfd_hint.http_hint_1.id]
}
resource "ctfd_file" "http_file" {
challenge_id = ctfd_challenge.http.id
name = "image.png"
contentb64 = filebase64(".../image.png")
}
```

Expand All @@ -67,10 +74,7 @@ resource "ctfd_challenge" "http" {

- `connection_info` (String) Connection Information to connect to the challenge instance, useful for pwn, web and infrastructure pentests.
- `decay` (Number) The decay defines from each number of solves does the decay function triggers until reaching minimum. This function is defined by CTFd and could be configured through `.function`.
- `files` (Attributes List) List of files given to players to flag the challenge. (see [below for nested schema](#nestedatt--files))
- `flags` (Attributes List) List of challenge flags that solves it. (see [below for nested schema](#nestedatt--flags))
- `function` (String) Decay function to define how the challenge value evolve through solves, either linear or logarithmic.
- `hints` (Attributes List) List of hints about the challenge displayed to the end-user. (see [below for nested schema](#nestedatt--hints))
- `max_attempts` (Number) Maximum amount of attempts before being unable to flag the challenge.
- `minimum` (Number) The minimum points for a dynamic-score challenge to reach with the decay function. Once there, no solve could have more value.
- `next` (Number) Suggestion for the end-user as next challenge to work on.
Expand All @@ -84,59 +88,6 @@ resource "ctfd_challenge" "http" {

- `id` (String) Identifier of the challenge.

<a id="nestedatt--files"></a>
### Nested Schema for `files`

Required:

- `name` (String) Name of the file as displayed to end-users.

Optional:

- `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}/...")`.
- `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}/...")`.
- `location` (String) Location where the file is stored on the CTFd instance, for download purposes.

Read-Only:

- `id` (String) Identifier of the file, used internally to handle the CTFd corresponding object.
- `sha1sum` (String) The sha1 sum of the file.


<a id="nestedatt--flags"></a>
### Nested Schema for `flags`

Required:

- `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.

Optional:

- `data` (String) The flag sensitivity information, either case_sensitive or case_insensitive
- `type` (String) The type of the flag, could be either static or regex

Read-Only:

- `id` (String) Identifier of the flag, used internally to handle the CTFd corresponding object.


<a id="nestedatt--hints"></a>
### Nested Schema for `hints`

Required:

- `content` (String) Content of the hint as displayed to the end-user.

Optional:

- `cost` (Number) Cost of the hint, and if any specified, the end-user will consume its own (or team) points to get it.
- `requirements` (List of String) Other hints required to be consumed before getting this one. Useful for cost-increasing hint strategies with more and more help.

Read-Only:

- `id` (String) Identifier of the hint, used internally to handle the CTFd corresponding object.


<a id="nestedatt--requirements"></a>
### Nested Schema for `requirements`

Expand Down
59 changes: 59 additions & 0 deletions docs/resources/file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "ctfd_file Resource - terraform-provider-ctfd"
subcategory: ""
description: |-
A CTFd file for a challenge.
---

# ctfd_file (Resource)

A CTFd file for a challenge.

## Example Usage

```terraform
resource "ctfd_challenge" "http" {
name = "My Challenge"
category = "misc"
description = "..."
value = 500
decay = 100
minimum = 50
state = "visible"
function = "logarithmic"
topics = [
"Misc"
]
tags = [
"misc",
"basic"
]
}
resource "ctfd_file" "http_file" {
challenge_id = ctfd_challenge.http.id
name = "image.png"
contentb64 = filebase64(".../image.png")
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `challenge_id` (String) Challenge of the file.
- `name` (String) Name of the file as displayed to end-users.

### Optional

- `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}/...")`.
- `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}/...")`.
- `location` (String) Location where the file is stored on the CTFd instance, for download purposes.

### Read-Only

- `id` (String) Identifier of the file, used internally to handle the CTFd corresponding object. WARNING: updating this file does not work, requires full replacement.
- `sha1sum` (String) The sha1 sum of the file.
56 changes: 56 additions & 0 deletions docs/resources/flag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "ctfd_flag Resource - terraform-provider-ctfd"
subcategory: ""
description: |-
A flag to solve the challenge.
---

# ctfd_flag (Resource)

A flag to solve the challenge.

## Example Usage

```terraform
resource "ctfd_challenge" "http" {
name = "My Challenge"
category = "misc"
description = "..."
value = 500
decay = 100
minimum = 50
state = "visible"
function = "logarithmic"
topics = [
"Misc"
]
tags = [
"misc",
"basic"
]
}
resource "ctfd_flag" "http_flag" {
challenge_id = ctfd_challenge.http.id
content = "CTF{some_flag}"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `challenge_id` (String) Challenge of the flag.
- `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.

### Optional

- `data` (String) The flag sensitivity information, either case_sensitive or case_insensitive
- `type` (String) The type of the flag, could be either static or regex

### Read-Only

- `id` (String) Identifier of the flag, used internally to handle the CTFd corresponding object.
69 changes: 69 additions & 0 deletions docs/resources/hint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "ctfd_hint Resource - terraform-provider-ctfd"
subcategory: ""
description: |-
A hint for a challenge to help players solve it.
---

# ctfd_hint (Resource)

A hint for a challenge to help players solve it.

## Example Usage

```terraform
resource "ctfd_challenge" "http" {
name = "My Challenge"
category = "misc"
description = "..."
value = 500
decay = 100
minimum = 50
state = "visible"
function = "logarithmic"
topics = [
"Misc"
]
tags = [
"misc",
"basic"
]
}
resource "ctfd_flag" "http_flag" {
challenge_id = ctfd_challenge.http.id
content = "CTF{some_flag}"
}
resource "ctfd_hint" "http_hint" {
challenge_id = ctfd_challenge.http.id
content = "Some super-helpful hint"
cost = 50
}
resource "ctfd_hint" "http_hint_2" {
challenge_id = ctfd_challenge.http.id
content = "Even more helpful hint !"
cost = 50
requirements = [ctfd_hint.http_hint_1.id]
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `challenge_id` (String) Challenge of the hint.
- `content` (String) Content of the hint as displayed to the end-user.

### Optional

- `cost` (Number) Cost of the hint, and if any specified, the end-user will consume its own (or team) points to get it.
- `requirements` (List of String) List of the other hints it depends on.

### Read-Only

- `id` (String) Identifier of the hint, used internally to handle the CTFd corresponding object.
Loading

0 comments on commit 778134c

Please sign in to comment.