mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-21 22:50:42 +08:00
fix: SpELGzipPacker class not found
This commit is contained in:
@@ -25,6 +25,7 @@ public class ContainerTool {
|
||||
public static final MountableFile springBoot2UndertowJarFile = MountableFile.forHostPath(Path.of("..", "vul", "vul-springboot2-undertow", "build", "libs", "vul-springboot2-undertow.jar").toAbsolutePath());
|
||||
public static final MountableFile springBoot2WebfluxJarFile = MountableFile.forHostPath(Path.of("..", "vul", "vul-springboot2-webflux", "build", "libs", "vul-springboot2-webflux.jar").toAbsolutePath());
|
||||
public static final MountableFile springBoot3JarFile = MountableFile.forHostPath(Path.of("..", "vul", "vul-springboot3", "build", "libs", "vul-springboot3.jar").toAbsolutePath());
|
||||
public static final MountableFile springBoot359JarFile = MountableFile.forHostPath(Path.of("..", "vul", "vul-springboot359", "build", "libs", "vul-springboot359.jar").toAbsolutePath());
|
||||
public static final MountableFile springBoot3WebfluxJarFile = MountableFile.forHostPath(Path.of("..", "vul", "vul-springboot3-webflux", "build", "libs", "vul-springboot3-webflux.jar").toAbsolutePath());
|
||||
|
||||
public static final Path neoGeorgDockerfile = Path.of("..", "assets", "neoreg", "Dockerfile").toAbsolutePath();
|
||||
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
package com.reajason.javaweb.integration.memshell.springwebmvc;
|
||||
|
||||
import com.reajason.javaweb.Server;
|
||||
import com.reajason.javaweb.integration.AbstractContainerTest;
|
||||
import com.reajason.javaweb.integration.ContainerTestConfig;
|
||||
import com.reajason.javaweb.integration.ContainerTool;
|
||||
import com.reajason.javaweb.memshell.ShellTool;
|
||||
import com.reajason.javaweb.memshell.ShellType;
|
||||
import com.reajason.javaweb.packer.Packers;
|
||||
import net.bytebuddy.jar.asm.Opcodes;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.testcontainers.containers.GenericContainer;
|
||||
import org.testcontainers.containers.Network;
|
||||
import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @author ReaJason
|
||||
* @since 2024/12/22
|
||||
*/
|
||||
@Testcontainers
|
||||
public class SpringBoot359ContainerTest extends AbstractContainerTest {
|
||||
private static final ContainerTestConfig CONFIG = ContainerTestConfig.builder()
|
||||
.imageName("eclipse-temurin:17.0.17_10-jdk")
|
||||
.jarFile(ContainerTool.springBoot359JarFile)
|
||||
.jakarta(true)
|
||||
.jarDeployPath("/app/app.jar")
|
||||
.command("java -jar /app/app.jar")
|
||||
.server(Server.SpringWebMvc)
|
||||
.pidScript(ContainerTool.springbootPid)
|
||||
.targetJdkVersion(Opcodes.V17)
|
||||
.enableJspPackerTest(false)
|
||||
.contextPath("")
|
||||
.healthCheckPath("/test")
|
||||
.supportedShellTypes(List.of(
|
||||
ShellType.SPRING_WEBMVC_JAKARTA_INTERCEPTOR,
|
||||
ShellType.SPRING_WEBMVC_JAKARTA_CONTROLLER_HANDLER,
|
||||
ShellType.SPRING_WEBMVC_AGENT_FRAMEWORK_SERVLET
|
||||
))
|
||||
.testPackers(List.of(Packers.H2))
|
||||
.unSupportedShellTools(List.of(ShellTool.AntSword))
|
||||
.probeShellTypes(List.of(
|
||||
ShellType.SPRING_WEBMVC_JAKARTA_INTERCEPTOR,
|
||||
ShellType.SPRING_WEBMVC_JAKARTA_CONTROLLER_HANDLER
|
||||
))
|
||||
.build();
|
||||
|
||||
private static final ContainerTestConfig TOMCAT_CONFIG = ContainerTestConfig.builder()
|
||||
.imageName("springboot3")
|
||||
.server(Server.Tomcat)
|
||||
.targetJdkVersion(Opcodes.V17)
|
||||
.supportedShellTypes(List.of(
|
||||
ShellType.JAKARTA_FILTER,
|
||||
// ShellType.LISTENER,
|
||||
ShellType.JAKARTA_VALVE,
|
||||
ShellType.JAKARTA_WEBSOCKET,
|
||||
ShellType.AGENT_FILTER_CHAIN,
|
||||
ShellType.CATALINA_AGENT_CONTEXT_VALVE
|
||||
))
|
||||
.testPackers(List.of(Packers.H2))
|
||||
.unSupportedShellTools(List.of(ShellTool.AntSword))
|
||||
.build();
|
||||
|
||||
static Network network = newNetwork();
|
||||
@Container
|
||||
public static final GenericContainer<?> python = buildPythonContainer(network);
|
||||
|
||||
@Container
|
||||
public static final GenericContainer<?> container = buildContainer(CONFIG, network);
|
||||
|
||||
static Stream<Arguments> tomcatCasesProvider() {
|
||||
return generateTestCases(TOMCAT_CONFIG);
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "{0}|{1}{2}|{3}")
|
||||
@MethodSource("tomcatCasesProvider")
|
||||
void testTomcat(String imageName, String shellType, String shellTool, Packers packer) {
|
||||
runShellInject(TOMCAT_CONFIG, shellType, shellTool, packer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ContainerTestConfig getConfig() {
|
||||
return CONFIG;
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
package com.reajason.javaweb.integration.memshell.springwebmvc;
|
||||
|
||||
import com.reajason.javaweb.Server;
|
||||
import com.reajason.javaweb.integration.ShellAssertion;
|
||||
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.testcontainers.containers.GenericContainer;
|
||||
import org.testcontainers.containers.wait.strategy.Wait;
|
||||
import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static com.reajason.javaweb.integration.ContainerTool.*;
|
||||
import static org.junit.jupiter.params.provider.Arguments.arguments;
|
||||
|
||||
/**
|
||||
* @author ReaJason
|
||||
* @since 2024/12/22
|
||||
*/
|
||||
@Testcontainers
|
||||
@Slf4j
|
||||
public class SpringBoot359ExpressionContainerTest {
|
||||
public static final String imageName = "springboot3";
|
||||
|
||||
@Container
|
||||
public final static GenericContainer<?> container = new GenericContainer<>("eclipse-temurin:17.0.17_10-jdk")
|
||||
.withCopyFileToContainer(springBoot359JarFile, "/app/app.jar")
|
||||
.withCommand("java -jar /app/app.jar")
|
||||
.withCopyToContainer(jattachFile, "/jattach")
|
||||
.withCopyToContainer(springbootPid, "/fetch_pid.sh")
|
||||
.waitingFor(Wait.forHttp("/test"))
|
||||
.withExposedPorts(8080);
|
||||
|
||||
|
||||
public static String getUrl(GenericContainer<?> container) {
|
||||
String host = container.getHost();
|
||||
int port = container.getMappedPort(8080);
|
||||
String url = "http://" + host + ":" + port;
|
||||
log.info("container started, app url is : {}", url);
|
||||
return url;
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void tearDown() {
|
||||
String logs = container.getLogs();
|
||||
log.info(logs);
|
||||
// assertThat("Logs should not contain any exceptions", logs, doesNotContainException());
|
||||
}
|
||||
|
||||
static Stream<Arguments> casesProvider() {
|
||||
return Stream.of(
|
||||
arguments(imageName, ShellType.JAKARTA_VALVE, ShellTool.Godzilla, Packers.SpELSpringGzipJDK17),
|
||||
arguments(imageName, ShellType.JAKARTA_VALVE, ShellTool.Godzilla, Packers.OGNLSpringGzipJDK17),
|
||||
arguments(imageName, ShellType.JAKARTA_VALVE, ShellTool.Godzilla, Packers.JXPathSpringGzipJDK17)
|
||||
);
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "{0}-expression|{1}{2}|{3}")
|
||||
@MethodSource("casesProvider")
|
||||
void test(String imageName, String shellType, String shellTool, Packers packer) {
|
||||
ShellAssertion.shellInjectIsOk(getUrl(container), Server.Tomcat, shellType, shellTool, Opcodes.V17, packer, container);
|
||||
}
|
||||
}
|
||||
-2
@@ -1,7 +1,6 @@
|
||||
package com.reajason.javaweb.integration.memshell.springwebmvc;
|
||||
|
||||
import com.reajason.javaweb.Server;
|
||||
import com.reajason.javaweb.integration.ContainerTool;
|
||||
import com.reajason.javaweb.integration.ShellAssertion;
|
||||
import com.reajason.javaweb.memshell.ShellTool;
|
||||
import com.reajason.javaweb.memshell.ShellType;
|
||||
@@ -14,7 +13,6 @@ import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.testcontainers.containers.GenericContainer;
|
||||
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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user