■ ■ ■ ■ ■ ■
src/main/java/org/owasp/wrongsecrets/RuntimeEnvironment.java
skipped 12 lines 13 13 14 14 import static org.owasp.wrongsecrets.RuntimeEnvironment.Environment.*; 15 15 16 + /** 17 + * Class establishing whether a challenge can run or not depending on the given RuntimeEnvironment and whether components are configured & the CTFmode is enabled or not. 18 + */ 16 19 @Component 17 20 public class RuntimeEnvironment { 18 21 skipped 11 lines 30 33 31 34 private static final Map<Environment, List<Environment>> envToOverlappingEnvs = Map.of(FLY_DOCKER, List.of(DOCKER, FLY_DOCKER), HEROKU_DOCKER, List.of(DOCKER, HEROKU_DOCKER), DOCKER, List.of(DOCKER, HEROKU_DOCKER, FLY_DOCKER), GCP, List.of(DOCKER, K8S, VAULT), AWS, List.of(DOCKER, K8S, VAULT), AZURE, List.of(DOCKER, K8S, VAULT), VAULT, List.of(DOCKER, K8S), K8S, List.of(DOCKER), OKTETO_K8S, List.of(K8S, DOCKER, OKTETO_K8S)); 32 35 36 + /** 37 + * Enum with possible environments supported by the app. 38 + */ 33 39 public enum Environment { 34 40 DOCKER("Docker"), HEROKU_DOCKER("Heroku(Docker)"), FLY_DOCKER("Fly(Docker)"), GCP("gcp"), AWS("aws"), AZURE("azure"), VAULT("k8s-with-vault"), K8S("k8s"), OKTETO_K8S("Okteto(k8s)"); 35 41 skipped 11 lines 47 53 @Getter 48 54 private final Environment runtimeEnvironment; 49 55 50 - private boolean isK8sUnlockedInCTFMode() { 51 - String defaultValueChallenge5 = "if_you_see_this_please_use_k8s"; 52 - return ctfModeEnabled && !challenge5Value.equals(defaultValueChallenge5); 53 - } 54 - 55 - private boolean isVaultUnlockedInCTFMode() { 56 - String defaultVaultAnswer = "ACTUAL_ANSWER_CHALLENGE7"; 57 - String secondDefaultVaultAnswer = "if_you_see_this_please_use_K8S_and_Vault"; 58 - return ctfModeEnabled && !challenge7Value.equals(defaultVaultAnswer) && !challenge7Value.equals(secondDefaultVaultAnswer); 59 - } 60 - 61 - private boolean isCloudUnlockedInCTFMode() { 62 - String defaultValueAWSValue = "if_you_see_this_please_use_AWS_Setup"; 63 - return ctfModeEnabled && !defaultChallenge9Value.equals(defaultValueAWSValue); 64 - } 65 - 66 56 @Autowired 67 57 public RuntimeEnvironment(@Value("${K8S_ENV}") String currentRuntimeEnvironment) { 68 58 this.runtimeEnvironment = Environment.fromId(currentRuntimeEnvironment); skipped 26 lines 95 85 return ctfModeEnabled; 96 86 } 97 87 88 + private boolean isK8sUnlockedInCTFMode() { 89 + String defaultValueChallenge5 = "if_you_see_this_please_use_k8s"; 90 + return ctfModeEnabled && !challenge5Value.equals(defaultValueChallenge5); 91 + } 92 + 93 + private boolean isVaultUnlockedInCTFMode() { 94 + String defaultVaultAnswer = "ACTUAL_ANSWER_CHALLENGE7"; 95 + String secondDefaultVaultAnswer = "if_you_see_this_please_use_K8S_and_Vault"; 96 + return ctfModeEnabled && !challenge7Value.equals(defaultVaultAnswer) && !challenge7Value.equals(secondDefaultVaultAnswer); 97 + } 98 + 99 + private boolean isCloudUnlockedInCTFMode() { 100 + String defaultValueAWSValue = "if_you_see_this_please_use_AWS_Setup"; 101 + return ctfModeEnabled && !defaultChallenge9Value.equals(defaultValueAWSValue); 102 + } 98 103 } 99 104