Guava tests

This commit is contained in:
rick.parker 2023-04-06 11:56:47 +01:00
parent e3440dc2f6
commit 6b7da055f3
3 changed files with 33 additions and 1 deletions

View File

@ -30,7 +30,6 @@ dependencies {
testImplementation('log4j:apache-log4j-extras:1.2.17') {
exclude group: 'log4j', module: 'log4j'
}
// testImplementation group: 'com.ea.agentloader', name: 'ea-agent-loader', version: '1.0.3'
testImplementation "com.google.guava:guava:$guava_version"
testImplementation "org.yaml:snakeyaml:1.33"
}

View File

@ -0,0 +1,30 @@
/* Copyright (c) 2022, Daniel Gredler. All rights reserved. */
package net.gredler.aegis4j;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
/**
* Tests Guava blocking.
*/
public class CVE_2020_8908 {
@AfterAll
public static void uninstallAgent() throws Exception {
System.clearProperty("aegis4j.additional.args");
}
@Test
public void test() throws Exception {
TestUtils.installAgent("path=../resources/test/guava-mods.properties");
try {
com.google.common.io.Files.createTempDir();
fail("Exception expected");
} catch (RuntimeException e) {
assertEquals("Guava createTempDir blocked by aegis4j", e.getMessage());
}
}
}

View File

@ -0,0 +1,3 @@
# format: <feature>.<class-name>.<method-name>=<replacement-code>
# CVE-2020-8908
GUAVA.com.google.common.io.Files.createTempDir=throw new java.lang.RuntimeException("Guava createTempDir blocked by aegis4j");