-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(challenge)!: split
ctfd_challenge
in two separate resources
- Loading branch information
Showing
19 changed files
with
1,038 additions
and
336 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "ctfd_challenges_standard Data Source - terraform-provider-ctfd" | ||
subcategory: "" | ||
description: |- | ||
--- | ||
|
||
# ctfd_challenges_standard (Data Source) | ||
|
||
|
||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Read-Only | ||
|
||
- `challenges` (Attributes List) (see [below for nested schema](#nestedatt--challenges)) | ||
- `id` (String) The ID of this resource. | ||
|
||
<a id="nestedatt--challenges"></a> | ||
### Nested Schema for `challenges` | ||
|
||
Read-Only: | ||
|
||
- `category` (String) Category of the challenge that CTFd groups by on the web UI. | ||
- `connection_info` (String) Connection Information to connect to the challenge instance, useful for pwn or web pentest. | ||
- `description` (String) Description of the challenge, consider using multiline descriptions for better style. | ||
- `id` (String) Identifier of the challenge. | ||
- `max_attempts` (Number) Maximum amount of attempts before being unable to flag the challenge. | ||
- `name` (String) Name of the challenge, displayed as it. | ||
- `next` (Number) Suggestion for the end-user as next challenge to work on. | ||
- `requirements` (Attributes) List of required challenges that needs to get flagged before this one being accessible. Useful for skill-trees-like strategy CTF. (see [below for nested schema](#nestedatt--challenges--requirements)) | ||
- `state` (String) State of the challenge, either hidden or visible. | ||
- `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. | ||
- `topics` (List of String) List of challenge topics that are displayed to the administrators for maintenance and planification. | ||
- `value` (Number) | ||
|
||
<a id="nestedatt--challenges--requirements"></a> | ||
### Nested Schema for `challenges.requirements` | ||
|
||
Read-Only: | ||
|
||
- `behavior` (String) Behavior if not unlocked, either hidden or anonymized. | ||
- `prerequisites` (List of String) List of the challenges ID. |
60 changes: 7 additions & 53 deletions
60
docs/resources/challenge.md → docs/resources/challenge_dynamic.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "ctfd_challenge_standard Resource - terraform-provider-ctfd" | ||
subcategory: "" | ||
description: |- | ||
CTFd is built around the Challenge resource, which contains all the attributes to define a part of the Capture The Flag event. | ||
It is the first historic implementation of its kind, with basic functionalities. | ||
--- | ||
|
||
# ctfd_challenge_standard (Resource) | ||
|
||
CTFd is built around the Challenge resource, which contains all the attributes to define a part of the Capture The Flag event. | ||
|
||
It is the first historic implementation of its kind, with basic functionalities. | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `category` (String) Category of the challenge that CTFd groups by on the web UI. | ||
- `description` (String) Description of the challenge, consider using multiline descriptions for better style. | ||
- `name` (String) Name of the challenge, displayed as it. | ||
- `value` (Number) The value (points) of the challenge once solved. | ||
|
||
### Optional | ||
|
||
- `connection_info` (String) Connection Information to connect to the challenge instance, useful for pwn, web and infrastructure pentests. | ||
- `max_attempts` (Number) Maximum amount of attempts before being unable to flag the challenge. | ||
- `next` (Number) Suggestion for the end-user as next challenge to work on. | ||
- `requirements` (Attributes) List of required challenges that needs to get flagged before this one being accessible. Useful for skill-trees-like strategy CTF. (see [below for nested schema](#nestedatt--requirements)) | ||
- `state` (String) State of the challenge, either hidden or visible. | ||
- `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. | ||
- `topics` (List of String) List of challenge topics that are displayed to the administrators for maintenance and planification. | ||
|
||
### Read-Only | ||
|
||
- `id` (String) Identifier of the challenge. | ||
|
||
<a id="nestedatt--requirements"></a> | ||
### Nested Schema for `requirements` | ||
|
||
Optional: | ||
|
||
- `behavior` (String) Behavior if not unlocked, either hidden or anonymized. | ||
- `prerequisites` (List of String) List of the challenges ID. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package provider | ||
|
||
import ( | ||
"github.com/ctfer-io/terraform-provider-ctfd/provider/utils" | ||
"github.com/hashicorp/terraform-plugin-framework/types" | ||
) | ||
|
||
var ( | ||
BehaviorHidden = types.StringValue("hidden") | ||
BehaviorAnonymized = types.StringValue("anonymized") | ||
|
||
FunctionLinear = types.StringValue("linear") | ||
FunctionLogarithmic = types.StringValue("logarithmic") | ||
) | ||
|
||
type RequirementsSubresourceModel struct { | ||
Behavior types.String `tfsdk:"behavior"` | ||
Prerequisites []types.String `tfsdk:"prerequisites"` | ||
} | ||
|
||
func GetAnon(str types.String) *bool { | ||
switch { | ||
case str.Equal(BehaviorHidden): | ||
return nil | ||
case str.Equal(BehaviorAnonymized): | ||
return utils.Ptr(true) | ||
} | ||
panic("invalid anonymization value: " + str.ValueString()) | ||
} | ||
|
||
func FromAnon(b *bool) types.String { | ||
if b == nil { | ||
return BehaviorHidden | ||
} | ||
if *b { | ||
return BehaviorAnonymized | ||
} | ||
panic("invalid anonymization value, got boolean false") | ||
} |
Oops, something went wrong.