Skip to content

Commit

Permalink
fix difficulty in mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
commjoen committed Oct 10, 2024
1 parent a7acbe6 commit f696d99
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand All @@ -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()))
Expand Down

0 comments on commit f696d99

Please sign in to comment.