diff --git a/src/main/java/org/owasp/wrongsecrets/challenges/ChallengesCtfController.java b/src/main/java/org/owasp/wrongsecrets/challenges/ChallengesCtfController.java index a44d3bed2..8dc0de5ff 100644 --- a/src/main/java/org/owasp/wrongsecrets/challenges/ChallengesCtfController.java +++ b/src/main/java/org/owasp/wrongsecrets/challenges/ChallengesCtfController.java @@ -10,6 +10,7 @@ import org.owasp.wrongsecrets.ScoreCard; import org.owasp.wrongsecrets.definitions.ChallengeDefinition; import org.owasp.wrongsecrets.definitions.ChallengeDefinitionsConfiguration; +import org.owasp.wrongsecrets.definitions.Difficulty; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @@ -68,7 +69,7 @@ public String getChallenges() { .orElse(disabledChallenge)); jsonChallenge.put("solved", scoreCard.getChallengeCompleted(definition)); jsonChallenge.put("disabledEnv", getDisabledEnv(definition)); - jsonChallenge.put("difficulty", definition.difficulty().difficulty()); + jsonChallenge.put("difficulty", getDificulty(definition.difficulty())); jsonArray.add(jsonChallenge); } json.put("status", "success"); @@ -78,6 +79,23 @@ public String getChallenges() { return result; } + private int getDificulty(Difficulty difficulty) { + switch (difficulty.difficulty()) { + case "easy": + return 1; + case "normal": + return 2; + case "hard": + return 3; + case "expert": + return 4; + case "master": + return 5; + default: + return 0; + } + } + private String getCategory() { return this.wrongSecretsConfiguration.environments().stream() .filter(e -> e.equals(runtimeEnvironment.getRuntimeEnvironment()))