Skip to content

Commit 4c166e2

Browse files
committed
Docker config
1 parent f175504 commit 4c166e2

File tree

6 files changed

+38
-33
lines changed

6 files changed

+38
-33
lines changed

VulnerableJavaWebApp/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# JDK 8 + Maven 3.3.9
2+
FROM maven:3.3.9-jdk-8
3+
4+
# Prepare the folder
5+
RUN mkdir -p /app
6+
COPY . /app
7+
WORKDIR /app
8+
9+
# Generates the package
10+
RUN mvn install
11+
12+
# Http port
13+
ENV PORT 9000
14+
EXPOSE $PORT
15+
16+
# Executes spring boot's jar
17+
CMD ["java", "-jar", "target/vulnerablejavawebapp-0.0.1-SNAPSHOT.jar"]

VulnerableJavaWebApp/pom.xml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<parent>
1111
<groupId>org.springframework.boot</groupId>
1212
<artifactId>spring-boot-starter-parent</artifactId>
13-
<version>1.4.0.RELEASE</version>
13+
<version>1.4.2.RELEASE</version>
1414
</parent>
1515

1616
<properties>
@@ -41,5 +41,21 @@
4141
<artifactId>h2</artifactId>
4242
</dependency>
4343
</dependencies>
44+
<build>
45+
<plugins>
46+
<plugin>
47+
<groupId>org.springframework.boot</groupId>
48+
<artifactId>spring-boot-maven-plugin</artifactId>
49+
<version>${parent.version}</version>
50+
<executions>
51+
<execution>
52+
<goals>
53+
<goal>repackage</goal>
54+
</goals>
55+
</execution>
56+
</executions>
57+
</plugin>
58+
</plugins>
59+
</build>
4460

45-
</project>
61+
</project>

VulnerableJavaWebApp/src/main/java/com/github/rafaelrpinto/vulnerablejavawebapp/config/AppLauncher.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,10 @@
99
import javax.servlet.SessionTrackingMode;
1010
import javax.sql.DataSource;
1111

12-
import org.apache.catalina.connector.Connector;
13-
import org.apache.coyote.http11.Http11NioProtocol;
1412
import org.springframework.beans.factory.annotation.Autowired;
1513
import org.springframework.boot.SpringApplication;
1614
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
17-
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
1815
import org.springframework.boot.context.embedded.ServletContextInitializer;
19-
import org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer;
20-
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
2116
import org.springframework.boot.web.servlet.FilterRegistrationBean;
2217
import org.springframework.context.annotation.Bean;
2318
import org.springframework.context.annotation.ComponentScan;
@@ -96,29 +91,4 @@ public void onStartup(ServletContext servletContext) throws ServletException {
9691
};
9792

9893
}
99-
100-
@Bean
101-
public EmbeddedServletContainerFactory servletContainer() {
102-
// https config
103-
final String keystorePass = "abcd1234";
104-
final String keystoreType = "PKCS12";
105-
final String keystoreProvider = "SunJSSE";
106-
final String keystoreAlias = "tomcat";
107-
final String keystoreAbsolutePath = getClass().getClassLoader().getResource("ssl/keystore.p12").getFile();
108-
109-
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
110-
factory.addConnectorCustomizers((TomcatConnectorCustomizer) (Connector con) -> {
111-
con.setScheme("https");
112-
con.setSecure(true);
113-
Http11NioProtocol proto = (Http11NioProtocol) con.getProtocolHandler();
114-
proto.setSSLEnabled(true);
115-
proto.setKeystoreFile(keystoreAbsolutePath);
116-
proto.setKeystorePass(keystorePass);
117-
proto.setKeystoreType(keystoreType);
118-
proto.setProperty("keystoreProvider", keystoreProvider);
119-
proto.setKeyAlias(keystoreAlias);
120-
});
121-
122-
return factory;
123-
}
12494
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
server.port=9000
1+
server.port=9000
2+
server.ssl.key-store = classpath:keystore.jks
3+
server.ssl.key-password = secret
2.2 KB
Binary file not shown.
-2.52 KB
Binary file not shown.

0 commit comments

Comments
 (0)