9
9
import boomerang .scene .Statement ;
10
10
import boomerang .scene .Val ;
11
11
import de .fraunhofer .iem .secucheck .analysis .configuration .SecucheckAnalysisConfiguration ;
12
+ import de .fraunhofer .iem .secucheck .analysis .datastructures .DifferentTypedPair ;
12
13
import de .fraunhofer .iem .secucheck .analysis .implementation .SingleFlowTaintAnalysis .BoomerangSolver .Utility ;
14
+ import de .fraunhofer .iem .secucheck .analysis .implementation .SingleFlowTaintAnalysis .datastructure .BoomerangTaintFlowPath ;
15
+ import de .fraunhofer .iem .secucheck .analysis .implementation .SingleFlowTaintAnalysis .TaintFlowPathUtility ;
13
16
import de .fraunhofer .iem .secucheck .analysis .query .*;
14
- import soot .jimple .internal .JDynamicInvokeExpr ;
15
17
16
- import java .util .ArrayList ;
17
- import java .util .Collection ;
18
- import java .util .Collections ;
19
- import java .util .List ;
18
+ import java .util .*;
20
19
21
20
/**
22
21
* This is the Secucheck DemandDriven Manager for Boomerang
@@ -28,7 +27,7 @@ public class BoomerangGPHandler implements IDemandDrivenGuidedManager {
28
27
* List of found sinks. Whenever SecucheckDemandDrivenManager finds a sink with a taintflow then it creates a
29
28
* BackwardQuery and adds it to this list.
30
29
*/
31
- private final ArrayList <BackwardQuery > foundSinks = new ArrayList <>();
30
+ private final ArrayList <DifferentTypedPair < BackwardQuery , BoomerangTaintFlowPath > > foundSinks = new ArrayList <>();
32
31
33
32
/**
34
33
* Current single TaintFlow specification, that the current analysis running for.
@@ -40,23 +39,27 @@ public class BoomerangGPHandler implements IDemandDrivenGuidedManager {
40
39
*/
41
40
private final SecucheckAnalysisConfiguration secucheckAnalysisConfiguration ;
42
41
42
+ private final BoomerangTaintFlowPath tempPath ;
43
+
43
44
/**
44
45
* Constructor
45
46
*
46
47
* @param singleFlow Single TaintFlow specification
47
48
* @param secucheckAnalysisConfiguration SecuchcekAnalysisConfiguration given by the client
48
49
*/
49
- public BoomerangGPHandler (TaintFlowImpl singleFlow , SecucheckAnalysisConfiguration secucheckAnalysisConfiguration ) {
50
+ public BoomerangGPHandler (TaintFlowImpl singleFlow , SecucheckAnalysisConfiguration secucheckAnalysisConfiguration , BoomerangTaintFlowPath initialPath ) {
50
51
this .singleFlow = singleFlow ;
51
52
this .secucheckAnalysisConfiguration = secucheckAnalysisConfiguration ;
53
+ this .tempPath = initialPath ;
54
+
52
55
}
53
56
54
57
/**
55
58
* Getter for the list of found sinks
56
59
*
57
60
* @return List of found sinks
58
61
*/
59
- public ArrayList <BackwardQuery > getFoundSinks () {
62
+ public ArrayList <DifferentTypedPair < BackwardQuery , BoomerangTaintFlowPath > > getFoundSinks () {
60
63
return foundSinks ;
61
64
}
62
65
@@ -68,9 +71,7 @@ public ArrayList<BackwardQuery> getFoundSinks() {
68
71
* @param dataFlowVal Fact: dataFlowVal
69
72
* @return True is there is a sink method call and TaintFlow exist.
70
73
*/
71
- private boolean isSink (Statement statement , ControlFlowGraph .Edge dataFlowEdge , Val dataFlowVal ) {
72
- boolean isSinkFound = false ;
73
-
74
+ private BackwardQuery isSink (Statement statement , ControlFlowGraph .Edge dataFlowEdge , Val dataFlowVal ) {
74
75
for (Method sinkMethod : singleFlow .getTo ()) {
75
76
String sinkSootSignature = Utility .wrapInAngularBrackets (sinkMethod .getSignature ());
76
77
@@ -86,8 +87,7 @@ private boolean isSink(Statement statement, ControlFlowGraph.Edge dataFlowEdge,
86
87
int parameterIndex = input .getParamID ();
87
88
if (statement .getInvokeExpr ().getArgs ().size () >= parameterIndex ) {
88
89
if (statement .getInvokeExpr ().getArg (parameterIndex ).toString ().equals (dataFlowVal .toString ())) {
89
- foundSinks .add (BackwardQuery .make (dataFlowEdge , statement .getInvokeExpr ().getArg (parameterIndex )));
90
- isSinkFound = true ;
90
+ return BackwardQuery .make (dataFlowEdge , statement .getInvokeExpr ().getArg (parameterIndex ));
91
91
}
92
92
}
93
93
}
@@ -97,15 +97,14 @@ private boolean isSink(Statement statement, ControlFlowGraph.Edge dataFlowEdge,
97
97
if (sinkMethod .isInputThis () &&
98
98
statement .getInvokeExpr ().isInstanceInvokeExpr ()) {
99
99
if (statement .getInvokeExpr ().getBase ().toString ().equals (dataFlowVal .toString ())) {
100
- foundSinks .add (BackwardQuery .make (dataFlowEdge , statement .getInvokeExpr ().getBase ()));
101
- isSinkFound = true ;
100
+ return BackwardQuery .make (dataFlowEdge , statement .getInvokeExpr ().getBase ());
102
101
}
103
102
}
104
103
}
105
104
106
105
}
107
106
108
- return isSinkFound ;
107
+ return null ;
109
108
}
110
109
111
110
/**
@@ -244,17 +243,44 @@ public Collection<Query> onForwardFlow(ForwardQuery query, ControlFlowGraph.Edge
244
243
Statement stmt = dataFlowEdge .getStart ();
245
244
ArrayList <Query > out = new ArrayList <Query >();
246
245
246
+ //TODO: check isPostProcessing enabled
247
+ BoomerangTaintFlowPath parentNode = (BoomerangTaintFlowPath ) TaintFlowPathUtility .findNodeUsingDFS (tempPath , query );
248
+
247
249
if (stmt .containsInvokeExpr ()) {
248
- if (isSink (stmt , dataFlowEdge , dataFlowVal )) {
250
+ BackwardQuery sinkQuery = isSink (stmt , dataFlowEdge , dataFlowVal );
251
+ if (sinkQuery != null ) {
252
+ //TODO: check isPostProcessing enabled
253
+ BoomerangTaintFlowPath finalSinkNode = new BoomerangTaintFlowPath (
254
+ sinkQuery , parentNode , false , true );
255
+ parentNode .addNewChild (finalSinkNode );
256
+ BoomerangTaintFlowPath singleTaintFlowPath = TaintFlowPathUtility .createSinglePathFromRootNode (finalSinkNode );
257
+ DifferentTypedPair <BackwardQuery , BoomerangTaintFlowPath > res = new DifferentTypedPair <>(sinkQuery , singleTaintFlowPath );
258
+ foundSinks .add (res );
249
259
return Collections .emptyList ();
250
260
}
251
261
252
- out .addAll (isPropogator (singleFlow .getThrough (), stmt , dataFlowEdge , dataFlowVal ));
262
+ Collection <Query > prop = isPropogator (singleFlow .getThrough (), stmt , dataFlowEdge , dataFlowVal );
263
+
264
+ for (Query propQuery : prop ) {
265
+ //TODO: check isPostProcessing enabled
266
+ BoomerangTaintFlowPath finalSinkNode = new BoomerangTaintFlowPath (
267
+ propQuery , parentNode , false , false );
268
+ parentNode .addNewChild (finalSinkNode );
269
+ out .add (propQuery );
270
+ }
253
271
254
272
if (out .size () > 0 )
255
273
return out ;
256
274
257
- out .addAll (isPropogator (secucheckAnalysisConfiguration .getAnalysisGeneralPropagators (), stmt , dataFlowEdge , dataFlowVal ));
275
+ Collection <Query > generalProp = isPropogator (secucheckAnalysisConfiguration .getAnalysisGeneralPropagators (), stmt , dataFlowEdge , dataFlowVal );
276
+
277
+ for (Query generalPropQuery : generalProp ) {
278
+ //TODO: check isPostProcessing enabled
279
+ BoomerangTaintFlowPath finalSinkNode = new BoomerangTaintFlowPath (
280
+ generalPropQuery , parentNode , false , false );
281
+ parentNode .addNewChild (finalSinkNode );
282
+ out .add (generalPropQuery );
283
+ }
258
284
}
259
285
260
286
return out ;
0 commit comments