refactor: remove unused code
This commit is contained in:
parent
67c1f622ef
commit
6a83ddcdef
@ -55,8 +55,8 @@ import org.thymeleaf.templateresource.StringTemplateResource;
|
|||||||
public class LessonTemplateResolver extends FileTemplateResolver {
|
public class LessonTemplateResolver extends FileTemplateResolver {
|
||||||
|
|
||||||
private static final String PREFIX = "lesson:";
|
private static final String PREFIX = "lesson:";
|
||||||
private ResourceLoader resourceLoader;
|
private final ResourceLoader resourceLoader;
|
||||||
private Map<String, byte[]> resources = new HashMap<>();
|
private final Map<String, byte[]> resources = new HashMap<>();
|
||||||
|
|
||||||
public LessonTemplateResolver(ResourceLoader resourceLoader) {
|
public LessonTemplateResolver(ResourceLoader resourceLoader) {
|
||||||
this.resourceLoader = resourceLoader;
|
this.resourceLoader = resourceLoader;
|
||||||
|
@ -40,7 +40,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.owasp.webgoat.container.i18n.Language;
|
import org.owasp.webgoat.container.i18n.Language;
|
||||||
import org.owasp.webgoat.container.i18n.Messages;
|
import org.owasp.webgoat.container.i18n.Messages;
|
||||||
import org.owasp.webgoat.container.i18n.PluginMessages;
|
import org.owasp.webgoat.container.i18n.PluginMessages;
|
||||||
import org.owasp.webgoat.container.lessons.LessonScanner;
|
|
||||||
import org.owasp.webgoat.container.session.LabelDebugger;
|
import org.owasp.webgoat.container.session.LabelDebugger;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@ -74,8 +73,6 @@ public class MvcConfiguration implements WebMvcConfigurer {
|
|||||||
|
|
||||||
private static final String UTF8 = "UTF-8";
|
private static final String UTF8 = "UTF-8";
|
||||||
|
|
||||||
private final LessonScanner lessonScanner;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addViewControllers(ViewControllerRegistry registry) {
|
public void addViewControllers(ViewControllerRegistry registry) {
|
||||||
registry.addViewController("/login").setViewName("login");
|
registry.addViewController("/login").setViewName("login");
|
||||||
@ -187,28 +184,6 @@ public class MvcConfiguration implements WebMvcConfigurer {
|
|||||||
registry
|
registry
|
||||||
.addResourceHandler("/fonts/**")
|
.addResourceHandler("/fonts/**")
|
||||||
.addResourceLocations("classpath:/webgoat/static/fonts/");
|
.addResourceLocations("classpath:/webgoat/static/fonts/");
|
||||||
|
|
||||||
// WebGoat lessons
|
|
||||||
registry
|
|
||||||
.addResourceHandler("/images/**")
|
|
||||||
.addResourceLocations(
|
|
||||||
lessonScanner.applyPattern("classpath:/lessons/%s/images/").toArray(String[]::new));
|
|
||||||
registry
|
|
||||||
.addResourceHandler("/lesson_js/**")
|
|
||||||
.addResourceLocations(
|
|
||||||
lessonScanner.applyPattern("classpath:/lessons/%s/js/").toArray(String[]::new));
|
|
||||||
registry
|
|
||||||
.addResourceHandler("/lesson_css/**")
|
|
||||||
.addResourceLocations(
|
|
||||||
lessonScanner.applyPattern("classpath:/lessons/%s/css/").toArray(String[]::new));
|
|
||||||
registry
|
|
||||||
.addResourceHandler("/lesson_templates/**")
|
|
||||||
.addResourceLocations(
|
|
||||||
lessonScanner.applyPattern("classpath:/lessons/%s/templates/").toArray(String[]::new));
|
|
||||||
registry
|
|
||||||
.addResourceHandler("/video/**")
|
|
||||||
.addResourceLocations(
|
|
||||||
lessonScanner.applyPattern("classpath:/lessons/%s/video/").toArray(String[]::new));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
package org.owasp.webgoat.container.assignments;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
|
|
||||||
/** Created by nbaars on 1/14/17. */
|
|
||||||
@Target(ElementType.TYPE)
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
public @interface AssignmentPath {
|
|
||||||
|
|
||||||
String[] path() default {};
|
|
||||||
|
|
||||||
RequestMethod[] method() default {};
|
|
||||||
|
|
||||||
String value() default "";
|
|
||||||
}
|
|
@ -35,6 +35,5 @@ package org.owasp.webgoat.container.lessons;
|
|||||||
*/
|
*/
|
||||||
public enum LessonMenuItemType {
|
public enum LessonMenuItemType {
|
||||||
CATEGORY,
|
CATEGORY,
|
||||||
LESSON,
|
LESSON
|
||||||
STAGE
|
|
||||||
}
|
}
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
package org.owasp.webgoat.container.lessons;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@Slf4j
|
|
||||||
public class LessonScanner {
|
|
||||||
|
|
||||||
private static final Pattern lessonPattern = Pattern.compile("^.*/lessons/([^/]*)/.*$");
|
|
||||||
|
|
||||||
@Getter private final Set<String> lessons = new HashSet<>();
|
|
||||||
|
|
||||||
public LessonScanner(ResourcePatternResolver resourcePatternResolver) {
|
|
||||||
try {
|
|
||||||
var resources = resourcePatternResolver.getResources("classpath:/lessons/*/*");
|
|
||||||
for (var resource : resources) {
|
|
||||||
// WG can run as a fat jar or as directly from file system we need to support both so use
|
|
||||||
// the URL
|
|
||||||
var url = resource.getURL();
|
|
||||||
var matcher = lessonPattern.matcher(url.toString());
|
|
||||||
if (matcher.matches()) {
|
|
||||||
lessons.add(matcher.group(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.debug("Found {} lessons", lessons.size());
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.warn("No lessons found...");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> applyPattern(String pattern) {
|
|
||||||
return lessons.stream().map(lesson -> String.format(pattern, lesson)).toList();
|
|
||||||
}
|
|
||||||
}
|
|
@ -27,7 +27,6 @@ import static org.owasp.webgoat.container.assignments.AttackResultBuilder.succes
|
|||||||
|
|
||||||
import org.owasp.webgoat.container.assignments.AssignmentEndpoint;
|
import org.owasp.webgoat.container.assignments.AssignmentEndpoint;
|
||||||
import org.owasp.webgoat.container.assignments.AssignmentHints;
|
import org.owasp.webgoat.container.assignments.AssignmentHints;
|
||||||
import org.owasp.webgoat.container.assignments.AssignmentPath;
|
|
||||||
import org.owasp.webgoat.container.assignments.AttackResult;
|
import org.owasp.webgoat.container.assignments.AttackResult;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
@ -36,7 +35,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@AssignmentHints({"http-basics.hints.http_basic_quiz.1", "http-basics.hints.http_basic_quiz.2"})
|
@AssignmentHints({"http-basics.hints.http_basic_quiz.1", "http-basics.hints.http_basic_quiz.2"})
|
||||||
@AssignmentPath("HttpBasics/attack2")
|
|
||||||
public class HttpBasicsQuiz implements AssignmentEndpoint {
|
public class HttpBasicsQuiz implements AssignmentEndpoint {
|
||||||
|
|
||||||
@PostMapping("/HttpBasics/attack2")
|
@PostMapping("/HttpBasics/attack2")
|
||||||
|
@ -1,69 +0,0 @@
|
|||||||
price,destination,departure date,arrive date,departing from
|
|
||||||
1223,HNL,12/26/13,01/02/14,SFO
|
|
||||||
1223,HNL,12/26/13,01/02/14,SFO
|
|
||||||
1131,SJU,12/26/13,01/02/14,SFO
|
|
||||||
1175,SJU,12/26/13,01/02/14,SFO
|
|
||||||
1430,BCN,12/26/13,01/02/14,SFO
|
|
||||||
1180,FRA,12/26/13,01/02/14,SFO
|
|
||||||
1683,LIM,12/26/13,01/02/14,SFO
|
|
||||||
1119,LHR,12/26/13,01/02/14,SFO
|
|
||||||
858,CUN,12/26/13,01/02/14,SFO
|
|
||||||
888,SJD,12/26/13,01/02/14,SFO
|
|
||||||
1223,HNL,12/26/13,01/02/14,OAK
|
|
||||||
1208,SJU,12/26/13,01/02/14,OAK
|
|
||||||
1428,FRA,12/26/13,01/02/14,OAK
|
|
||||||
1864,LIM,12/26/13,01/02/14,OAK
|
|
||||||
1484,LHR,12/26/13,01/02/14,OAK
|
|
||||||
977,CUN,12/26/13,01/02/14,OAK
|
|
||||||
868,SJD,12/26/13,01/02/14,OAK
|
|
||||||
1394,HNL,12/26/13,01/02/14,BOS
|
|
||||||
734,SJU,12/26/13,01/02/14,BOS
|
|
||||||
1299,BCN,12/26/13,01/02/14,BOS
|
|
||||||
1141,FRA,12/26/13,01/02/14,BOS
|
|
||||||
944,CUN,12/26/13,01/02/14,BOS
|
|
||||||
1355,SJD,12/26/13,01/02/14,BOS
|
|
||||||
595,HNL,01/04/14,01/11/14,SFO
|
|
||||||
587,SJU,01/04/14,01/11/14,SFO
|
|
||||||
1385,BCN,01/04/14,01/11/14,SFO
|
|
||||||
1376,FRA,01/04/14,01/11/14,SFO
|
|
||||||
1005,LIM,01/04/14,01/11/14,SFO
|
|
||||||
1396,LHR,01/04/14,01/11/14,SFO
|
|
||||||
496,CUN,01/04/14,01/11/14,SFO
|
|
||||||
363,SJD,01/04/14,01/11/14,SFO
|
|
||||||
563,HNL,01/04/14,01/11/14,OAK
|
|
||||||
857,SJU,01/04/14,01/11/14,OAK
|
|
||||||
1743,BCN,01/04/14,01/11/14,OAK
|
|
||||||
1768,FRA,01/04/14,01/11/14,OAK
|
|
||||||
1355,LIM,01/04/14,01/11/14,OAK
|
|
||||||
2039,LHR,01/04/14,01/11/14,OAK
|
|
||||||
1035,HNL,01/04/14,01/11/14,BOS
|
|
||||||
533,SJU,01/04/14,01/11/14,BOS
|
|
||||||
1206,BCN,01/04/14,01/11/14,BOS
|
|
||||||
1180,LHR,01/04/14,01/11/14,BOS
|
|
||||||
432,CUN,01/04/14,01/11/14,BOS
|
|
||||||
612,SJD,01/04/14,01/11/14,BOS
|
|
||||||
473,HNL,1/09/14,01/17/14,SFO
|
|
||||||
417,SJU,1/09/14,01/17/14,SFO
|
|
||||||
864,BCN,1/09/14,01/17/14,SFO
|
|
||||||
953,LHR,1/09/14,01/17/14,SFO
|
|
||||||
450,CUN,1/09/14,01/17/14,SFO
|
|
||||||
363,SJD,1/09/14,01/17/14,SFO
|
|
||||||
417,HNL,1/09/14,01/17/14,OAK
|
|
||||||
577,SJU,1/09/14,01/17/14,OAK
|
|
||||||
993,LIM,1/09/14,01/17/14,OAK
|
|
||||||
1039,LHR,1/09/14,01/17/14,OAK
|
|
||||||
460,CUN,1/09/14,01/17/14,OAK
|
|
||||||
368,SJD,1/09/14,01/17/14,OAK
|
|
||||||
738,HNL,1/09/14,01/17/14,BOS
|
|
||||||
309,SJU,1/09/14,01/17/14,BOS
|
|
||||||
716,BCN,1/09/14,01/17/14,BOS
|
|
||||||
859,FRA,1/09/14,01/17/14,BOS
|
|
||||||
1121,LIM,1/09/14,01/17/14,BOS
|
|
||||||
591,SJD,1/09/14,01/17/14,BOS
|
|
||||||
422,HNL,01/14/14,01/23/14,SFO
|
|
||||||
385,SJU,01/14/14,01/23/14,SFO
|
|
||||||
892,BCN,01/14/14,01/23/14,SFO
|
|
||||||
956,FRA,01/14/14,01/23/14,SFO
|
|
||||||
723,LIM,01/14/14,01/23/14,SFO
|
|
||||||
894,LHR,01/14/14,01/23/14,SFO
|
|
||||||
397,HNL,01/14/14,01/23/14,OAK
|
|
Loading…
x
Reference in New Issue
Block a user