Skip to content

Commit afb5635

Browse files
committed
[Entitlements] Add URLConnection instrumentation for ftp, http and https protocols (elastic#123802)
1 parent 403b7ae commit afb5635

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
@@ -350,7 +350,18 @@ public interface EntitlementChecker {
350350

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

353-
// Using java.net.URLConnection for "that" as sun.net.www.URLConnection is not exported
353+
void check$java_net_HttpURLConnection$getResponseCode(Class<?> callerClass, java.net.HttpURLConnection that);
354+
355+
void check$java_net_HttpURLConnection$getResponseMessage(Class<?> callerClass, java.net.HttpURLConnection that);
356+
357+
void check$java_net_HttpURLConnection$getHeaderFieldDate(
358+
Class<?> callerClass,
359+
java.net.HttpURLConnection that,
360+
String name,
361+
long defaultValue
362+
);
363+
364+
// Using java.net.URLConnection for "that" as sun.net.www.* is not exported
354365
void check$sun_net_www_URLConnection$getHeaderField(Class<?> callerClass, java.net.URLConnection that, String name);
355366

356367
void check$sun_net_www_URLConnection$getHeaderFields(Class<?> callerClass, java.net.URLConnection that);
@@ -363,6 +374,147 @@ public interface EntitlementChecker {
363374

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

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

368520
// 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)