From 03a97ecb5cd4782c29ff85e4bb4048590a0e8841 Mon Sep 17 00:00:00 2001 From: Lucas TESSON Date: Tue, 9 Apr 2024 14:13:46 +0200 Subject: [PATCH] docs(examples): fmt HCL, generic resources examples --- .../provider-install-verification/main.tf | 160 ++++++++---------- examples/resources/ctfd_challenge/resource.tf | 30 ++-- examples/resources/ctfd_user/resource.tf | 1 - 3 files changed, 85 insertions(+), 106 deletions(-) diff --git a/examples/provider-install-verification/main.tf b/examples/provider-install-verification/main.tf index 7e20e97..9c7e445 100644 --- a/examples/provider-install-verification/main.tf +++ b/examples/provider-install-verification/main.tf @@ -1,62 +1,62 @@ terraform { - required_providers { - ctfd = { - source = "registry.terraform.io/ctfer-io/ctfd" - } + required_providers { + ctfd = { + source = "registry.terraform.io/ctfer-io/ctfd" } + } } provider "ctfd" { - url = "http://localhost:8080" + url = "http://localhost:8080" } resource "ctfd_challenge" "http" { - name = "HTTP Authentication" - category = "network" - description = <<-EOT + name = "HTTP Authentication" + category = "network" + description = <<-EOT Oh non ! Je n'avais pas vu que ma connexion n'était pas chiffrée ! J'espère que personne ne m'espionnait... Authors: - NicolasFgrx EOT - value = 500 - initial = 500 - decay = 17 - minimum = 50 - state = "visible" - function = "logarithmic" - - flags = [{ - content = "24HIUT{Http_1s_n0t_s3cuR3}" - }] - - topics = [ - "Network" - ] - tags = [ - "network", - "http" - ] - - hints = [{ - content = "Les flux http ne sont pas chiffrés" - cost = 50 + value = 500 + initial = 500 + decay = 17 + minimum = 50 + state = "visible" + function = "logarithmic" + + flags = [{ + content = "24HIUT{Http_1s_n0t_s3cuR3}" + }] + + topics = [ + "Network" + ] + tags = [ + "network", + "http" + ] + + hints = [{ + content = "Les flux http ne sont pas chiffrés" + cost = 50 }, { - content = "Les informations sont POSTées en HTTP :)" - cost = 50 - }] - - files = [{ - name = "capture.pcapng" - contentb64 = filebase64("${path.module}/capture.pcapng") - }] + content = "Les informations sont POSTées en HTTP :)" + cost = 50 + }] + + files = [{ + name = "capture.pcapng" + contentb64 = filebase64("${path.module}/capture.pcapng") + }] } resource "ctfd_challenge" "icmp" { - name = "Stealing data" - category = "network" - description = <<-EOT + name = "Stealing data" + category = "network" + description = <<-EOT L'administrateur réseau vient de nous signaler que des flux étranges étaient à destination d'un serveur. Visiblement, il s'agit d'un serveur interne. Vous pouvez nous dire de quoi il s'agit ? @@ -65,51 +65,37 @@ resource "ctfd_challenge" "icmp" { Authors: - NicolasFgrx EOT - // TODO find a way to avoid this shitty pattern (either with type="static" or with type="dynamic") - value = 500 - initial = 500 - decay = 17 - minimum = 50 - state = "visible" - requirements = { - behavior = "anonymized" - prerequisites = [ctfd_challenge.http.id] - } - - flags = [{ - content = "24HIUT{IcmpExfiltrationIsEasy}" - }] - - topics = [ - "Network" - ] - tags = [ - "network", - "icmp" - ] - - hints = [{ - content = "Vous ne trouvez pas qu'il ya beaucoup de requêtes ICMP ?" - cost = 50 + value = 500 + decay = 17 + minimum = 50 + state = "visible" + requirements = { + behavior = "anonymized" + prerequisites = [ctfd_challenge.http.id] + } + + flags = [{ + content = "24HIUT{IcmpExfiltrationIsEasy}" + }] + + topics = [ + "Network" + ] + tags = [ + "network", + "icmp" + ] + + hints = [{ + content = "Vous ne trouvez pas qu'il ya beaucoup de requêtes ICMP ?" + cost = 50 }, { - content = "Pour l'exo, le ttl a été modifié, tente un `ip.ttl<=20`" - cost = 50 - }] - - files = [{ - name = "icmp.pcap" - # content = file("${path.module}/icmp.pcap") - contentb64 = filebase64("${path.module}/icmp.pcap") - }] + content = "Pour l'exo, le ttl a été modifié, tente un `ip.ttl<=20`" + cost = 50 + }] + + files = [{ + name = "icmp.pcap" + contentb64 = filebase64("${path.module}/icmp.pcap") + }] } - -# resource "ctfd_flag" "some_flag" { -# challenge = ctfd_challenge.icmp.id -# content = "24HIUT{IcmpExfiltrationIsEasy-gg}" -# } - -# data "ctfd_challenges" "all" {} - -# output "all_challenges" { -# value = data.ctfd_challenges.all -# } diff --git a/examples/resources/ctfd_challenge/resource.tf b/examples/resources/ctfd_challenge/resource.tf index a479b42..2f50963 100644 --- a/examples/resources/ctfd_challenge/resource.tf +++ b/examples/resources/ctfd_challenge/resource.tf @@ -1,42 +1,36 @@ resource "ctfd_challenge" "http" { - name = "HTTP Authentication" - category = "network" - description = <<-EOT - Oh no ! I did not see my connection was no encrypted ! - I hope no one spied me... - - Authors: - - NicolasFgrx - EOT + name = "My Challenge" + category = "misc" + description = "..." value = 500 initial = 500 - decay = 17 + decay = 100 minimum = 50 state = "visible" function = "logarithmic" flags = [{ - content = "24HIUT{Http_1s_n0t_s3cuR3}" + content = "CTF{some_flag}" }] topics = [ - "Network" + "Misc" ] tags = [ - "network", - "http" + "misc", + "basic" ] hints = [{ - content = "HTTP exchanges are not ciphered." + content = "Some super-helpful hint" cost = 50 }, { - content = "Content is POSTed in HTTP :)" + content = "Even more helpful hint !" cost = 50 }] files = [{ - name = "capture.pcapng" - contentb64 = filebase64("${path.module}/capture.pcapng") + name = "image.png" + contentb64 = filebase64("${path.module}/image.png") }] } diff --git a/examples/resources/ctfd_user/resource.tf b/examples/resources/ctfd_user/resource.tf index 5346409..6499886 100644 --- a/examples/resources/ctfd_user/resource.tf +++ b/examples/resources/ctfd_user/resource.tf @@ -3,7 +3,6 @@ resource "ctfd_user" "ctfer" { email = "ctfer-io@protonmail.com" password = "password" - # Define as an administration account type = "admin" verified = true hidden = true