File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,12 +2,8 @@ import java
22private import semmle.code.java.dataflow.FlowSteps
33private import semmle.code.java.dataflow.ExternalFlow
44
5- string jarName ( CompilationUnit cu ) {
6- result = cu .getParentContainer ( ) .toString ( ) .regexpCapture ( ".*/(.*\\.jar)/?.*" , 1 )
7- }
8-
95predicate isJavaRuntime ( Callable call ) {
10- jarName ( call .getCompilationUnit ( ) ) = "rt.jar" or
6+ call .getCompilationUnit ( ) . getParentContainer * ( ) . getStem ( ) = "rt" and
117 call .getCompilationUnit ( ) .getParentContainer ( ) .toString ( ) .substring ( 0 , 14 ) = "/modules/java."
128}
139
Original file line number Diff line number Diff line change @@ -9,8 +9,6 @@ class ExternalAPI extends Callable {
99 not isJavaRuntime ( this )
1010 }
1111
12- string jarName ( ) { result = jarName ( this .getCompilationUnit ( ) ) }
13-
1412 string simpleName ( ) {
1513 result = getDeclaringType ( ) .getSourceDeclaration ( ) + "#" + this .getStringSignature ( )
1614 }
Original file line number Diff line number Diff line change 11/**
22 * @name External libraries
33 * @description A list of external libraries used in the code
4+ * @kind diagnostic
45 * @id java/telemetry/external-libs
56 */
67
78import java
89import ExternalAPI
910
10- from ExternalAPI api
11- where not api .getDeclaringType ( ) instanceof TestLibrary
12- // TODO [bm]: the count is not aggregated and we have the same jar with multiple usages, e.g.
13- // 1 protobuf-java-3.17.3.jar 373
14- // 2 protobuf-java-3.17.3.jar 48
15- select api .jarName ( ) as jarname , count ( Call c | c .getCallee ( ) = api ) as Usages order by Usages desc
11+ from int Usages , JarFile jar
12+ where
13+ jar = any ( ExternalAPI api ) .getCompilationUnit ( ) .getParentContainer * ( ) and
14+ Usages =
15+ strictcount ( Call c , ExternalAPI a |
16+ c .getCallee ( ) = a and
17+ not c .getFile ( ) instanceof GeneratedFile and
18+ a .getCompilationUnit ( ) .getParentContainer * ( ) = jar and
19+ not a .getDeclaringType ( ) instanceof TestLibrary
20+ )
21+ select jar .getFile ( ) .getStem ( ) + "." + jar .getFile ( ) .getExtension ( ) , Usages order by Usages desc
You can’t perform that action at this time.
0 commit comments