Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes: eslint, broken animation, contributors, and more challenges links #1242

Merged
merged 5 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ module.exports = {
parserOptions: {
ecmaVersion: 'latest'
},
rules: {
'chai-friendly/no-unused-expressions': 'off'
},
plugins: [
'cypress',
'chai-friendly'
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/owasp/wrongsecrets/Challenges.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<ChallengeDefinition> getChallengeDefinitions() {
return definitions.challenges();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Spoiler> spoilerFromRuntimeEnvironment =
challenges.findChallenge(shortName, runtimeEnvironment).map(c -> c.spoiler());
challenges.findChallenge(shortName, runtimeEnvironment).map(Challenge::spoiler);
Supplier<Spoiler> spoilerFromRandomChallenge =
() -> {
var challengeDefinition = findByShortName(shortName);
Expand Down Expand Up @@ -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")) {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/explanations/missing_cloud.adoc
Original file line number Diff line number Diff line change
@@ -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!
2 changes: 2 additions & 0 deletions src/main/resources/explanations/missing_k8s.adoc
Original file line number Diff line number Diff line change
@@ -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!
2 changes: 2 additions & 0 deletions src/main/resources/explanations/missing_vault.adoc
Original file line number Diff line number Diff line change
@@ -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!
8 changes: 0 additions & 8 deletions src/main/resources/static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
13 changes: 1 addition & 12 deletions src/main/resources/static/theme-toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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
Expand Down
20 changes: 13 additions & 7 deletions src/main/resources/templates/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<td th:text="${challenge.tech}"></td>
<td class="d-none d-md-table-cell" th:text="${challenge.starsOnScale}"></td>
<td th:text="${challenge.runtimeEnvironmentCategory}">
</td>
</td>
<td class="d-none d-xl-table-cell">
<span
th:if="${challenge.challengeCompleted}"
Expand All @@ -73,7 +73,8 @@
th:text="'Scoring and progress keeping is disabled in CTF mode, have a look at '+${ctfServerAddress}+' for your actual score and progress'"
></p>
<!-- <p th:text="'You are currently running on the following environment: '+${environment}"></p>-->
<p>Hasty? Here is the Vault <a href="spoil/challenge-7" data-cy="show-secret-spoiler-link">secret;-)</a></p>
<p>Hasty? Here is the Vault <a href="spoil/challenge-7" data-cy="show-secret-spoiler-link">secret;-)</a>
</p>
</div>
<div class="col-12 col-lg-4 offset-lg-1">
<div class="border border-dark thank-you text-center">
Expand Down Expand Up @@ -112,22 +113,23 @@
<li><a href='https://www.github.com/osamamagdy'>Osama Magdy @osamamagdy</a></li>
<li><a href='https://www.github.com/Novice-expert'>Divyanshu Dev @Novice-expert</a></li>
<li><a href='https://www.github.com/tiborhercz'>Tibor Hercz @tiborhercz</a></li>
<li><a href='https://www.github.com/za'>za @za</a></li>
<li><a href='https://www.github.com/neatzsche'>Chris Elbring Jr. @neatzsche</a></li>
<li><a href='https://www.github.com/diamant3'>Diamond Rivero @diamant3</a></li>
<li><a href='https://www.github.com/nwolniak'>Norbert Wolniak @nwolniak</a></li>
<li><a href='https://www.github.com/adarsh-a-tw'>Adarsh A @adarsh-a-tw</a></li>
<li><a href='https://www.github.com/Shubham-Patel07'>Shubham Patel @Shubham-Patel07</a></li>
<li><a href='https://www.github.com/fchyla'>Filip Chyla @fchyla</a></li>
<li><a href='https://www.github.com/nwolniak'>Norbert Wolniak @nwolniak</a></li>
<li><a href='https://www.github.com/turjoc120'>Turjo Chowdhury @turjoc120</a></li>
<li><a href='https://www.github.com/djvinnie'>Vineeth Jagadeesh @djvinnie</a></li>
<li><a href='https://www.github.com/Dlitosh'>Dmitry Litosh @Dlitosh</a></li>
<li><a href='https://www.github.com/djvinnie'>Vineeth Jagadeesh @djvinnie</a></li>
<li><a href='https://www.github.com/turjoc120'>Turjo Chowdhury @turjoc120</a></li>
<li><a href='https://www.github.com/tghosth'>Josh Grossman @tghosth</a></li>
<li><a href='https://www.github.com/alphasecio'>alphasec @alphasecio</a></li>
<li><a href='https://www.github.com/CaduRoriz'>CaduRoriz @CaduRoriz</a></li>
<li><a href='https://www.github.com/madhuakula'>Madhu Akula @madhuakula</a></li>
<li><a href='https://www.github.com/mikewoudenberg'>Mike Woudenberg @mikewoudenberg</a></li>
<li><a href='https://www.github.com/northdpole'>Spyros @northdpole</a></li>
<li><a href='https://www.github.com/RubenAtBinx'>RubenAtBinx @RubenAtBinx</a></li>
<li><a href='https://www.github.com/za'>za @za</a></li>
<li><a href='https://www.github.com/alex-bender'>Alex Bender @alex-bender</a></li>
<li><a href='https://www.github.com/nhumblot'>Nicolas Humblot @nhumblot</a></li>
<li><a href='https://www.github.com/kingthorin'>Rick M @kingthorin</a></li>
Expand All @@ -136,7 +138,11 @@
</ul>
Testers:
<ul>
<li><a href='https://www.github.com/davevs'>Dave van Stein @davevs</a></li><li><a href='https://www.github.com/drnow4u'>Marcin Nowak @drnow4u</a></li><li><a href='https://www.github.com/mchangsp'>Marc Chang Sing Pang @mchangsp</a></li><li><a href='https://www.github.com/djvinnie'>Vineeth Jagadeesh @djvinnie</a></li></ul>
<li><a href='https://www.github.com/davevs'>Dave van Stein @davevs</a></li>
<li><a href='https://www.github.com/drnow4u'>Marcin Nowak @drnow4u</a></li>
<li><a href='https://www.github.com/mchangsp'>Marc Chang Sing Pang @mchangsp</a></li>
<li><a href='https://www.github.com/djvinnie'>Vineeth Jagadeesh @djvinnie</a></li>
</ul>
Special mentions for helping out:
<ul>
<li><a href='https://www.github.com/madhuakula'>Madhu Akula @madhuakula @madhuakula</a></li>
Expand Down
Loading