Open wtwhite opened 1 month ago
The simplest way to track requests that use Apache HttpClient is to track constructor calls to HttpGet
, which supplies the URI. Adding activity and entity tracking to bind-jdbc.json
for this (and using <init>
as the method name) does get activity results, but no associated entities. The reason is that, although calls to recordParameter()
are correctly injected into the (two) constructors, and these calls later execute, calls to captureTarget()
are never injected -- I assume because constructors don't return values in the normal way:
wtwhite@wtwhite-vuw-vm:~/code/provenance-demonstrator-movie$ grep -n recordParameter stdout.txt
2539603:Inserted call to recordParameter() at start of java/sql/DriverManager.getConnection (descriptor: (Ljava/lang/String;Ljava/util/Properties;)Ljava/sql/Connection;).
2539606:Inserted call to recordParameter() at start of java/sql/DriverManager.getConnection (descriptor: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/Connection;).
2539609:Inserted call to recordParameter() at start of java/sql/DriverManager.getConnection (descriptor: (Ljava/lang/String;)Ljava/sql/Connection;).
2539612:Inserted call to recordParameter() at start of java/sql/DriverManager.getDriver (descriptor: (Ljava/lang/String;)Ljava/sql/Driver;).
2539615:Inserted call to recordParameter() at start of java/sql/DriverManager.getConnection (descriptor: (Ljava/lang/String;Ljava/util/Properties;Ljava/lang/Class;)Ljava/sql/Connection;).
4823406:Inserted call to recordParameter() at start of org/apache/hc/client5/http/classic/methods/HttpGet.<init> (descriptor: (Ljava/net/URI;)V).
4823408:Inserted call to recordParameter() at start of org/apache/hc/client5/http/classic/methods/HttpGet.<init> (descriptor: (Ljava/lang/String;)V).
4823416:recordParameter(entityType=HttpRequestApacheGet, identifier=2a802c97-a3a2-4a54-b07d-339e7f04366c, param=https://app.veracity.homes/omar-notifications-main-menu.html?name=jens&movieId=45&stars=4 (type: class java.lang.String))! Stacktrace:
4823418: at nz.ac.wgtn.veracity.provenance.injector.instrumentation.CallSiteVisitor.recordParameter(CallSiteVisitor.java:95)
4823520:recordParameter(): end of stacktrace.
4823522:recordParameter(entityType=HttpRequestApacheGet, identifier=79bd1dae-bad1-45a3-a830-1b01bcdeda21, param=https://app.veracity.homes/omar-notifications-main-menu.html?name=jens&movieId=45&stars=4 (type: class java.net.URI))! Stacktrace:
4823524: at nz.ac.wgtn.veracity.provenance.injector.instrumentation.CallSiteVisitor.recordParameter(CallSiteVisitor.java:95)
4823627:recordParameter(): end of stacktrace.
wtwhite@wtwhite-vuw-vm:~/code/provenance-demonstrator-movie$ grep -n captureTarget stdout.txt
2539605:Inserted call to captureTarget() before RETURN inside java/sql/DriverManager.getConnection (descriptor: (Ljava/lang/String;Ljava/util/Properties;)Ljava/sql/Connection;).
2539608:Inserted call to captureTarget() before RETURN inside java/sql/DriverManager.getConnection (descriptor: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/Connection;).
2539611:Inserted call to captureTarget() before RETURN inside java/sql/DriverManager.getConnection (descriptor: (Ljava/lang/String;)Ljava/sql/Connection;).
2539614:Inserted call to captureTarget() before RETURN inside java/sql/DriverManager.getDriver (descriptor: (Ljava/lang/String;)Ljava/sql/Driver;).
2539617:Inserted call to captureTarget() before RETURN inside java/sql/DriverManager.getConnection (descriptor: (Ljava/lang/String;Ljava/util/Properties;Ljava/lang/Class;)Ljava/sql/Connection;).
We need to capture the ctor's "return value" in some other way -- either by using the EntityRef.THIS
(which I don't think is implemented yet), or some other way.
Trapping
URL.openConnection()
is proving difficult (#25) so to get something working, let's try using Apache HttpClient or OkHttp instead.