First attempt to remove JSP and move to Thymeleaf and update to Spring Boot. The Thymeleaf templates can be loaded as snippets which makes it more easy to move away from ECS and create normal HTML pages for a lesson.

This commit is contained in:
Nanne Baars 2016-04-05 08:19:50 +02:00
parent 7f91671c8f
commit ecc8cb391b
186 changed files with 14439 additions and 13920 deletions

View File

@ -17,6 +17,12 @@
<url>https://webgoat.github.io/</url> <url>https://webgoat.github.io/</url>
</organization> </organization>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
</parent>
<licenses> <licenses>
<license> <license>
<name>GNU General Public License, version 2</name> <name>GNU General Public License, version 2</name>
@ -148,7 +154,6 @@
<maven-surefire-plugin.version>2.19</maven-surefire-plugin.version> <maven-surefire-plugin.version>2.19</maven-surefire-plugin.version>
<maven-war-plugin.version>2.6</maven-war-plugin.version> <maven-war-plugin.version>2.6</maven-war-plugin.version>
<nexus-staging-maven-plugin.version>1.6.6</nexus-staging-maven-plugin.version> <nexus-staging-maven-plugin.version>1.6.6</nexus-staging-maven-plugin.version>
<org.springframework.version>3.2.4.RELEASE</org.springframework.version>
<sauce_junit.version>2.1.20</sauce_junit.version> <sauce_junit.version>2.1.20</sauce_junit.version>
<selenium-java.version>2.48.2</selenium-java.version> <selenium-java.version>2.48.2</selenium-java.version>
<slf4j-api.version>1.7.12</slf4j-api.version> <slf4j-api.version>1.7.12</slf4j-api.version>

View File

@ -12,6 +12,10 @@
<version>7.1-SNAPSHOT</version> <version>7.1-SNAPSHOT</version>
</parent> </parent>
<properties>
<start-class>org.owasp.webgoat.WebGoat</start-class>
</properties>
<profiles> <profiles>
<profile> <profile>
<id>run-integration-tests</id> <id>run-integration-tests</id>
@ -206,10 +210,49 @@
</excludes> </excludes>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins> </plugins>
</build> </build>
<dependencies> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<!--<dependency>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-devtools</artifactId>-->
<!--<optional>true</optional>-->
<!--</dependency>-->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.xeustechnologies</groupId>
<artifactId>jcl-core</artifactId>
<version>2.7</version>
</dependency>
<dependency> <dependency>
<groupId>javax.activation</groupId> <groupId>javax.activation</groupId>
<artifactId>activation</artifactId> <artifactId>activation</artifactId>
@ -266,16 +309,16 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>commons-logging</groupId> <!--<groupId>commons-logging</groupId>-->
<artifactId>commons-logging</artifactId> <!--<artifactId>commons-logging</artifactId>-->
<version>${commons-logging.version}</version> <!--<version>${commons-logging.version}</version>-->
</dependency> <!--</dependency>-->
<dependency> <!--<dependency>-->
<groupId>org.slf4j</groupId> <!--<groupId>org.slf4j</groupId>-->
<artifactId>jcl-over-slf4j</artifactId> <!--<artifactId>jcl-over-slf4j</artifactId>-->
<version>${jcl-over-slf4j.version}</version> <!--<version>${jcl-over-slf4j.version}</version>-->
</dependency> <!--</dependency>-->
<dependency> <dependency>
<groupId>commons-discovery</groupId> <groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId> <artifactId>commons-discovery</artifactId>
@ -316,71 +359,33 @@
<artifactId>jtds</artifactId> <artifactId>jtds</artifactId>
<version>${jtds.version}</version> <version>${jtds.version}</version>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>org.apache.tomcat</groupId> <!--<groupId>org.apache.tomcat</groupId>-->
<artifactId>tomcat-catalina</artifactId> <!--<artifactId>tomcat-catalina</artifactId>-->
<version>${tomcat-catalina.version}</version> <!--<version>${tomcat-catalina.version}</version>-->
<scope>provided</scope> <!--<scope>provided</scope>-->
</dependency> <!--</dependency>-->
<!-- ************* spring MVC and related dependencies ************** --> <!-- ************* spring MVC and related dependencies ************** -->
<!-- servlet API --> <!-- servlet API -->
<dependency> <!--<dependency>-->
<groupId>javax</groupId> <!--<groupId>javax</groupId>-->
<artifactId>javaee-api</artifactId> <!--<artifactId>javaee-api</artifactId>-->
<version>${javaee-api.version}</version> <!--<version>${javaee-api.version}</version>-->
<scope>provided</scope> <!--<scope>provided</scope>-->
</dependency> <!--</dependency>-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!-- Jackson --> <!-- Jackson -->
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId> <artifactId>jackson-core</artifactId>
<version>${jackson-core.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
<version>${jackson-databind.version}</version>
</dependency>
<!-- Spring MVC framework -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${spring.security.version}</version>
</dependency> </dependency>
<!-- Apache Commons Upload --> <!-- Apache Commons Upload -->
@ -409,43 +414,43 @@
<version>${standard.version}</version> <version>${standard.version}</version>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>log4j</groupId> <!--<groupId>log4j</groupId>-->
<artifactId>log4j</artifactId> <!--<artifactId>log4j</artifactId>-->
<version>${log4j.version}</version> <!--<version>${log4j.version}</version>-->
<exclusions> <!--<exclusions>-->
<exclusion> <!--<exclusion>-->
<groupId>javax.jms</groupId> <!--<groupId>javax.jms</groupId>-->
<artifactId>jms</artifactId> <!--<artifactId>jms</artifactId>-->
</exclusion> <!--</exclusion>-->
<exclusion> <!--<exclusion>-->
<groupId>com.sun.jdmk</groupId> <!--<groupId>com.sun.jdmk</groupId>-->
<artifactId>jmxtools</artifactId> <!--<artifactId>jmxtools</artifactId>-->
</exclusion> <!--</exclusion>-->
<exclusion> <!--<exclusion>-->
<groupId>com.sun.jmx</groupId> <!--<groupId>com.sun.jmx</groupId>-->
<artifactId>jmxri</artifactId> <!--<artifactId>jmxri</artifactId>-->
</exclusion> <!--</exclusion>-->
</exclusions> <!--</exclusions>-->
</dependency> <!--</dependency>-->
<dependency> <dependency>
<groupId>org.apache.tiles</groupId> <groupId>org.apache.tiles</groupId>
<artifactId>tiles-core</artifactId> <artifactId>tiles-core</artifactId>
<version>${tiles.version}</version> <version>${tiles.version}</version>
<type>jar</type> <type>jar</type>
</dependency> </dependency>
<dependency> <!--<dependency>-->
<groupId>org.slf4j</groupId> <!--<groupId>org.slf4j</groupId>-->
<artifactId>slf4j-api</artifactId> <!--<artifactId>slf4j-api</artifactId>-->
<version>${slf4j-api.version}</version> <!--<version>${slf4j-api.version}</version>-->
<type>jar</type> <!--<type>jar</type>-->
</dependency> <!--</dependency>-->
<dependency> <!--<dependency>-->
<groupId>org.slf4j</groupId> <!--<groupId>org.slf4j</groupId>-->
<artifactId>slf4j-log4j12</artifactId> <!--<artifactId>slf4j-log4j12</artifactId>-->
<version>${slf4j-log4j12.version}</version> <!--<version>${slf4j-log4j12.version}</version>-->
<type>jar</type> <!--<type>jar</type>-->
</dependency> <!--</dependency>-->
<!-- ************* END spring MVC and related dependencies ************** --> <!-- ************* END spring MVC and related dependencies ************** -->
<!-- ************* START: Dependencies for Unit and Integration Testing ************** --> <!-- ************* START: Dependencies for Unit and Integration Testing ************** -->
<dependency> <dependency>

View File

@ -204,7 +204,7 @@ public class HammerHead extends HttpServlet {
private String getViewPage(WebSession webSession) { private String getViewPage(WebSession webSession) {
// now always display the lesson content // now always display the lesson content
String page = "/lesson_content.jsp"; String page = "lesson_content";
//page = "/main.jsp"; //page = "/main.jsp";
return page; return page;
} }

View File

@ -0,0 +1,33 @@
package org.owasp.webgoat;
import org.owasp.webgoat.session.LabelDebugger;
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
/**
*
*/
@Configuration
public class MvcConfiguration extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/login").setViewName("login");
registry.addViewController("/lesson_content").setViewName("lesson_content");
}
@Bean
public ServletRegistrationBean servletRegistrationBean() {
return new ServletRegistrationBean(new HammerHead(), "/attack/*");
}
@Bean
//@Scope(value= WebApplicationContext.SCOPE_SESSION)
public LabelDebugger labelDebugger() {
return new LabelDebugger();
}
}

View File

@ -0,0 +1,53 @@
package org.owasp.webgoat;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
@SpringBootApplication
public class WebGoat extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(WebGoat.class);
}
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
super.onStartup(servletContext);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(WebGoat.class, args);
}
// @Bean
// @Autowired
// public TomcatEmbeddedServletContainerFactory servletContainer(final JarScanner jarScanner) {
// TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
// factory.setPort(80);
// factory.setSessionTimeout(10, TimeUnit.MINUTES);
// factory.addContextCustomizers(new TomcatContextCustomizer() {
// @Override
// public void customize(Context context) {
//
// context.setJarScanner(jarScanner);
// }
// });
// return factory;
// }
//
// @Bean
// public JarScanner getJarScanner() {
// StandardJarScanner jarScanner = new StandardJarScanner();
// jarScanner.setScanClassPath(true);
// return jarScanner;
// }
}

View File

@ -0,0 +1,49 @@
package org.owasp.webgoat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
import org.springframework.security.core.userdetails.UserDetailsService;
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry security = http
.authorizeRequests()
.antMatchers("/css/**", "/images/**", "/js/**", "fonts/**", "/plugins/**").permitAll()
.antMatchers("/servlet/AdminServlet/**").hasAnyRole("WEBGOAT_ADMIN", "SERVER_ADMIN") //
.antMatchers("/JavaSource/**").hasRole("SERVER_ADMIN") //
.anyRequest().hasAnyRole("WEBGOAT_USER", "WEBGOAT_ADMIN", "SERVER_ADMIN");
security.and()
.formLogin()
.loginPage("/login")
.defaultSuccessUrl("/welcome.mvc")
.usernameParameter("username")
.passwordParameter("password")
.permitAll();
security.and()
.logout()
.permitAll();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("guest").password("guest").roles("WEBGOAT_USER").and() //
.withUser("webgoat").password("webgoat").roles("WEBGOAT_ADMIN").and() //
.withUser("server").password("server").roles("SERVER_ADMIN");
}
@Bean
@Override
public UserDetailsService userDetailsServiceBean() throws Exception {
return super.userDetailsServiceBean();
}
}

View File

@ -1,59 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.owasp.webgoat.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
/**
* <p>About class.</p>
*
* @author rlawson
* @version $Id: $Id
*/
@Controller
public class About {
final Logger logger = LoggerFactory.getLogger(About.class);
private static final String WELCOMED = "welcomed";
/**
* <p>welcome.</p>
*
* @param request a {@link javax.servlet.http.HttpServletRequest} object.
* @param error a {@link java.lang.String} object.
* @param logout a {@link java.lang.String} object.
* @return a {@link org.springframework.web.servlet.ModelAndView} object.
*/
@RequestMapping(value = "about.mvc", method = RequestMethod.GET)
public ModelAndView welcome(HttpServletRequest request,
@RequestParam(value = "error", required = false) String error,
@RequestParam(value = "logout", required = false) String logout) {
// set the welcome attribute
// this is so the attack servlet does not also
// send them to the welcome page
HttpSession session = request.getSession();
if (session.getAttribute(WELCOMED) == null) {
session.setAttribute(WELCOMED, "true");
}
//go ahead and send them to webgoat (skip the welcome page)
ModelAndView model = new ModelAndView();
//model.setViewName("welcome");
//model.setViewName("main_new");
model.setViewName("about");
return model;
}
}

View File

@ -5,44 +5,38 @@
*/ */
package org.owasp.webgoat.controller; package org.owasp.webgoat.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
/** /**
* <p>Login class.</p> * <p>Login class.</p>
* *
* @author rlawson * @author rlawson
* @version $Id: $Id * @version $Id: $Id
*/ */
@Controller //@Controller
public class Login { public class Login {
/** // /**
* <p>login.</p> // * <p>login.</p>
* // *
* @param error a {@link java.lang.String} object. // * @param error a {@link java.lang.String} object.
* @param logout a {@link java.lang.String} object. // * @param logout a {@link java.lang.String} object.
* @return a {@link org.springframework.web.servlet.ModelAndView} object. // * @return a {@link org.springframework.web.servlet.ModelAndView} object.
*/ // */
@RequestMapping(value = "login.mvc", method = RequestMethod.GET) // @RequestMapping(path = "login.mvc", method = RequestMethod.GET)
public ModelAndView login( // public ModelAndView login(
@RequestParam(value = "error", required = false) String error, // @RequestParam(value = "error", required = false) String error,
@RequestParam(value = "logout", required = false) String logout) { // @RequestParam(value = "logout", required = false) String logout) {
//
ModelAndView model = new ModelAndView(); // ModelAndView model = new ModelAndView();
if (error != null) { // if (error != null) {
model.addObject("error", "Invalid username and password!"); // model.addObject("error", "Invalid username and password!");
} // }
//
if (logout != null) { // if (logout != null) {
model.addObject("msg", "You've been logged out successfully."); // model.addObject("msg", "You've been logged out successfully.");
} // }
model.setViewName("login"); // model.setViewName("login");
//
return model; // return model;
//
} // }
} }

View File

@ -31,7 +31,7 @@ public class Logout {
* @param logout a {@link java.lang.String} object. * @param logout a {@link java.lang.String} object.
* @return a {@link org.springframework.web.servlet.ModelAndView} object. * @return a {@link org.springframework.web.servlet.ModelAndView} object.
*/ */
@RequestMapping(value = "logout.mvc", method = RequestMethod.GET) @RequestMapping(path = "logout.mvc", method = RequestMethod.GET)
public ModelAndView logout( public ModelAndView logout(
@RequestParam(value = "error", required = false) String error, @RequestParam(value = "error", required = false) String error,
@RequestParam(value = "logout", required = false) String logout) { @RequestParam(value = "logout", required = false) String logout) {

View File

@ -5,10 +5,6 @@
*/ */
package org.owasp.webgoat.controller; package org.owasp.webgoat.controller;
import java.util.Collection;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.owasp.webgoat.application.Application; import org.owasp.webgoat.application.Application;
import org.owasp.webgoat.session.WebSession; import org.owasp.webgoat.session.WebSession;
@ -20,9 +16,13 @@ import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Collection;
/** /**
* <p>Start class.</p> * <p>Start class.</p>
* *
@ -43,14 +43,10 @@ public class Start {
* <p>start.</p> * <p>start.</p>
* *
* @param request a {@link javax.servlet.http.HttpServletRequest} object. * @param request a {@link javax.servlet.http.HttpServletRequest} object.
* @param error a {@link java.lang.String} object.
* @param logout a {@link java.lang.String} object.
* @return a {@link org.springframework.web.servlet.ModelAndView} object. * @return a {@link org.springframework.web.servlet.ModelAndView} object.
*/ */
@RequestMapping(value = "start.mvc", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(path = "start.mvc", method = {RequestMethod.GET, RequestMethod.POST})
public ModelAndView start(HttpServletRequest request, public ModelAndView start(HttpServletRequest request) {
@RequestParam(value = "error", required = false) String error,
@RequestParam(value = "logout", required = false) String logout) {
ModelAndView model = new ModelAndView(); ModelAndView model = new ModelAndView();
// make sure session is set up correctly // make sure session is set up correctly

View File

@ -5,16 +5,14 @@
*/ */
package org.owasp.webgoat.controller; package org.owasp.webgoat.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
/** /**
* <p>Welcome class.</p> * <p>Welcome class.</p>
* *
@ -24,21 +22,16 @@ import org.springframework.web.servlet.ModelAndView;
@Controller @Controller
public class Welcome { public class Welcome {
final Logger logger = LoggerFactory.getLogger(Welcome.class);
private static final String WELCOMED = "welcomed"; private static final String WELCOMED = "welcomed";
/** /**
* <p>welcome.</p> * <p>welcome.</p>
* *
* @param request a {@link javax.servlet.http.HttpServletRequest} object. * @param request a {@link javax.servlet.http.HttpServletRequest} object.
* @param error a {@link java.lang.String} object.
* @param logout a {@link java.lang.String} object.
* @return a {@link org.springframework.web.servlet.ModelAndView} object. * @return a {@link org.springframework.web.servlet.ModelAndView} object.
*/ */
@RequestMapping(value = "welcome.mvc", method = RequestMethod.GET) @RequestMapping(path = "welcome.mvc", method = RequestMethod.GET)
public ModelAndView welcome(HttpServletRequest request, public ModelAndView welcome(HttpServletRequest request) {
@RequestParam(value = "error", required = false) String error,
@RequestParam(value = "logout", required = false) String logout) {
// set the welcome attribute // set the welcome attribute
// this is so the attack servlet does not also // this is so the attack servlet does not also

View File

@ -259,7 +259,7 @@ public abstract class AbstractLesson extends Screen implements Comparable<Object
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
if ((line.indexOf(methodName) != -1) if ((line.indexOf(methodName) != -1)
&& ((line.indexOf("public") != -1) || (line.indexOf("protected") != -1) || (line && ((line.indexOf("static") != -1) || (line.indexOf("protected") != -1) || (line
.indexOf("private") != -1))) { .indexOf("private") != -1))) {
echo = true; echo = true;
startCount = true; startCount = true;

View File

@ -2,7 +2,6 @@ package org.owasp.webgoat.plugins;
import com.google.common.base.Optional; import com.google.common.base.Optional;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.apache.catalina.loader.WebappClassLoader;
import org.owasp.webgoat.lessons.AbstractLesson; import org.owasp.webgoat.lessons.AbstractLesson;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -28,6 +27,7 @@ public class Plugin {
private static final String NAME_LESSON_SOLUTION_DIRECTORY = "lessonSolutions"; private static final String NAME_LESSON_SOLUTION_DIRECTORY = "lessonSolutions";
private static final String NAME_LESSON_PLANS_DIRECTORY = "lessonPlans"; private static final String NAME_LESSON_PLANS_DIRECTORY = "lessonPlans";
private final PluginClassLoader classLoader;
private Class<AbstractLesson> lesson; private Class<AbstractLesson> lesson;
private Map<String, File> solutionLanguageFiles = new HashMap<>(); private Map<String, File> solutionLanguageFiles = new HashMap<>();
@ -35,6 +35,10 @@ public class Plugin {
private List<File> pluginFiles = Lists.newArrayList(); private List<File> pluginFiles = Lists.newArrayList();
private File lessonSourceFile; private File lessonSourceFile;
public Plugin(PluginClassLoader classLoader) {
this.classLoader = classLoader;
}
/** /**
* <p>findLesson.</p> * <p>findLesson.</p>
* *
@ -49,10 +53,10 @@ public class Plugin {
private void findLesson(String name) { private void findLesson(String name) {
String realClassName = StringUtils.trimLeadingCharacter(name, '/').replaceAll("/", ".").replaceAll(".class", ""); String realClassName = StringUtils.trimLeadingCharacter(name, '/').replaceAll("/", ".").replaceAll(".class", "");
//TODO should be passed in (refactor) //TODO should be passed in (refactor)
WebappClassLoader cl = (WebappClassLoader) Thread.currentThread().getContextClassLoader(); //TomcatEmbeddedWebappClassLoader cl = (TomcatEmbeddedWebappClassLoader) Thread.currentThread().getContextClassLoader();
try { try {
Class clazz = cl.loadClass(realClassName, true); Class clazz = classLoader.loadClass(realClassName);
if (AbstractLesson.class.isAssignableFrom(clazz)) { if (AbstractLesson.class.isAssignableFrom(clazz)) {
this.lesson = clazz; this.lesson = clazz;

View File

@ -0,0 +1,16 @@
package org.owasp.webgoat.plugins;
import java.net.URL;
import java.net.URLClassLoader;
public class PluginClassLoader extends URLClassLoader {
public PluginClassLoader(ClassLoader parent) {
super(new URL[] {}, parent);
}
@Override
public void addURL(URL url) {
super.addURL(url);
}
}

View File

@ -34,9 +34,9 @@ public class PluginExtractor {
* @return a {@link org.owasp.webgoat.plugins.Plugin} object. * @return a {@link org.owasp.webgoat.plugins.Plugin} object.
* @throws java.io.IOException if any. * @throws java.io.IOException if any.
*/ */
public Plugin extractJarFile(final File archive, final File targetDirectory) throws IOException { public Plugin extractJarFile(final File archive, final File targetDirectory, PluginClassLoader cl) throws IOException {
ZipFile zipFile = new ZipFile(archive); ZipFile zipFile = new ZipFile(archive);
Plugin plugin = new Plugin(); Plugin plugin = new Plugin(cl);
try { try {
Enumeration<? extends ZipEntry> entries = zipFile.entries(); Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) { while (entries.hasMoreElements()) {

View File

@ -1,7 +1,6 @@
package org.owasp.webgoat.plugins; package org.owasp.webgoat.plugins;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.apache.catalina.loader.WebappClassLoader;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.owasp.webgoat.util.LabelProvider; import org.owasp.webgoat.util.LabelProvider;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -48,24 +47,25 @@ public class PluginsLoader {
this.pluginTarget = Objects.requireNonNull(pluginTarget, "plugin target cannot be null"); this.pluginTarget = Objects.requireNonNull(pluginTarget, "plugin target cannot be null");
} }
/** // /**
* Copy jars to the lib directory // * Copy jars to the lib directory
*/ // */
public void copyJars() { // public void copyJars() {
try { // try {
if (!alreadyLoaded) { // if (!alreadyLoaded) {
WebappClassLoader cl = (WebappClassLoader) Thread.currentThread().getContextClassLoader(); // WebappClassLoader cl = (WebappClassLoader) Thread.currentThread().getContextClassLoader();
cl.setAntiJARLocking(true); // // cl.setAntiJARLocking(true);
List<URL> jars = listJars(); // List<URL> jars = listJars();
for (URL jar : jars) { // for (URL jar : jars) {
cl.addRepository(jar.toString()); // // cl.setResources();
} // // cl.addRepository(jar.toString());
alreadyLoaded = true; // }
} // alreadyLoaded = true;
} catch (Exception e) { // }
logger.error("Copying plugins failed", e); // } catch (Exception e) {
} // logger.error("Copying plugins failed", e);
} // }
// }
/** /**
* <p>loadPlugins.</p> * <p>loadPlugins.</p>
@ -73,7 +73,7 @@ public class PluginsLoader {
* @return a {@link java.util.List} object. * @return a {@link java.util.List} object.
*/ */
public List<Plugin> loadPlugins() { public List<Plugin> loadPlugins() {
copyJars(); // copyJars();
List<Plugin> plugins = Lists.newArrayList(); List<Plugin> plugins = Lists.newArrayList();
try { try {
@ -134,13 +134,17 @@ public class PluginsLoader {
private List<Callable<Plugin>> extractJars(List<URL> jars) { private List<Callable<Plugin>> extractJars(List<URL> jars) {
List<Callable<Plugin>> extractorCallables = Lists.newArrayList(); List<Callable<Plugin>> extractorCallables = Lists.newArrayList();
ClassLoader parentClassLoader = PluginClassLoader.class.getClassLoader();
final PluginClassLoader classLoader = new PluginClassLoader(parentClassLoader);
for (final URL jar : jars) { for (final URL jar : jars) {
classLoader.addURL(jar);
extractorCallables.add(new Callable<Plugin>() { extractorCallables.add(new Callable<Plugin>() {
@Override @Override
public Plugin call() throws Exception { public Plugin call() throws Exception {
PluginExtractor extractor = new PluginExtractor(); PluginExtractor extractor = new PluginExtractor();
return extractor.extractJarFile(ResourceUtils.getFile(jar), pluginTarget.toFile()); return extractor.extractJarFile(ResourceUtils.getFile(jar), pluginTarget.toFile(), classLoader);
} }
}); });
} }

View File

@ -29,12 +29,13 @@
*/ */
package org.owasp.webgoat.service; package org.owasp.webgoat.service;
import javax.servlet.http.HttpSession;
import org.owasp.webgoat.application.Application; import org.owasp.webgoat.application.Application;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpSession;
/** /**
* <p>ApplicationService class.</p> * <p>ApplicationService class.</p>
* *
@ -50,7 +51,7 @@ public class ApplicationService extends BaseService {
* @param session a {@link javax.servlet.http.HttpSession} object. * @param session a {@link javax.servlet.http.HttpSession} object.
* @return a {@link org.owasp.webgoat.application.Application} object. * @return a {@link org.owasp.webgoat.application.Application} object.
*/ */
@RequestMapping(value = "/application.mvc", produces = "application/json") @RequestMapping(path = "/application.mvc", produces = "application/json")
public @ResponseBody public @ResponseBody
Application showApplication(HttpSession session) { Application showApplication(HttpSession session) {
Application app = Application.getInstance(); Application app = Application.getInstance();

View File

@ -29,10 +29,6 @@
*/ */
package org.owasp.webgoat.service; package org.owasp.webgoat.service;
import java.util.Collections;
import java.util.List;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpSession;
import org.owasp.webgoat.lessons.model.RequestParameter; import org.owasp.webgoat.lessons.model.RequestParameter;
import org.owasp.webgoat.session.WebSession; import org.owasp.webgoat.session.WebSession;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -40,6 +36,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpSession;
import java.util.Collections;
import java.util.List;
/** /**
* <p>CookieService class.</p> * <p>CookieService class.</p>
* *
@ -55,7 +56,7 @@ public class CookieService extends BaseService {
* @param session a {@link javax.servlet.http.HttpSession} object. * @param session a {@link javax.servlet.http.HttpSession} object.
* @return a {@link java.util.List} object. * @return a {@link java.util.List} object.
*/ */
@RequestMapping(value = "/cookie.mvc", produces = "application/json") @RequestMapping(path = "/cookie.mvc", produces = "application/json")
public @ResponseBody public @ResponseBody
List<Cookie> showCookies(HttpSession session) { List<Cookie> showCookies(HttpSession session) {
WebSession ws = getWebSession(session); WebSession ws = getWebSession(session);

View File

@ -32,7 +32,7 @@ public class HintService extends BaseService {
* @param session a {@link javax.servlet.http.HttpSession} object. * @param session a {@link javax.servlet.http.HttpSession} object.
* @return a {@link java.util.List} object. * @return a {@link java.util.List} object.
*/ */
@RequestMapping(value = "/hint.mvc", produces = "application/json") @RequestMapping(path = "/hint.mvc", produces = "application/json")
public @ResponseBody public @ResponseBody
List<Hint> showHint(HttpSession session) { List<Hint> showHint(HttpSession session) {
List<Hint> listHints = new ArrayList<Hint>(); List<Hint> listHints = new ArrayList<Hint>();

View File

@ -68,7 +68,7 @@ public class LabelDebugService extends BaseService {
* *
* @return a {@link org.springframework.http.ResponseEntity} object. * @return a {@link org.springframework.http.ResponseEntity} object.
*/ */
@RequestMapping(value = URL_DEBUG_LABELS_MVC, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = URL_DEBUG_LABELS_MVC, produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody public @ResponseBody
ResponseEntity<Map<String, Object>> checkDebuggingStatus() { ResponseEntity<Map<String, Object>> checkDebuggingStatus() {
logger.debug("Checking label debugging, it is " + labelDebugger.isEnabled()); // FIXME parameterize logger.debug("Checking label debugging, it is " + labelDebugger.isEnabled()); // FIXME parameterize

View File

@ -32,7 +32,7 @@ public class LessonInfoService extends BaseService {
* @param session a {@link javax.servlet.http.HttpSession} object. * @param session a {@link javax.servlet.http.HttpSession} object.
* @return a {@link org.owasp.webgoat.lessons.model.LessonInfoModel} object. * @return a {@link org.owasp.webgoat.lessons.model.LessonInfoModel} object.
*/ */
@RequestMapping(value = "/lessoninfo.mvc", produces = "application/json") @RequestMapping(path = "/lessoninfo.mvc", produces = "application/json")
public @ResponseBody public @ResponseBody
LessonInfoModel getLessonInfo(HttpSession session) { LessonInfoModel getLessonInfo(HttpSession session) {
WebSession webSession = getWebSession(session); WebSession webSession = getWebSession(session);

View File

@ -29,9 +29,6 @@
*/ */
package org.owasp.webgoat.service; package org.owasp.webgoat.service;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpSession;
import org.owasp.webgoat.lessons.AbstractLesson; import org.owasp.webgoat.lessons.AbstractLesson;
import org.owasp.webgoat.lessons.Category; import org.owasp.webgoat.lessons.Category;
import org.owasp.webgoat.lessons.RandomLessonAdapter; import org.owasp.webgoat.lessons.RandomLessonAdapter;
@ -45,6 +42,10 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;
/** /**
* <p>LessonMenuService class.</p> * <p>LessonMenuService class.</p>
* *
@ -62,7 +63,7 @@ public class LessonMenuService extends BaseService {
* @param session a {@link javax.servlet.http.HttpSession} object. * @param session a {@link javax.servlet.http.HttpSession} object.
* @return a {@link java.util.List} object. * @return a {@link java.util.List} object.
*/ */
@RequestMapping(value = "/lessonmenu.mvc", produces = "application/json") @RequestMapping(path = "/lessonmenu.mvc", produces = "application/json")
public @ResponseBody public @ResponseBody
List<LessonMenuItem> showLeftNav(HttpSession session) { List<LessonMenuItem> showLeftNav(HttpSession session) {
List<LessonMenuItem> menu = new ArrayList<LessonMenuItem>(); List<LessonMenuItem> menu = new ArrayList<LessonMenuItem>();

View File

@ -53,7 +53,7 @@ public class LessonPlanService extends BaseService {
* @param session a {@link javax.servlet.http.HttpSession} object. * @param session a {@link javax.servlet.http.HttpSession} object.
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
@RequestMapping(value = "/lessonplan.mvc", produces = "application/html") @RequestMapping(path = "/lessonplan.mvc", produces = "application/html")
public @ResponseBody public @ResponseBody
String showPlan(HttpSession session) { String showPlan(HttpSession session) {
WebSession ws = getWebSession(session); WebSession ws = getWebSession(session);

View File

@ -24,7 +24,7 @@ public class LessonTitleService extends BaseService {
* @param session a {@link javax.servlet.http.HttpSession} object. * @param session a {@link javax.servlet.http.HttpSession} object.
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
@RequestMapping(value = "/lessontitle.mvc", produces = "application/html") @RequestMapping(path = "/lessontitle.mvc", produces = "application/html")
public @ResponseBody public @ResponseBody
String showPlan(HttpSession session) { String showPlan(HttpSession session) {
WebSession ws = getWebSession(session); WebSession ws = getWebSession(session);

View File

@ -58,7 +58,7 @@ public class ParameterService extends BaseService {
* @param session a {@link javax.servlet.http.HttpSession} object. * @param session a {@link javax.servlet.http.HttpSession} object.
* @return a {@link java.util.List} object. * @return a {@link java.util.List} object.
*/ */
@RequestMapping(value = "/parameter.mvc", produces = "application/json") @RequestMapping(path = "/parameter.mvc", produces = "application/json")
public @ResponseBody public @ResponseBody
List<RequestParameter> showParameters(HttpSession session) { List<RequestParameter> showParameters(HttpSession session) {
WebSession ws = getWebSession(session); WebSession ws = getWebSession(session);

View File

@ -63,7 +63,7 @@ public class PluginReloadService extends BaseService {
* @param session a {@link javax.servlet.http.HttpSession} object. * @param session a {@link javax.servlet.http.HttpSession} object.
* @return a {@link org.springframework.http.ResponseEntity} object. * @return a {@link org.springframework.http.ResponseEntity} object.
*/ */
@RequestMapping(value = "/reloadplugins.mvc", produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/reloadplugins.mvc", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody public @ResponseBody
ResponseEntity<Map<String, Object>> reloadPlugins(HttpSession session) { ResponseEntity<Map<String, Object>> reloadPlugins(HttpSession session) {
WebSession webSession = (WebSession) session.getAttribute(WebSession.SESSION); WebSession webSession = (WebSession) session.getAttribute(WebSession.SESSION);

View File

@ -47,7 +47,7 @@ public class RestartLessonService extends BaseService {
* @param session a {@link javax.servlet.http.HttpSession} object. * @param session a {@link javax.servlet.http.HttpSession} object.
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
@RequestMapping(value = "/restartlesson.mvc", produces = "text/text") @RequestMapping(path = "/restartlesson.mvc", produces = "text/text")
public @ResponseBody public @ResponseBody
String restartLesson(HttpSession session) { String restartLesson(HttpSession session) {
WebSession ws = getWebSession(session); WebSession ws = getWebSession(session);

View File

@ -32,7 +32,7 @@ public class SessionService extends BaseService {
* @param request a {@link javax.servlet.http.HttpServletRequest} object. * @param request a {@link javax.servlet.http.HttpServletRequest} object.
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
@RequestMapping(value = "/session.mvc", produces = "application/json") @RequestMapping(path = "/session.mvc", produces = "application/json")
public @ResponseBody public @ResponseBody
String showSession(HttpServletRequest request, HttpSession session) { String showSession(HttpServletRequest request, HttpSession session) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();

View File

@ -53,7 +53,7 @@ public class SolutionService extends BaseService {
* @param session a {@link javax.servlet.http.HttpSession} object. * @param session a {@link javax.servlet.http.HttpSession} object.
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
@RequestMapping(value = "/solution.mvc", produces = "text/html") @RequestMapping(path = "/solution.mvc", produces = "text/html")
public @ResponseBody public @ResponseBody
String showSolution(HttpSession session) { String showSolution(HttpSession session) {
WebSession ws = getWebSession(session); WebSession ws = getWebSession(session);

View File

@ -57,7 +57,7 @@ public class SourceService extends BaseService {
* @param session a {@link javax.servlet.http.HttpSession} object. * @param session a {@link javax.servlet.http.HttpSession} object.
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
@RequestMapping(value = "/source.mvc", produces = "application/text") @RequestMapping(path = "/source.mvc", produces = "application/text")
public @ResponseBody public @ResponseBody
String showSource(HttpSession session) { String showSource(HttpSession session) {
WebSession ws = getWebSession(session); WebSession ws = getWebSession(session);

View File

@ -3,10 +3,13 @@ package org.owasp.webgoat.session;
import org.owasp.webgoat.HammerHead; import org.owasp.webgoat.HammerHead;
import org.owasp.webgoat.lessons.AbstractLesson; import org.owasp.webgoat.lessons.AbstractLesson;
import org.owasp.webgoat.lessons.Category; import org.owasp.webgoat.lessons.Category;
import org.owasp.webgoat.plugins.LegacyLoader;
import org.owasp.webgoat.plugins.Plugin; import org.owasp.webgoat.plugins.Plugin;
import org.owasp.webgoat.plugins.PluginsLoader; import org.owasp.webgoat.plugins.PluginsLoader;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import java.io.File; import java.io.File;
@ -18,16 +21,6 @@ import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.ServletContext;
import org.owasp.webgoat.HammerHead;
import org.owasp.webgoat.lessons.AbstractLesson;
import org.owasp.webgoat.lessons.Category;
import org.owasp.webgoat.plugins.LegacyLoader;
import org.owasp.webgoat.plugins.Plugin;
import org.owasp.webgoat.plugins.PluginsLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
************************************************************************************************* *************************************************************************************************
@ -63,7 +56,7 @@ public class Course {
final Logger logger = LoggerFactory.getLogger(Course.class); final Logger logger = LoggerFactory.getLogger(Course.class);
private final List<AbstractLesson> lessons = new LinkedList<AbstractLesson>(); private List<AbstractLesson> lessons = new LinkedList<AbstractLesson>();
private final static String PROPERTIES_FILENAME = HammerHead.propertiesPath; private final static String PROPERTIES_FILENAME = HammerHead.propertiesPath;
@ -262,7 +255,7 @@ public class Course {
* Gets the lessons attribute of the Course object * Gets the lessons attribute of the Course object
* *
* @param category Description of the Parameter * @param category Description of the Parameter
* @param role Description of the Parameter * @param roles Description of the Parameter
* @return The lessons value * @return The lessons value
*/ */
private List<AbstractLesson> getLessons(Category category, List roles) { private List<AbstractLesson> getLessons(Category category, List roles) {
@ -322,15 +315,30 @@ public class Course {
return null; return null;
} }
public void setLessons(List<AbstractLesson> lessons) {
this.lessons = lessons;
}
/** /**
* <p>loadLessonFromPlugin.</p> * <p>loadLessonFromPlugin.</p>
* *
* @param context a {@link javax.servlet.ServletContext} object. * @param context a {@link javax.servlet.ServletContext} object.
*/ */
public void loadLessonFromPlugin(ServletContext context) { public void loadLessonFromPlugin(ServletContext context) {
Resource resource = new ClassPathResource("/plugin_lessons/plugin_lessons_marker.txt");
String pluginPath = null;
String targetPath = null;
try {
pluginPath = resource.getFile().getParent();
targetPath = pluginPath;
} catch (IOException e) {
e.printStackTrace();
}
logger.debug("Loading plugins into cache"); logger.debug("Loading plugins into cache");
String pluginPath = context.getRealPath("plugin_lessons"); //String pluginPath = context.getRealPath("plugin_lessons");
String targetPath = context.getRealPath("plugin_extracted"); //String targetPath = context.getRealPath("plugin_extracted");
if (pluginPath == null) { if (pluginPath == null) {
logger.error("Plugins directory {} not found", pluginPath); logger.error("Plugins directory {} not found", pluginPath);

View File

@ -2,9 +2,9 @@ package org.owasp.webgoat.session;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Properties; import java.util.Properties;
@ -57,12 +57,14 @@ public class WebgoatProperties extends Properties {
if (propertiesFileName == null) { if (propertiesFileName == null) {
throw new IOException("Path to webgoat.properties is null, initialization must have failed"); throw new IOException("Path to webgoat.properties is null, initialization must have failed");
} }
File propertiesFile = new File(propertiesFileName);
if (propertiesFile.exists() == false) { // File propertiesFile = new File(propertiesFileName);
throw new IOException("Unable to locate webgoat.properties at: " + propertiesFileName); // if (propertiesFile.exists() == false) {
} // throw new IOException("Unable to locate webgoat.properties at: " + propertiesFileName);
FileInputStream in = new FileInputStream(propertiesFile); // }
load(in); Resource resource = new ClassPathResource("/webgoat.properties");
//FileInputStream in = new FileInputStream(propertiesFile);
load(resource.getInputStream());
} }
/** /**

View File

@ -7,7 +7,6 @@ import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.UrlResource; import org.springframework.core.io.UrlResource;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.inject.Singleton;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Arrays; import java.util.Arrays;
@ -47,7 +46,6 @@ import java.util.Locale;
* @author dm * @author dm
*/ */
@Component @Component
@Singleton
public class LabelProvider { public class LabelProvider {
/** Constant <code>DEFAULT_LANGUAGE="Locale.ENGLISH.getLanguage()"</code> */ /** Constant <code>DEFAULT_LANGUAGE="Locale.ENGLISH.getLanguage()"</code> */
public final static String DEFAULT_LANGUAGE = Locale.ENGLISH.getLanguage(); public final static String DEFAULT_LANGUAGE = Locale.ENGLISH.getLanguage();

View File

@ -0,0 +1,11 @@
#spring.mvc.view.prefix=/WEB-INF/jsp/
#spring.mvc.view.suffix=.jsp
#server.servlet-path=/*
#server.jsp-servlet.class-name=org.apache.jasper.servlet.JspServlet
#server.jsp-servlet.registered=true
server.error.include-stacktrace=always
logging.level.org.springframework=DEBUG
logging.level.org.hibernate=ERROR
spring.thymeleaf.cache=false
security.enable-csrf=false

View File

Before

Width:  |  Height:  |  Size: 669 B

After

Width:  |  Height:  |  Size: 669 B

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View File

Before

Width:  |  Height:  |  Size: 197 KiB

After

Width:  |  Height:  |  Size: 197 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 690 B

After

Width:  |  Height:  |  Size: 690 B

View File

Before

Width:  |  Height:  |  Size: 563 B

After

Width:  |  Height:  |  Size: 563 B

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 684 B

After

Width:  |  Height:  |  Size: 684 B

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 784 B

After

Width:  |  Height:  |  Size: 784 B

View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 878 B

After

Width:  |  Height:  |  Size: 878 B

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 716 B

After

Width:  |  Height:  |  Size: 716 B

View File

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 95 KiB

View File

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 83 KiB

View File

Before

Width:  |  Height:  |  Size: 798 B

After

Width:  |  Height:  |  Size: 798 B

View File

Before

Width:  |  Height:  |  Size: 669 B

After

Width:  |  Height:  |  Size: 669 B

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 49 B

After

Width:  |  Height:  |  Size: 49 B

View File

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Some files were not shown because too many files have changed in this diff Show More