Lessons which load JavaScript etc now works

This commit is contained in:
Nanne Baars
2016-04-26 18:59:51 +02:00
parent 9066e45725
commit 79102c6ddd
17 changed files with 222 additions and 559 deletions

View File

@ -1,11 +1,25 @@
package org.owasp.webgoat;
import org.owasp.webgoat.plugins.PluginsLoader;
import org.owasp.webgoat.session.Course;
import org.owasp.webgoat.session.WebSession;
import org.owasp.webgoat.session.WebgoatContext;
import org.owasp.webgoat.session.WebgoatProperties;
import org.springframework.beans.factory.annotation.Qualifier;
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 org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import javax.servlet.ServletContext;
import java.io.File;
@SpringBootApplication
@PropertySource("classpath:/webgoat.properties")
public class WebGoat extends SpringBootServletInitializer {
@Override
@ -17,28 +31,31 @@ public class WebGoat extends SpringBootServletInitializer {
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;
// }
@Bean(name = "pluginTargetDirectory")
public File pluginTargetDirectory() {
File tempDir = com.google.common.io.Files.createTempDir();
tempDir.deleteOnExit();
return tempDir;
}
@Bean
public PluginsLoader pluginsLoader(@Qualifier("pluginTargetDirectory") File pluginTargetDirectory) {
System.out.println("Plugin target directory: " + pluginTargetDirectory.toString());
return new PluginsLoader(pluginTargetDirectory);
}
@Bean
@Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
public WebSession webSession(Course course, WebgoatContext webgoatContext, ServletContext context) {
return new WebSession(course, webgoatContext, context);
}
@Bean
public Course course(PluginsLoader pluginsLoader, WebgoatContext webgoatContext, ServletContext context,
WebgoatProperties webgoatProperties) {
Course course = new Course(webgoatProperties);
course.loadCourses(webgoatContext, context, "/");
course.loadLessonFromPlugin(pluginsLoader.loadPlugins());
return course;
}
}