10
10
import org .owasp .wrongsecrets .ScoreCard ;
11
11
import org .owasp .wrongsecrets .definitions .ChallengeDefinition ;
12
12
import org .owasp .wrongsecrets .definitions .ChallengeDefinitionsConfiguration ;
13
+ import org .owasp .wrongsecrets .definitions .Difficulty ;
13
14
import org .springframework .http .MediaType ;
14
15
import org .springframework .web .bind .annotation .GetMapping ;
15
16
import org .springframework .web .bind .annotation .RestController ;
@@ -68,7 +69,7 @@ public String getChallenges() {
68
69
.orElse (disabledChallenge ));
69
70
jsonChallenge .put ("solved" , scoreCard .getChallengeCompleted (definition ));
70
71
jsonChallenge .put ("disabledEnv" , getDisabledEnv (definition ));
71
- jsonChallenge .put ("difficulty" , definition .difficulty (). difficulty ( ));
72
+ jsonChallenge .put ("difficulty" , getDificulty ( definition .difficulty ()));
72
73
jsonArray .add (jsonChallenge );
73
74
}
74
75
json .put ("status" , "success" );
@@ -78,6 +79,23 @@ public String getChallenges() {
78
79
return result ;
79
80
}
80
81
82
+ private int getDificulty (Difficulty difficulty ) {
83
+ switch (difficulty .difficulty ()) {
84
+ case "easy" :
85
+ return 1 ;
86
+ case "normal" :
87
+ return 2 ;
88
+ case "hard" :
89
+ return 3 ;
90
+ case "expert" :
91
+ return 4 ;
92
+ case "master" :
93
+ return 5 ;
94
+ default :
95
+ return 0 ;
96
+ }
97
+ }
98
+
81
99
private String getCategory () {
82
100
return this .wrongSecretsConfiguration .environments ().stream ()
83
101
.filter (e -> e .equals (runtimeEnvironment .getRuntimeEnvironment ()))
0 commit comments