|
40 | 40 | import java.net.Socket; |
41 | 41 | import java.net.SocketException; |
42 | 42 | import java.net.URL; |
43 | | -import java.net.URLClassLoader; |
44 | 43 | import java.net.URLConnection; |
45 | 44 | import java.net.URLStreamHandler; |
46 | 45 | import java.net.spi.URLStreamHandlerProvider; |
|
63 | 62 | import static org.elasticsearch.entitlement.qa.test.EntitlementTest.ExpectedAccess.PLUGINS; |
64 | 63 | import static org.elasticsearch.entitlement.qa.test.EntitlementTest.ExpectedAccess.SERVER_ONLY; |
65 | 64 | import static org.elasticsearch.entitlement.qa.test.RestEntitlementsCheckAction.CheckAction.alwaysDenied; |
66 | | -import static org.elasticsearch.entitlement.qa.test.RestEntitlementsCheckAction.CheckAction.deniedToPlugins; |
67 | 65 | import static org.elasticsearch.entitlement.qa.test.RestEntitlementsCheckAction.CheckAction.forPlugins; |
68 | 66 | import static org.elasticsearch.rest.RestRequest.Method.GET; |
69 | 67 |
|
@@ -95,26 +93,10 @@ static CheckAction alwaysDenied(CheckedRunnable<Exception> action) { |
95 | 93 |
|
96 | 94 | private static final Map<String, CheckAction> checkActions = Stream.of( |
97 | 95 | Stream.<Entry<String, CheckAction>>of( |
98 | | - entry("create_classloader", forPlugins(RestEntitlementsCheckAction::createClassLoader)), |
99 | | - entry("processBuilder_start", deniedToPlugins(RestEntitlementsCheckAction::processBuilder_start)), |
100 | | - entry("processBuilder_startPipeline", deniedToPlugins(RestEntitlementsCheckAction::processBuilder_startPipeline)), |
101 | 96 | entry("set_https_connection_properties", forPlugins(RestEntitlementsCheckAction::setHttpsConnectionProperties)), |
102 | 97 | entry("set_default_ssl_socket_factory", alwaysDenied(RestEntitlementsCheckAction::setDefaultSSLSocketFactory)), |
103 | 98 | entry("set_default_hostname_verifier", alwaysDenied(RestEntitlementsCheckAction::setDefaultHostnameVerifier)), |
104 | 99 | entry("set_default_ssl_context", alwaysDenied(RestEntitlementsCheckAction::setDefaultSSLContext)), |
105 | | - entry( |
106 | | - "thread_setDefaultUncaughtExceptionHandler", |
107 | | - alwaysDenied(RestEntitlementsCheckAction::thread$$setDefaultUncaughtExceptionHandler) |
108 | | - ), |
109 | | - entry("logManager", alwaysDenied(RestEntitlementsCheckAction::logManager$)), |
110 | | - |
111 | | - entry("locale_setDefault", alwaysDenied(WritePropertiesCheckActions::setDefaultLocale)), |
112 | | - entry("locale_setDefaultForCategory", alwaysDenied(WritePropertiesCheckActions::setDefaultLocaleForCategory)), |
113 | | - entry("timeZone_setDefault", alwaysDenied(WritePropertiesCheckActions::setDefaultTimeZone)), |
114 | | - |
115 | | - entry("system_setProperty", forPlugins(WritePropertiesCheckActions::setSystemProperty)), |
116 | | - entry("system_clearProperty", forPlugins(WritePropertiesCheckActions::clearSystemProperty)), |
117 | | - entry("system_setSystemProperties", alwaysDenied(WritePropertiesCheckActions::setSystemProperties)), |
118 | 100 |
|
119 | 101 | // This group is a bit nasty: if entitlements don't prevent these, then networking is |
120 | 102 | // irreparably borked for the remainder of the test run. |
@@ -211,7 +193,9 @@ static CheckAction alwaysDenied(CheckedRunnable<Exception> action) { |
211 | 193 | getTestEntries(SpiActions.class), |
212 | 194 | getTestEntries(SystemActions.class), |
213 | 195 | getTestEntries(URLConnectionFileActions.class), |
214 | | - getTestEntries(URLConnectionNetworkActions.class) |
| 196 | + getTestEntries(URLConnectionNetworkActions.class), |
| 197 | + getTestEntries(JvmActions.class), |
| 198 | + getTestEntries(OperatingSystemActions.class) |
215 | 199 | ) |
216 | 200 | .flatMap(Function.identity()) |
217 | 201 | .filter(entry -> entry.getValue().fromJavaVersion() == null || Runtime.version().feature() >= entry.getValue().fromJavaVersion()) |
@@ -323,33 +307,10 @@ private static void setDefaultSSLSocketFactory() { |
323 | 307 | HttpsURLConnection.setDefaultSSLSocketFactory(new DummyImplementations.DummySSLSocketFactory()); |
324 | 308 | } |
325 | 309 |
|
326 | | - private static void createClassLoader() throws IOException { |
327 | | - try (var classLoader = new URLClassLoader("test", new URL[0], RestEntitlementsCheckAction.class.getClassLoader())) { |
328 | | - logger.info("Created URLClassLoader [{}]", classLoader.getName()); |
329 | | - } |
330 | | - } |
331 | | - |
332 | | - private static void processBuilder_start() throws IOException { |
333 | | - new ProcessBuilder("").start(); |
334 | | - } |
335 | | - |
336 | | - private static void processBuilder_startPipeline() throws IOException { |
337 | | - ProcessBuilder.startPipeline(List.of()); |
338 | | - } |
339 | | - |
340 | 310 | private static void setHttpsConnectionProperties() { |
341 | 311 | new DummyImplementations.DummyHttpsURLConnection().setSSLSocketFactory(new DummyImplementations.DummySSLSocketFactory()); |
342 | 312 | } |
343 | 313 |
|
344 | | - private static void thread$$setDefaultUncaughtExceptionHandler() { |
345 | | - Thread.setDefaultUncaughtExceptionHandler(Thread.getDefaultUncaughtExceptionHandler()); |
346 | | - } |
347 | | - |
348 | | - private static void logManager$() { |
349 | | - new java.util.logging.LogManager() { |
350 | | - }; |
351 | | - } |
352 | | - |
353 | 314 | @SuppressWarnings("deprecation") |
354 | 315 | @SuppressForbidden(reason = "We're required to prevent calls to this forbidden API") |
355 | 316 | private static void datagramSocket$$setDatagramSocketImplFactory() throws IOException { |
|
0 commit comments