test: fix failed cases

This commit is contained in:
ReaJason
2025-12-08 01:43:41 +08:00
parent 772a8b5cb0
commit c5cdb03a9f
4 changed files with 53 additions and 1 deletions
@@ -412,6 +412,10 @@ public class ShellAssertion {
Pair<String, String> urls = ShellAssertion.getUrls(url, shellType, shellTool, packer); Pair<String, String> urls = ShellAssertion.getUrls(url, shellType, shellTool, packer);
String shellUrl = urls.getLeft(); String shellUrl = urls.getLeft();
String urlPattern = urls.getRight(); String urlPattern = urls.getRight();
if (urlPattern != null) {
shellUrl += "testProbe";
urlPattern += "testProbe";
}
ShellConfig shellConfig = ShellConfig.builder() ShellConfig shellConfig = ShellConfig.builder()
.server(server) .server(server)
.serverVersion(serverVersion) .serverVersion(serverVersion)
@@ -33,7 +33,7 @@ public class GlassFish7ContainerTest {
@Container @Container
public static final GenericContainer<?> container = new GenericContainer<>(imageName) public static final GenericContainer<?> container = new GenericContainer<>(imageName)
.withCopyToContainer(warJakartaFile, "/usr/local/glassfish7/glassfish/domains/domain1/autodeploy/app.war") .withCopyToContainer(warJakartaFile, "/usr/local/glassfish7/glassfish/domains/domain1/autodeploy/app.war")
.waitingFor(Wait.forLogMessage(".*deployed.*", 1)) .waitingFor(Wait.forLogMessage(".*(deployed|done).*", 1))
.withExposedPorts(8080); .withExposedPorts(8080);
@AfterAll @AfterAll
@@ -0,0 +1,24 @@
package com.reajason.javaweb.vul.springboot2.controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author ReaJason
* @since 2025/12/6
*/
@RestController
@RequestMapping("/biginteger")
public class BigIntegerClassLoaderController extends ClassLoader {
static byte[] decodeBigInteger(String bigIntegerStr) throws Exception {
Class<?> decoderClass = Class.forName("java.math.BigInteger");
return (byte[]) decoderClass.getMethod("toByteArray").invoke(decoderClass.getConstructor(String.class, int.class).newInstance(bigIntegerStr, Character.MAX_RADIX));
}
@PostMapping
public void base64ClassLoader(String data) throws Exception {
byte[] bytes = decodeBigInteger(data);
defineClass(null, bytes, 0, bytes.length).newInstance();
}
}
@@ -0,0 +1,24 @@
package com.reajason.javaweb.vul.springboot2.controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author ReaJason
* @since 2025/12/6
*/
@RestController
@RequestMapping("/biginteger")
public class BigIntegerClassLoaderController extends ClassLoader {
static byte[] decodeBigInteger(String bigIntegerStr) throws Exception {
Class<?> decoderClass = Class.forName("java.math.BigInteger");
return (byte[]) decoderClass.getMethod("toByteArray").invoke(decoderClass.getConstructor(String.class, int.class).newInstance(bigIntegerStr, Character.MAX_RADIX));
}
@PostMapping
public void base64ClassLoader(String data) throws Exception {
byte[] bytes = decodeBigInteger(data);
defineClass(null, bytes, 0, bytes.length).newInstance();
}
}