From 6507b36d1e3cd87c3a620505435a9ececb6156d4 Mon Sep 17 00:00:00 2001 From: Jeroen Willemsen Date: Sun, 18 Feb 2024 08:56:00 +0100 Subject: [PATCH 1/4] fix es-lint rules again --- .eslintrc.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 480ce3a7a..7b77cbf7d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -15,9 +15,6 @@ module.exports = { parserOptions: { ecmaVersion: 'latest' }, - rules: { - 'chai-friendly/no-unused-expressions': 'off' - }, plugins: [ 'cypress', 'chai-friendly' From a1a5b8dc745c9fe90c38e53ecb84eb77e8e45fc6 Mon Sep 17 00:00:00 2001 From: Jeroen Willemsen Date: Sun, 18 Feb 2024 09:16:11 +0100 Subject: [PATCH 2/4] removed bugging animation, added contributors --- README.md | 1 + src/main/resources/static/css/style.css | 8 -------- src/main/resources/static/theme-toggle.js | 13 +------------ src/main/resources/templates/welcome.html | 21 +++++++++++++-------- 4 files changed, 15 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 0daf3e9a7..76c8df73e 100644 --- a/README.md +++ b/README.md @@ -289,6 +289,7 @@ Contributors: - [Diamond Rivero @diamant3](https://www.github.com/diamant3) - [Norbert Wolniak @nwolniak](https://www.github.com/nwolniak) - [Adarsh A @adarsh-a-tw](https://www.github.com/adarsh-a-tw) +- [Shubham Patel @Shubham-Patel07](https://www.github.com/Shubham-Patel07) - [Filip Chyla @fchyla](https://www.github.com/fchyla) - [Dmitry Litosh @Dlitosh](https://www.github.com/Dlitosh) - [Vineeth Jagadeesh @djvinnie](https://www.github.com/djvinnie) diff --git a/src/main/resources/static/css/style.css b/src/main/resources/static/css/style.css index 144c27123..379bfc46c 100644 --- a/src/main/resources/static/css/style.css +++ b/src/main/resources/static/css/style.css @@ -102,11 +102,3 @@ tr.solved { .sect2, .thank-you, .toggle-button { border-color: #ffffff; /* Or any color that contrasts well with your light mode background */ } - -.rotate { - transform: rotate(360deg); -} - -.notransition { - transition: none !important; -} diff --git a/src/main/resources/static/theme-toggle.js b/src/main/resources/static/theme-toggle.js index 299ad8ec9..473b9c354 100644 --- a/src/main/resources/static/theme-toggle.js +++ b/src/main/resources/static/theme-toggle.js @@ -7,12 +7,6 @@ label.textContent = darkMode ? '🌙' : '☀️' localStorage.setItem('darkMode', darkMode ? 'true' : 'false') localStorage.setItem('darkmode-pref-set', 'true') - - if (darkMode) { - label.classList.add('rotate') - } else { - label.classList.remove('rotate') - } } function toggleTheme () { @@ -21,15 +15,10 @@ toggle.checked = darkMode } - window.addEventListener('load', () => { + window.addEventListener('DOMContentLoaded', () => { const darkModePref = localStorage.getItem('darkMode') === 'true' applyDarkMode(darkModePref) toggle.checked = darkModePref - - // Prevent the rotate animation on load - label.classList.add('notransition') // Temporarily disable transition - label.offsetHeight // Trigger reflow to apply the transition disable - label.classList.remove('notransition') // Re-enable transitions }) label.onclick = toggleTheme diff --git a/src/main/resources/templates/welcome.html b/src/main/resources/templates/welcome.html index 81a9a8b4f..4c3734335 100644 --- a/src/main/resources/templates/welcome.html +++ b/src/main/resources/templates/welcome.html @@ -56,7 +56,7 @@ - +

-

Hasty? Here is the Vault secret;-)

+

Hasty? Here is the Vault secret;-) +

From 9af4e0701771a7dd4db39184f41ca2b9ea0c1e34 Mon Sep 17 00:00:00 2001 From: Jeroen Willemsen Date: Sun, 18 Feb 2024 10:14:11 +0100 Subject: [PATCH 3/4] Fixing the misconception that there are no challengeas after challenge 6 ;-) --- .../java/org/owasp/wrongsecrets/Challenges.java | 4 ++++ .../challenges/ChallengesController.java | 13 +++++++++---- src/main/resources/explanations/missing_cloud.adoc | 2 ++ src/main/resources/explanations/missing_k8s.adoc | 2 ++ src/main/resources/explanations/missing_vault.adoc | 2 ++ 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/owasp/wrongsecrets/Challenges.java b/src/main/java/org/owasp/wrongsecrets/Challenges.java index b7f719f62..b2ffba8c8 100644 --- a/src/main/java/org/owasp/wrongsecrets/Challenges.java +++ b/src/main/java/org/owasp/wrongsecrets/Challenges.java @@ -88,6 +88,10 @@ public boolean isFirstChallenge(ChallengeDefinition challengeDefinition) { return challengeDefinition.equals(definitions.challenges().get(0)); } + public boolean isLastChallenge(ChallengeDefinition challengeDefinition) { + return challengeDefinition.equals(definitions.challenges().getLast()); + } + public List getChallengeDefinitions() { return definitions.challenges(); } diff --git a/src/main/java/org/owasp/wrongsecrets/challenges/ChallengesController.java b/src/main/java/org/owasp/wrongsecrets/challenges/ChallengesController.java index 3bcbf7cb1..8c9fe0f3d 100644 --- a/src/main/java/org/owasp/wrongsecrets/challenges/ChallengesController.java +++ b/src/main/java/org/owasp/wrongsecrets/challenges/ChallengesController.java @@ -48,7 +48,7 @@ public class ChallengesController { @Value("${ctf_enabled}") private boolean ctfModeEnabled; - private boolean spoilingEnabled; + private final boolean spoilingEnabled; @Value("${ctf_key}") private String ctfKey; @@ -93,7 +93,7 @@ public String spoiler(@PathVariable("short-name") String shortName, Model model) model.addAttribute("spoiler", new Spoiler("Spoils are disabled in the configuration")); } else { Optional spoilerFromRuntimeEnvironment = - challenges.findChallenge(shortName, runtimeEnvironment).map(c -> c.spoiler()); + challenges.findChallenge(shortName, runtimeEnvironment).map(Challenge::spoiler); Supplier spoilerFromRandomChallenge = () -> { var challengeDefinition = findByShortName(shortName); @@ -151,8 +151,13 @@ public String challenge(Model model, @PathVariable("short-name") String shortNam model.addAttribute("answerCorrect", null); model.addAttribute("answerIncorrect", null); model.addAttribute("solution", null); + String clickNext = + "This challenge has been disabled. Click \"next\" to go to the next challenge."; + if (challenges.isLastChallenge(challengeDefinition)) { + clickNext = "This challenge has been disabled"; + } if (!isChallengeEnabled(challengeDefinition)) { - model.addAttribute("answerIncorrect", "This challenge has been disabled."); + model.addAttribute("answerIncorrect", "This challenge has been disabled." + clickNext); } if (ctfModeEnabled && challenges.isFirstChallenge(challengeDefinition)) { if (!Strings.isNullOrEmpty(ctfServerAddress) && !ctfServerAddress.equals("not_set")) { @@ -331,7 +336,7 @@ private void enrichWithHintsAndReasons(Model model) { private void fireEnding(Model model) { var notCompleted = challenges.getDefinitions().challenges().stream() - .filter(def -> isChallengeEnabled(def)) + .filter(this::isChallengeEnabled) .filter(this::challengeNotCompleted) .count(); if (notCompleted == 0) { diff --git a/src/main/resources/explanations/missing_cloud.adoc b/src/main/resources/explanations/missing_cloud.adoc index b1dd9ea29..55884a78c 100644 --- a/src/main/resources/explanations/missing_cloud.adoc +++ b/src/main/resources/explanations/missing_cloud.adoc @@ -1,2 +1,4 @@ We are running outside a properly configured Cloud environment. Please run this in an AWS/Azure/GCP environment as explained in the https://github.com/OWASP/wrongsecrets#cloud-challenges[README.md] + +There are still supported challenges after this one. Please try another challenge instead! diff --git a/src/main/resources/explanations/missing_k8s.adoc b/src/main/resources/explanations/missing_k8s.adoc index 4e7315753..f40e18672 100644 --- a/src/main/resources/explanations/missing_k8s.adoc +++ b/src/main/resources/explanations/missing_k8s.adoc @@ -1,3 +1,5 @@ We are running outside a K8s cluster. Please run this in the K8s cluster as explained in the https://github.com/OWASP/wrongsecrets#basic-k8s-exercise[README.md] + +There are still supported challenges after this one. Please try another challenge instead! diff --git a/src/main/resources/explanations/missing_vault.adoc b/src/main/resources/explanations/missing_vault.adoc index 006e40ad1..384392fa8 100644 --- a/src/main/resources/explanations/missing_vault.adoc +++ b/src/main/resources/explanations/missing_vault.adoc @@ -1,2 +1,4 @@ We are running outside a K8s cluster with Vault. Please run this in the K8s cluster as explained in the https://github.com/OWASP/wrongsecrets#vault-exercises-with-minikube[README.md] + +There might still be supported challenges after this one. Please try another challenge instead! From 0f000032df5b29284a738017e24e4c7c73d2b47a Mon Sep 17 00:00:00 2001 From: Jeroen Willemsen Date: Mon, 19 Feb 2024 09:05:42 +0100 Subject: [PATCH 4/4] Update welcome.html to add missing ul closing tag --- src/main/resources/templates/welcome.html | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/templates/welcome.html b/src/main/resources/templates/welcome.html index 4c3734335..3de7ab2b0 100644 --- a/src/main/resources/templates/welcome.html +++ b/src/main/resources/templates/welcome.html @@ -151,6 +151,7 @@
  • Dan Gora @devsecops
  • Xiaolu Dai @saragluna
  • Jonathan Giles @jonathanGiles
  • +