diff --git a/README.MD b/README.MD index 55cccd8dc..f992a45d8 100644 --- a/README.MD +++ b/README.MD @@ -175,3 +175,23 @@ show an extra set of links below the cookie overview. To be able to see which labels are loaded through a property file, open up the developer tools avalailable from the info menu After the reload is complete, all labels which are loaded from a property file will be __marked green__. + + +## Docker support + +WebGoat now has Docker support you can build a container with the following commands: + +```Shell +cd WebGoat +mvn -pl webgoat-container package docker:build +``` + +With the following command you are able to run the Docker container on your local machine: + +```Shell +docker run -p 8080:8080 -t webgoat/webgoat-container +docker ps +``` + +With the last command you are able to determine ip address to connect to. +At the moment the Docker image is not distributed to a Docker registry. \ No newline at end of file diff --git a/webgoat-container/pom.xml b/webgoat-container/pom.xml index cf8ae6909..d37c2cba7 100644 --- a/webgoat-container/pom.xml +++ b/webgoat-container/pom.xml @@ -113,6 +113,22 @@ + + com.spotify + docker-maven-plugin + 0.4.10 + + webgoat/${project.artifactId} + src/main/docker + + + / + ${project.build.directory} + ${project.build.finalName}.war + + + + org.apache.maven.plugins maven-jar-plugin @@ -182,21 +198,23 @@ org.springframework.boot spring-boot-maven-plugin - - - - repackage - - - - - org.thymeleaf.extra - thymeleaf-extras-springsecurity4 - - - - - + + + + + org.thymeleaf.extra + thymeleaf-extras-springsecurity4 + + + org.asciidoctor + asciidoctorj + + + org.jruby + jruby-complete + + + @@ -322,7 +340,11 @@ guava ${guava.version} - + + com.spotify + docker-maven-plugin + 0.4.10 + diff --git a/webgoat-container/src/main/docker/Dockerfile b/webgoat-container/src/main/docker/Dockerfile new file mode 100644 index 000000000..d9198d7db --- /dev/null +++ b/webgoat-container/src/main/docker/Dockerfile @@ -0,0 +1,5 @@ +FROM frolvlad/alpine-oraclejdk8:slim +VOLUME /tmp +ADD webgoat-container-7.1-SNAPSHOT.war webgoat.jar +RUN sh -c 'touch /webgoat.jar' +ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/webgoat.jar"] \ No newline at end of file diff --git a/webgoat-container/src/main/java/org/owasp/webgoat/plugins/PluginsLoader.java b/webgoat-container/src/main/java/org/owasp/webgoat/plugins/PluginsLoader.java index 6e9f854f0..1600f559a 100644 --- a/webgoat-container/src/main/java/org/owasp/webgoat/plugins/PluginsLoader.java +++ b/webgoat-container/src/main/java/org/owasp/webgoat/plugins/PluginsLoader.java @@ -27,8 +27,8 @@ import java.util.concurrent.CompletionService; import java.util.concurrent.ExecutorCompletionService; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.jar.JarFile; import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; /** *

PluginsLoader class.

@@ -58,11 +58,11 @@ public class PluginsLoader { public List loadPlugins() { List plugins = Lists.newArrayList(); try { - File jarFile = new File(this.getClass().getProtectionDomain().getCodeSource().getLocation().getFile()); - if (jarFile.isDirectory()) { - extractToTempDirectoryFromExplodedDirectory(jarFile); + URL location = this.getClass().getProtectionDomain().getCodeSource().getLocation(); + if (ResourceUtils.isFileURL(location)) { + extractToTempDirectoryFromExplodedDirectory(ResourceUtils.getFile(location)); } else { - extractToTempDirectoryFromJarFile(jarFile); + extractToTempDirectoryFromJarFile(ResourceUtils.getFile(ResourceUtils.extractJarFileURL(location))); } List jars = listJars(); plugins = processPlugins(jars); @@ -73,7 +73,7 @@ public class PluginsLoader { } private void extractToTempDirectoryFromJarFile(File jarFile) throws IOException { - JarFile jar = new JarFile(jarFile); + ZipFile jar = new ZipFile(jarFile); Enumeration entries = jar.entries(); while (entries.hasMoreElements()) { ZipEntry zipEntry = entries.nextElement(); @@ -83,7 +83,7 @@ public class PluginsLoader { } } - private void unpack(JarFile jar, ZipEntry zipEntry) throws IOException { + private void unpack(ZipFile jar, ZipEntry zipEntry) throws IOException { try (InputStream inputStream = jar.getInputStream(zipEntry)) { String name = zipEntry.getName(); if (name.lastIndexOf("/") != -1) {