@@ -2,34 +2,25 @@ import java
2
2
private import semmle.code.java.dataflow.FlowSteps
3
3
private import semmle.code.java.dataflow.ExternalFlow
4
4
5
- // TODO Is this heuristic too broad?
6
- predicate isInterestingAPI ( Callable call ) {
7
- call .getNumberOfParameters ( ) > 0 and
8
- not (
9
- call .getReturnType ( ) instanceof VoidType or
10
- call .getReturnType ( ) instanceof PrimitiveType or
11
- call .getReturnType ( ) instanceof BoxedType
12
- )
13
- }
14
-
15
- // TODO [bm] Fails to detect Collection flow yet (e.g. Map#put)
16
5
string supportKind ( Callable api ) {
17
6
if api instanceof TaintPreservingCallable
18
7
then result = "taint-preserving"
19
8
else
20
- if
21
- summaryModel ( api .getCompilationUnit ( ) .getPackage ( ) .toString ( ) ,
22
- api .getDeclaringType ( ) .toString ( ) , _, api .getName ( ) , _, _, _, _, _)
9
+ if summaryModel ( packageName ( api ) , typeName ( api ) , _, api .getName ( ) , _, _, _, _, _)
23
10
then result = "summary"
24
11
else
25
- if
26
- sinkModel ( api .getCompilationUnit ( ) .getPackage ( ) .toString ( ) ,
27
- api .getDeclaringType ( ) .toString ( ) , _, api .getName ( ) , _, _, _, _)
12
+ if sinkModel ( packageName ( api ) , typeName ( api ) , _, api .getName ( ) , _, _, _, _)
28
13
then result = "sink"
29
14
else
30
- if
31
- sourceModel ( api .getCompilationUnit ( ) .getPackage ( ) .toString ( ) ,
32
- api .getDeclaringType ( ) .toString ( ) , _, api .getName ( ) , _, _, _, _)
15
+ if sourceModel ( packageName ( api ) , typeName ( api ) , _, api .getName ( ) , _, _, _, _)
33
16
then result = "source"
34
17
else result = "?"
35
18
}
19
+
20
+ private string packageName ( Callable api ) {
21
+ result = api .getCompilationUnit ( ) .getPackage ( ) .toString ( )
22
+ }
23
+
24
+ private string typeName ( Callable api ) {
25
+ result = api .getDeclaringType ( ) .getAnAncestor ( ) .getSourceDeclaration ( ) .toString ( )
26
+ }
0 commit comments