|
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. |
@@ -213,7 +195,9 @@ static CheckAction alwaysDenied(CheckedRunnable<Exception> action) { |
213 | 195 | getTestEntries(URLConnectionFileActions.class), |
214 | 196 | getTestEntries(URLConnectionNetworkActions.class), |
215 | 197 | getTestEntries(VersionSpecificManageThreadsActions.class), |
216 | | - getTestEntries(VersionSpecificNioFileSystemActions.class) |
| 198 | + getTestEntries(VersionSpecificNioFileSystemActions.class), |
| 199 | + getTestEntries(JvmActions.class), |
| 200 | + getTestEntries(OperatingSystemActions.class) |
217 | 201 | ) |
218 | 202 | .flatMap(Function.identity()) |
219 | 203 | .filter(entry -> entry.getValue().fromJavaVersion() == null || Runtime.version().feature() >= entry.getValue().fromJavaVersion()) |
@@ -325,33 +309,10 @@ private static void setDefaultSSLSocketFactory() { |
325 | 309 | HttpsURLConnection.setDefaultSSLSocketFactory(new DummyImplementations.DummySSLSocketFactory()); |
326 | 310 | } |
327 | 311 |
|
328 | | - private static void createClassLoader() throws IOException { |
329 | | - try (var classLoader = new URLClassLoader("test", new URL[0], RestEntitlementsCheckAction.class.getClassLoader())) { |
330 | | - logger.info("Created URLClassLoader [{}]", classLoader.getName()); |
331 | | - } |
332 | | - } |
333 | | - |
334 | | - private static void processBuilder_start() throws IOException { |
335 | | - new ProcessBuilder("").start(); |
336 | | - } |
337 | | - |
338 | | - private static void processBuilder_startPipeline() throws IOException { |
339 | | - ProcessBuilder.startPipeline(List.of()); |
340 | | - } |
341 | | - |
342 | 312 | private static void setHttpsConnectionProperties() { |
343 | 313 | new DummyImplementations.DummyHttpsURLConnection().setSSLSocketFactory(new DummyImplementations.DummySSLSocketFactory()); |
344 | 314 | } |
345 | 315 |
|
346 | | - private static void thread$$setDefaultUncaughtExceptionHandler() { |
347 | | - Thread.setDefaultUncaughtExceptionHandler(Thread.getDefaultUncaughtExceptionHandler()); |
348 | | - } |
349 | | - |
350 | | - private static void logManager$() { |
351 | | - new java.util.logging.LogManager() { |
352 | | - }; |
353 | | - } |
354 | | - |
355 | 316 | @SuppressWarnings("deprecation") |
356 | 317 | @SuppressForbidden(reason = "We're required to prevent calls to this forbidden API") |
357 | 318 | private static void datagramSocket$$setDatagramSocketImplFactory() throws IOException { |
|
0 commit comments