Skip to content

Commit 2b18a0c

Browse files
authored
[Entitlements] Add URLConnection instrumentation for ftp, http and https protocols (elastic#123802) (elastic#123960)
1 parent 8e409d6 commit 2b18a0c

File tree

4 files changed

+662
-2
lines changed

4 files changed

+662
-2
lines changed

libs/entitlement/bridge/src/main/java/org/elasticsearch/entitlement/bridge/EntitlementChecker.java

Lines changed: 153 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,18 @@ public interface EntitlementChecker {
358358

359359
void check$java_net_URLConnection$getContent(Class<?> callerClass, java.net.URLConnection that, Class<?>[] classes);
360360

361-
// Using java.net.URLConnection for "that" as sun.net.www.URLConnection is not exported
361+
void check$java_net_HttpURLConnection$getResponseCode(Class<?> callerClass, java.net.HttpURLConnection that);
362+
363+
void check$java_net_HttpURLConnection$getResponseMessage(Class<?> callerClass, java.net.HttpURLConnection that);
364+
365+
void check$java_net_HttpURLConnection$getHeaderFieldDate(
366+
Class<?> callerClass,
367+
java.net.HttpURLConnection that,
368+
String name,
369+
long defaultValue
370+
);
371+
372+
// Using java.net.URLConnection for "that" as sun.net.www.* is not exported
362373
void check$sun_net_www_URLConnection$getHeaderField(Class<?> callerClass, java.net.URLConnection that, String name);
363374

364375
void check$sun_net_www_URLConnection$getHeaderFields(Class<?> callerClass, java.net.URLConnection that);
@@ -371,6 +382,147 @@ public interface EntitlementChecker {
371382

372383
void check$sun_net_www_URLConnection$getContentLength(Class<?> callerClass, java.net.URLConnection that);
373384

385+
void check$sun_net_www_protocol_ftp_FtpURLConnection$connect(Class<?> callerClass, java.net.URLConnection that);
386+
387+
void check$sun_net_www_protocol_ftp_FtpURLConnection$getInputStream(Class<?> callerClass, java.net.URLConnection that);
388+
389+
void check$sun_net_www_protocol_ftp_FtpURLConnection$getOutputStream(Class<?> callerClass, java.net.URLConnection that);
390+
391+
void check$sun_net_www_protocol_http_HttpURLConnection$$openConnectionCheckRedirects(Class<?> callerClass, java.net.URLConnection c);
392+
393+
void check$sun_net_www_protocol_http_HttpURLConnection$connect(Class<?> callerClass, java.net.HttpURLConnection that);
394+
395+
void check$sun_net_www_protocol_http_HttpURLConnection$getOutputStream(Class<?> callerClass, java.net.HttpURLConnection that);
396+
397+
void check$sun_net_www_protocol_http_HttpURLConnection$getInputStream(Class<?> callerClass, java.net.HttpURLConnection that);
398+
399+
void check$sun_net_www_protocol_http_HttpURLConnection$getErrorStream(Class<?> callerClass, java.net.HttpURLConnection that);
400+
401+
void check$sun_net_www_protocol_http_HttpURLConnection$getHeaderField(
402+
Class<?> callerClass,
403+
java.net.HttpURLConnection that,
404+
String name
405+
);
406+
407+
void check$sun_net_www_protocol_http_HttpURLConnection$getHeaderFields(Class<?> callerClass, java.net.HttpURLConnection that);
408+
409+
void check$sun_net_www_protocol_http_HttpURLConnection$getHeaderField(Class<?> callerClass, java.net.HttpURLConnection that, int n);
410+
411+
void check$sun_net_www_protocol_http_HttpURLConnection$getHeaderFieldKey(Class<?> callerClass, java.net.HttpURLConnection that, int n);
412+
413+
void check$sun_net_www_protocol_https_HttpsURLConnectionImpl$connect(Class<?> callerClass, javax.net.ssl.HttpsURLConnection that);
414+
415+
void check$sun_net_www_protocol_https_HttpsURLConnectionImpl$getOutputStream(
416+
Class<?> callerClass,
417+
javax.net.ssl.HttpsURLConnection that
418+
);
419+
420+
void check$sun_net_www_protocol_https_HttpsURLConnectionImpl$getInputStream(
421+
Class<?> callerClass,
422+
javax.net.ssl.HttpsURLConnection that
423+
);
424+
425+
void check$sun_net_www_protocol_https_HttpsURLConnectionImpl$getErrorStream(
426+
Class<?> callerClass,
427+
javax.net.ssl.HttpsURLConnection that
428+
);
429+
430+
void check$sun_net_www_protocol_https_HttpsURLConnectionImpl$getHeaderField(
431+
Class<?> callerClass,
432+
javax.net.ssl.HttpsURLConnection that,
433+
String name
434+
);
435+
436+
void check$sun_net_www_protocol_https_HttpsURLConnectionImpl$getHeaderFields(
437+
Class<?> callerClass,
438+
javax.net.ssl.HttpsURLConnection that
439+
);
440+
441+
void check$sun_net_www_protocol_https_HttpsURLConnectionImpl$getHeaderField(
442+
Class<?> callerClass,
443+
javax.net.ssl.HttpsURLConnection that,
444+
int n
445+
);
446+
447+
void check$sun_net_www_protocol_https_HttpsURLConnectionImpl$getHeaderFieldKey(
448+
Class<?> callerClass,
449+
javax.net.ssl.HttpsURLConnection that,
450+
int n
451+
);
452+
453+
void check$sun_net_www_protocol_https_HttpsURLConnectionImpl$getResponseCode(
454+
Class<?> callerClass,
455+
javax.net.ssl.HttpsURLConnection that
456+
);
457+
458+
void check$sun_net_www_protocol_https_HttpsURLConnectionImpl$getResponseMessage(
459+
Class<?> callerClass,
460+
javax.net.ssl.HttpsURLConnection that
461+
);
462+
463+
void check$sun_net_www_protocol_https_HttpsURLConnectionImpl$getContentLength(
464+
Class<?> callerClass,
465+
javax.net.ssl.HttpsURLConnection that
466+
);
467+
468+
void check$sun_net_www_protocol_https_HttpsURLConnectionImpl$getContentLengthLong(
469+
Class<?> callerClass,
470+
javax.net.ssl.HttpsURLConnection that
471+
);
472+
473+
void check$sun_net_www_protocol_https_HttpsURLConnectionImpl$getContentType(
474+
Class<?> callerClass,
475+
javax.net.ssl.HttpsURLConnection that
476+
);
477+
478+
void check$sun_net_www_protocol_https_HttpsURLConnectionImpl$getContentEncoding(
479+
Class<?> callerClass,
480+
javax.net.ssl.HttpsURLConnection that
481+
);
482+
483+
void check$sun_net_www_protocol_https_HttpsURLConnectionImpl$getExpiration(Class<?> callerClass, javax.net.ssl.HttpsURLConnection that);
484+
485+
void check$sun_net_www_protocol_https_HttpsURLConnectionImpl$getDate(Class<?> callerClass, javax.net.ssl.HttpsURLConnection that);
486+
487+
void check$sun_net_www_protocol_https_HttpsURLConnectionImpl$getLastModified(
488+
Class<?> callerClass,
489+
javax.net.ssl.HttpsURLConnection that
490+
);
491+
492+
void check$sun_net_www_protocol_https_HttpsURLConnectionImpl$getHeaderFieldInt(
493+
Class<?> callerClass,
494+
javax.net.ssl.HttpsURLConnection that,
495+
String name,
496+
int defaultValue
497+
);
498+
499+
void check$sun_net_www_protocol_https_HttpsURLConnectionImpl$getHeaderFieldLong(
500+
Class<?> callerClass,
501+
javax.net.ssl.HttpsURLConnection that,
502+
String name,
503+
long defaultValue
504+
);
505+
506+
void check$sun_net_www_protocol_https_HttpsURLConnectionImpl$getHeaderFieldDate(
507+
Class<?> callerClass,
508+
javax.net.ssl.HttpsURLConnection that,
509+
String name,
510+
long defaultValue
511+
);
512+
513+
void check$sun_net_www_protocol_https_HttpsURLConnectionImpl$getContent(Class<?> callerClass, javax.net.ssl.HttpsURLConnection that);
514+
515+
void check$sun_net_www_protocol_https_HttpsURLConnectionImpl$getContent(
516+
Class<?> callerClass,
517+
javax.net.ssl.HttpsURLConnection that,
518+
Class<?>[] classes
519+
);
520+
521+
void check$sun_net_www_protocol_https_AbstractDelegateHttpsURLConnection$connect(
522+
Class<?> callerClass,
523+
javax.net.ssl.HttpsURLConnection that
524+
);
525+
374526
// Network miscellanea
375527

376528
// HttpClient#send and sendAsync are abstract, so we instrument their internal implementations

libs/entitlement/qa/entitled-plugin/src/main/java/org/elasticsearch/entitlement/qa/entitled/EntitledActions.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,12 @@ public static Path createTempSymbolicLink() throws IOException {
6363
public static URLConnection createHttpURLConnection() throws IOException {
6464
return URI.create("http://127.0.0.1:12345/").toURL().openConnection();
6565
}
66+
67+
public static URLConnection createHttpsURLConnection() throws IOException {
68+
return URI.create("https://127.0.0.1:12345/").toURL().openConnection();
69+
}
70+
71+
public static URLConnection createFtpURLConnection() throws IOException {
72+
return URI.create("ftp://127.0.0.1:12345/").toURL().openConnection();
73+
}
6674
}

0 commit comments

Comments
 (0)