diff --git a/integration-test/docker-compose/wildfly/docker-compose-26.yaml b/integration-test/docker-compose/wildfly/docker-compose-26.yaml new file mode 100644 index 00000000..a0205a70 --- /dev/null +++ b/integration-test/docker-compose/wildfly/docker-compose-26.yaml @@ -0,0 +1,11 @@ +services: + wildfly26: + image: quay.io/wildfly/wildfly:26.1.3.Final-jdk11 + container_name: wildfly26 + ports: + - 8080:8080 + - 5005:5005 + environment: + JAVA_OPTS: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 + volumes: + - ../../../vul/vul-webapp-jakarta/build/libs/vul-webapp.war:/opt/jboss/wildfly/standalone/deployments/app.war \ No newline at end of file diff --git a/integration-test/docker-compose/wildfly/docker-compose-27.yaml b/integration-test/docker-compose/wildfly/docker-compose-27.yaml new file mode 100644 index 00000000..cb17f69f --- /dev/null +++ b/integration-test/docker-compose/wildfly/docker-compose-27.yaml @@ -0,0 +1,11 @@ +services: + wildfly27: + image: quay.io/wildfly/wildfly:27.0.1.Final-jdk11 + container_name: wildfly27 + ports: + - 8080:8080 + - 5005:5005 + environment: + JAVA_OPTS: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 + volumes: + - ../../../vul/vul-webapp-jakarta/build/libs/vul-webapp-jakarta.war:/opt/jboss/wildfly/standalone/deployments/app.war \ No newline at end of file diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/springwebmvc/SpringBoot1ContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/springwebmvc/SpringBoot1ContainerTest.java index e74501d4..fe047fa6 100644 --- a/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/springwebmvc/SpringBoot1ContainerTest.java +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/springwebmvc/SpringBoot1ContainerTest.java @@ -57,7 +57,7 @@ public class SpringBoot1ContainerTest { ShellType.SPRING_WEBMVC_CONTROLLER_HANDLER, ShellType.SPRING_WEBMVC_AGENT_FRAMEWORK_SERVLET ); - List testPackers = List.of(Packers.ScriptEngine, Packers.SpEL, Packers.Base64); + List testPackers = List.of(Packers.SpEL); return TestCasesProvider.getTestCases(imageName, server, supportedShellTypes, testPackers); } diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/springwebmvc/SpringBoot2ContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/springwebmvc/SpringBoot2ContainerTest.java index a4987896..84520b86 100644 --- a/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/springwebmvc/SpringBoot2ContainerTest.java +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/springwebmvc/SpringBoot2ContainerTest.java @@ -94,7 +94,7 @@ public class SpringBoot2ContainerTest { ShellType.AGENT_FILTER_CHAIN, ShellType.CATALINA_AGENT_CONTEXT_VALVE ); - List testPackers = List.of(Packers.ScriptEngine, Packers.SpEL, Packers.Base64, Packers.H2JS); + List testPackers = List.of(Packers.H2JS); return TestCasesProvider.getTestCases(imageName, server, supportedShellTypes, testPackers); } diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/springwebmvc/SpringBoot2JettyContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/springwebmvc/SpringBoot2JettyContainerTest.java index 31a875bb..a197edc1 100644 --- a/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/springwebmvc/SpringBoot2JettyContainerTest.java +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/springwebmvc/SpringBoot2JettyContainerTest.java @@ -87,16 +87,18 @@ public class SpringBoot2JettyContainerTest { List supportedShellTypes = List.of( ShellType.SERVLET, ShellType.FILTER, + ShellType.HANDLER, + ShellType.CUSTOMIZER, // ShellType.LISTENER, ShellType.JETTY_AGENT_HANDLER ); - List testPackers = List.of(Packers.ScriptEngine, Packers.SpEL, Packers.Base64); + List testPackers = List.of(Packers.SpEL); return TestCasesProvider.getTestCases(imageName, server, supportedShellTypes, testPackers); } @ParameterizedTest(name = "{0}|{1}{2}|{3}") @MethodSource("jettyCasesProvider") void testJetty(String imageName, String shellType, String shellTool, Packers packer) { - shellInjectIsOk(getUrl(container), Server.Jetty, shellType, shellTool, Opcodes.V1_8, packer, container, python); + shellInjectIsOk(getUrl(container), Server.Jetty, "7+", shellType, shellTool, Opcodes.V1_8, packer, container, python); } } diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/springwebmvc/SpringBoot2UndertowContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/springwebmvc/SpringBoot2UndertowContainerTest.java index 5eabf475..eb11f68d 100644 --- a/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/springwebmvc/SpringBoot2UndertowContainerTest.java +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/springwebmvc/SpringBoot2UndertowContainerTest.java @@ -90,7 +90,7 @@ public class SpringBoot2UndertowContainerTest { // ShellType.LISTENER, ShellType.UNDERTOW_AGENT_SERVLET_HANDLER ); - List testPackers = List.of(Packers.ScriptEngine, Packers.SpEL); + List testPackers = List.of(Packers.SpEL); return TestCasesProvider.getTestCases(imageName, server, supportedShellTypes, testPackers); } diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/springwebmvc/SpringBoot2WarContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/springwebmvc/SpringBoot2WarContainerTest.java index 4e20cc75..23330a43 100644 --- a/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/springwebmvc/SpringBoot2WarContainerTest.java +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/springwebmvc/SpringBoot2WarContainerTest.java @@ -81,7 +81,7 @@ public class SpringBoot2WarContainerTest { ShellType.AGENT_FILTER_CHAIN, ShellType.CATALINA_AGENT_CONTEXT_VALVE ); - List testPackers = List.of(Packers.ScriptEngine, Packers.SpEL, Packers.Base64); + List testPackers = List.of(Packers.SpEL); return TestCasesProvider.getTestCases(imageName, server, supportedShellTypes, testPackers); } diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/springwebmvc/SpringBoot3ContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/springwebmvc/SpringBoot3ContainerTest.java index 9e16b0b6..cf2b2fe9 100644 --- a/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/springwebmvc/SpringBoot3ContainerTest.java +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/springwebmvc/SpringBoot3ContainerTest.java @@ -58,7 +58,7 @@ public class SpringBoot3ContainerTest { ShellType.SPRING_WEBMVC_JAKARTA_CONTROLLER_HANDLER, ShellType.SPRING_WEBMVC_AGENT_FRAMEWORK_SERVLET ); - List testPackers = List.of(Packers.Base64, Packers.H2); + List testPackers = List.of(Packers.H2); return TestCasesProvider.getTestCases(imageName, server, supportedShellTypes, testPackers, null, List.of(ShellTool.AntSword)); } diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/wildfly/Wildfly26ContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/wildfly/Wildfly26ContainerTest.java new file mode 100644 index 00000000..699bf15d --- /dev/null +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/wildfly/Wildfly26ContainerTest.java @@ -0,0 +1,85 @@ +package com.reajason.javaweb.integration.memshell.wildfly; + +import com.reajason.javaweb.Server; +import com.reajason.javaweb.integration.ShellAssertion; +import com.reajason.javaweb.integration.TestCasesProvider; +import com.reajason.javaweb.memshell.ShellType; +import com.reajason.javaweb.packer.Packers; +import lombok.extern.slf4j.Slf4j; +import net.bytebuddy.jar.asm.Opcodes; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.ValueSource; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.Network; +import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.images.builder.ImageFromDockerfile; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; + +import java.util.List; +import java.util.stream.Stream; + +import static com.reajason.javaweb.integration.ContainerTool.*; +import static com.reajason.javaweb.integration.DoesNotContainExceptionMatcher.doesNotContainException; +import static com.reajason.javaweb.integration.ShellAssertion.shellInjectIsOk; +import static org.hamcrest.MatcherAssert.assertThat; + +/** + * @author ReaJason + * @since 2024/12/10 + */ +@Slf4j +@Testcontainers +public class Wildfly26ContainerTest { + public static final String imageName = "quay.io/wildfly/wildfly:26.1.3.Final-jdk11"; + static Network network = Network.newNetwork(); + @Container + public final static GenericContainer python = new GenericContainer<>(new ImageFromDockerfile() + .withDockerfile(neoGeorgDockerfile)) + .withNetwork(network); + @Container + public static final GenericContainer container = new GenericContainer<>(imageName) + .withCopyToContainer(warFile, "/opt/jboss/wildfly/standalone/deployments/app.war") + .withCopyToContainer(jattachFile, "/jattach") + .withCopyToContainer(jbossPid, "/fetch_pid.sh") + .withNetwork(network) + .withNetworkAliases("app") + .waitingFor(Wait.forHttp("/app")) + .withExposedPorts(8080); + + static Stream casesProvider() { + String server = Server.Undertow; + List supportedShellTypes = List.of( + ShellType.SERVLET, + ShellType.FILTER, + ShellType.LISTENER, + ShellType.UNDERTOW_AGENT_SERVLET_HANDLER + ); + List testPackers = List.of(Packers.JSP); + return TestCasesProvider.getTestCases(imageName, server, supportedShellTypes, testPackers); + } + + @AfterAll + static void tearDown() { + String logs = container.getLogs(); + assertThat("Logs should not contain any exceptions", logs, doesNotContainException()); + } + + @ParameterizedTest(name = "{0}|{1}{2}|{3}") + @MethodSource("casesProvider") + void test(String imageName, String shellType, String shellTool, Packers packer) { + shellInjectIsOk(getUrl(container), Server.Undertow, shellType, shellTool, Opcodes.V11, packer, container, python); + } + + @ParameterizedTest + @ValueSource(strings = { ShellType.SERVLET, + ShellType.FILTER, + ShellType.LISTENER,}) + void testProbeInject(String shellType) { + String url = getUrl(container); + ShellAssertion.testProbeInject(url, Server.Undertow, shellType, Opcodes.V11); + } +} diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/wildfly/Wildfly27ContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/wildfly/Wildfly27ContainerTest.java new file mode 100644 index 00000000..bc4d235e --- /dev/null +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/memshell/wildfly/Wildfly27ContainerTest.java @@ -0,0 +1,88 @@ +package com.reajason.javaweb.integration.memshell.wildfly; + +import com.reajason.javaweb.Server; +import com.reajason.javaweb.integration.ShellAssertion; +import com.reajason.javaweb.integration.TestCasesProvider; +import com.reajason.javaweb.memshell.ShellTool; +import com.reajason.javaweb.memshell.ShellType; +import com.reajason.javaweb.packer.Packers; +import lombok.extern.slf4j.Slf4j; +import net.bytebuddy.jar.asm.Opcodes; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.ValueSource; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.Network; +import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.images.builder.ImageFromDockerfile; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; + +import java.util.List; +import java.util.stream.Stream; + +import static com.reajason.javaweb.integration.ContainerTool.*; +import static com.reajason.javaweb.integration.DoesNotContainExceptionMatcher.doesNotContainException; +import static com.reajason.javaweb.integration.ShellAssertion.shellInjectIsOk; +import static org.hamcrest.MatcherAssert.assertThat; + +/** + * @author ReaJason + * @since 2024/12/10 + */ +@Slf4j +@Testcontainers +public class Wildfly27ContainerTest { + public static final String imageName = "quay.io/wildfly/wildfly:27.0.1.Final-jdk11"; + static Network network = Network.newNetwork(); + @Container + public final static GenericContainer python = new GenericContainer<>(new ImageFromDockerfile() + .withDockerfile(neoGeorgDockerfile)) + .withNetwork(network); + @Container + public static final GenericContainer container = new GenericContainer<>(imageName) + .withCopyToContainer(warJakartaFile, "/opt/jboss/wildfly/standalone/deployments/app.war") + .withCopyToContainer(jattachFile, "/jattach") + .withCopyToContainer(jbossPid, "/fetch_pid.sh") + .withNetwork(network) + .withNetworkAliases("app") + .waitingFor(Wait.forHttp("/app")) + .withExposedPorts(8080); + + static Stream casesProvider() { + String server = Server.Undertow; + List supportedShellTypes = List.of( + ShellType.JAKARTA_SERVLET, + ShellType.JAKARTA_FILTER, + ShellType.JAKARTA_LISTENER, + ShellType.UNDERTOW_AGENT_SERVLET_HANDLER + ); + List testPackers = List.of(Packers.JSP); + return TestCasesProvider.getTestCases(imageName, server, supportedShellTypes, testPackers, + null, List.of(ShellTool.AntSword) // AntSword not support jakarta + ); + } + + @AfterAll + static void tearDown() { + String logs = container.getLogs(); + assertThat("Logs should not contain any exceptions", logs, doesNotContainException()); + } + + @ParameterizedTest(name = "{0}|{1}{2}|{3}") + @MethodSource("casesProvider") + void test(String imageName, String shellType, String shellTool, Packers packer) { + shellInjectIsOk(getUrl(container), Server.Undertow, shellType, shellTool, Opcodes.V11, packer, container, python); + } + + @ParameterizedTest + @ValueSource(strings = {ShellType.JAKARTA_SERVLET, + ShellType.JAKARTA_FILTER, + ShellType.JAKARTA_LISTENER,}) + void testProbeInject(String shellType) { + String url = getUrl(container); + ShellAssertion.testProbeInject(url, Server.Undertow, shellType, Opcodes.V11); + } +}