mirror of
https://github.com/corda/corda.git
synced 2025-01-01 18:56:44 +00:00
Support extra args system property and tests
This commit is contained in:
parent
9ec5cfcecb
commit
a61dfd9195
@ -42,8 +42,6 @@ compileTestJava.options.encoding = 'UTF-8'
|
||||
javadoc.options.encoding = 'UTF-8'
|
||||
|
||||
java {
|
||||
//withJavadocJar()
|
||||
//withSourcesJar()
|
||||
}
|
||||
|
||||
test {
|
||||
@ -83,51 +81,3 @@ shadowJar {
|
||||
tasks.build.dependsOn tasks.shadowJar
|
||||
tasks.test.dependsOn tasks.shadowJar
|
||||
|
||||
/*
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) { publication ->
|
||||
project.shadow.component(publication)
|
||||
artifact sourcesJar
|
||||
artifact javadocJar
|
||||
pom {
|
||||
groupId = 'net.gredler'
|
||||
name = 'aegis4j'
|
||||
url = 'https://github.com/gredler/aegis4j'
|
||||
description = 'A Java agent which disables dangerous rarely-used runtime features.'
|
||||
licenses {
|
||||
license {
|
||||
name = 'The Apache License, Version 2.0'
|
||||
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
||||
}
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id = 'gredler'
|
||||
name = 'Daniel Gredler'
|
||||
email = 'daniel.gredler@gmail.com'
|
||||
}
|
||||
}
|
||||
scm {
|
||||
url = 'https://github.com/gredler/aegis4j'
|
||||
connection = 'scm:git:git://github.com/gredler/aegis4j.git'
|
||||
developerConnection = 'scm:git:ssh:git@github.com:gredler/aegis4j.git'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
url = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
|
||||
credentials {
|
||||
username = project.hasProperty('ossrhUsername') ? ossrhUsername : 'unknown'
|
||||
password = project.hasProperty('ossrhPassword') ? ossrhPassword : 'unknown'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
signing {
|
||||
sign publishing.publications.mavenJava
|
||||
}
|
||||
*/
|
||||
|
@ -36,6 +36,14 @@ public final class AegisAgent {
|
||||
*/
|
||||
public static void premain(String args, Instrumentation instr) {
|
||||
instrumentation = instr;
|
||||
String argsProperty = System.getProperty("aegis4j.additional.args");
|
||||
if (argsProperty != null) {
|
||||
if (args == null || args.trim().isEmpty()) {
|
||||
args = argsProperty;
|
||||
} else {
|
||||
args += ";" + argsProperty;
|
||||
}
|
||||
}
|
||||
try {
|
||||
boolean started = false;
|
||||
Properties props = null;
|
||||
|
@ -0,0 +1,40 @@
|
||||
/* 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;
|
||||
|
||||
/**
|
||||
* Tests {@link AegisAgent} monitoring via system properties.
|
||||
*/
|
||||
public class AegisAgentSystemPropertyTest {
|
||||
@AfterAll
|
||||
public static void uninstallAgent() throws Exception {
|
||||
System.clearProperty("aegis4j.additional.args");
|
||||
TestUtils.installAgent("unblock=serialization");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSystemPropertyWithNullExistingArgs() throws Exception {
|
||||
System.setProperty("aegis4j.additional.args", "unblock=jndi,rmi,scripting");
|
||||
TestUtils.installAgent(null);
|
||||
assertEquals("serialization,process,httpserver", System.getProperty("aegis4j.blocked.features"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSystemPropertyWithEmptyExistingArgs() throws Exception {
|
||||
System.setProperty("aegis4j.additional.args", "unblock=jndi,rmi,scripting");
|
||||
TestUtils.installAgent("");
|
||||
assertEquals("serialization,process,httpserver", System.getProperty("aegis4j.blocked.features"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSystemPropertyWithNonEmptyExistingArgs() throws Exception {
|
||||
System.setProperty("aegis4j.additional.args", "unblock=jndi,rmi,scripting");
|
||||
TestUtils.installAgent("path=../resources/main/net/gredler/aegis4j/mods.properties");
|
||||
assertEquals("serialization,process,httpserver", System.getProperty("aegis4j.blocked.features"));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user