Skip to content

Commit 90f7766

Browse files
committed
Now user can control the Post processing of the result
1 parent e33fc3f commit 90f7766

File tree

7 files changed

+66
-26
lines changed

7 files changed

+66
-26
lines changed

de.fraunhofer.iem.secucheck.analysis.configuration/src/main/java/de/fraunhofer/iem/secucheck/analysis/configuration/SecucheckAnalysisConfiguration.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ public interface SecucheckAnalysisConfiguration {
6262
*/
6363
void setListener(AnalysisResultListener resultListener);
6464

65+
/**
66+
* Sets the isPostProcess result. If set, then it process the result and add the taintflow path to the result.
67+
* For now, it PostProcess result is available only to Boomerang3 solver
68+
*
69+
* @param isPostProcessResult is Post Process result
70+
*/
71+
void setIsPostProcessResult(boolean isPostProcessResult);
72+
6573
OS getOs();
6674

6775
Solver getSolver();
@@ -76,4 +84,6 @@ public interface SecucheckAnalysisConfiguration {
7684

7785
AnalysisResultListener getListener();
7886

87+
boolean isPostProcessResult();
88+
7989
}

de.fraunhofer.iem.secucheck.analysis.configuration/src/main/java/de/fraunhofer/iem/secucheck/analysis/configuration/SecucheckAnalysisDefaultConfiguration.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class SecucheckAnalysisDefaultConfiguration implements SecucheckAnalysisC
2020
private List<EntryPoint> entryPoints;
2121
private List<MethodImpl> generalPropagators;
2222
private AnalysisResultListener resultListener;
23+
private boolean isPostProcess;
2324

2425
@Override
2526
public void setOs(OS os) {
@@ -56,6 +57,11 @@ public void setListener(AnalysisResultListener resultListener) {
5657
this.resultListener = resultListener;
5758
}
5859

60+
@Override
61+
public void setIsPostProcessResult(boolean isPostProcessResult) {
62+
this.isPostProcess = isPostProcessResult;
63+
}
64+
5965
@Override
6066
public OS getOs() {
6167
return this.os;
@@ -90,4 +96,9 @@ public List<MethodImpl> getAnalysisGeneralPropagators() {
9096
public AnalysisResultListener getListener() {
9197
return this.resultListener;
9298
}
99+
100+
@Override
101+
public boolean isPostProcessResult() {
102+
return isPostProcess;
103+
}
93104
}

de.fraunhofer.iem.secucheck.analysis.implementation/src/main/java/de/fraunhofer/iem/secucheck/analysis/implementation/SingleFlowTaintAnalysis/BoomerangSolver/BoomerangSingleFlowAnalysis.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
import de.fraunhofer.iem.secucheck.analysis.SingleFlowAnalysis.SingleFlowAnalysis;
1010
import de.fraunhofer.iem.secucheck.analysis.configuration.SecucheckAnalysisConfiguration;
1111
import de.fraunhofer.iem.secucheck.analysis.datastructures.DifferentTypedPair;
12-
import de.fraunhofer.iem.secucheck.analysis.datastructures.SameTypedPair;
1312
import de.fraunhofer.iem.secucheck.analysis.implementation.SingleFlowTaintAnalysis.BoomerangSolver.guided.SecucheckBoomerangDemandDrivenAnalysis;
1413
import de.fraunhofer.iem.secucheck.analysis.query.TaintFlow;
1514
import de.fraunhofer.iem.secucheck.analysis.query.TaintFlowImpl;
16-
import de.fraunhofer.iem.secucheck.analysis.result.LocationDetails;
1715
import de.fraunhofer.iem.secucheck.analysis.result.SingleTaintFlowAnalysisResult;
1816
import de.fraunhofer.iem.secucheck.analysis.result.TaintFlowResult;
1917
import soot.PackManager;

de.fraunhofer.iem.secucheck.analysis.implementation/src/main/java/de/fraunhofer/iem/secucheck/analysis/implementation/SingleFlowTaintAnalysis/BoomerangSolver/guided/BoomerangGPHandler.java

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -243,44 +243,53 @@ public Collection<Query> onForwardFlow(ForwardQuery query, ControlFlowGraph.Edge
243243
Statement stmt = dataFlowEdge.getStart();
244244
ArrayList<Query> out = new ArrayList<Query>();
245245

246-
//TODO: check isPostProcessing enabled
247-
BoomerangTaintFlowPath parentNode = (BoomerangTaintFlowPath) TaintFlowPathUtility.findNodeUsingDFS(tempPath, query);
246+
BoomerangTaintFlowPath parentNode = null;
247+
if (secucheckAnalysisConfiguration.isPostProcessResult()) {
248+
parentNode = (BoomerangTaintFlowPath) TaintFlowPathUtility.findNodeUsingDFS(tempPath, query);
249+
}
248250

249251
if (stmt.containsInvokeExpr()) {
250252
BackwardQuery sinkQuery = isSink(stmt, dataFlowEdge, dataFlowVal);
251253
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);
254+
BoomerangTaintFlowPath singleTaintFlowPath = null;
255+
if (secucheckAnalysisConfiguration.isPostProcessResult()) {
256+
BoomerangTaintFlowPath finalSinkNode = new BoomerangTaintFlowPath(
257+
sinkQuery, parentNode, false, true);
258+
parentNode.addNewChild(finalSinkNode);
259+
singleTaintFlowPath = TaintFlowPathUtility.createSinglePathFromRootNode(finalSinkNode);
260+
}
261+
257262
DifferentTypedPair<BackwardQuery, BoomerangTaintFlowPath> res = new DifferentTypedPair<>(sinkQuery, singleTaintFlowPath);
258263
foundSinks.add(res);
259264
return Collections.emptyList();
260265
}
261266

262267
Collection<Query> prop = isPropogator(singleFlow.getThrough(), stmt, dataFlowEdge, dataFlowVal);
263268

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);
269+
if (secucheckAnalysisConfiguration.isPostProcessResult()) {
270+
for (Query propQuery : prop) {
271+
BoomerangTaintFlowPath finalSinkNode = new BoomerangTaintFlowPath(
272+
propQuery, parentNode, false, false);
273+
parentNode.addNewChild(finalSinkNode);
274+
}
270275
}
271276

277+
out.addAll(prop);
278+
272279
if (out.size() > 0)
273280
return out;
274281

275282
Collection<Query> generalProp = isPropogator(secucheckAnalysisConfiguration.getAnalysisGeneralPropagators(), stmt, dataFlowEdge, dataFlowVal);
276283

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);
284+
if (secucheckAnalysisConfiguration.isPostProcessResult()) {
285+
for (Query generalPropQuery : generalProp) {
286+
BoomerangTaintFlowPath finalSinkNode = new BoomerangTaintFlowPath(
287+
generalPropQuery, parentNode, false, false);
288+
parentNode.addNewChild(finalSinkNode);
289+
}
283290
}
291+
292+
out.addAll(generalProp);
284293
}
285294

286295
return out;

de.fraunhofer.iem.secucheck.analysis.implementation/src/main/java/de/fraunhofer/iem/secucheck/analysis/implementation/SingleFlowTaintAnalysis/BoomerangSolver/guided/SecucheckBoomerangDemandDrivenAnalysis.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,11 @@ public List<DifferentTypedPair<TaintFlowImpl, SingleTaintFlowAnalysisResult>> ru
6363

6464
for (DifferentTypedPair<BackwardQuery, BoomerangTaintFlowPath> sinkNode : boomerangGPHandler.getFoundSinks()) {
6565
BackwardQuery sink = sinkNode.getFirst();
66-
TaintFlowPathUtility.print(sinkNode.getSecond());
66+
6767
SingleTaintFlowAnalysisResult res = new SingleTaintFlowAnalysisResult(
6868
new DifferentTypedPair<>(singleFlow, getLocationDetailsPair(source, sink)),
69-
sinkNode.getSecond()
69+
sinkNode.getSecond(),
70+
secucheckAnalysisConfiguration.isPostProcessResult()
7071
);
7172
reachMap.add(new DifferentTypedPair<>(singleFlow, res));
7273
}

de.fraunhofer.iem.secucheck.analysis.implementation/src/main/java/de/fraunhofer/iem/secucheck/analysis/implementation/SingleFlowTaintAnalysis/FlowDroidSolver/FlowDroidSingleFlowAnalysis.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ public TaintFlowResult run() throws Exception {
156156
SameTypedPair<LocationDetails> locationPair = getLocationDetailsPair(singleFlow, dataFlowResult);
157157
SingleTaintFlowAnalysisResult res = new SingleTaintFlowAnalysisResult(
158158
new DifferentTypedPair<>(singleFlow, locationPair),
159-
null
159+
null,
160+
false
160161
);
161162
reachMap.add(new DifferentTypedPair<>(singleFlow, res));
162163
}
@@ -219,7 +220,10 @@ public TaintFlowResult run() throws Exception {
219220

220221
originalReachMap.add(new
221222
DifferentTypedPair<TaintFlowImpl, SingleTaintFlowAnalysisResult>
222-
(singleFlow, new SingleTaintFlowAnalysisResult(new DifferentTypedPair<>(singleFlow, stichedPair), null)));
223+
(singleFlow, new SingleTaintFlowAnalysisResult(
224+
new DifferentTypedPair<>(singleFlow, stichedPair),
225+
null,
226+
false)));
223227
}
224228
}
225229

de.fraunhofer.iem.secucheck.analysis.result/src/main/java/de/fraunhofer/iem/secucheck/analysis/result/SingleTaintFlowAnalysisResult.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@
1212
*/
1313
public class SingleTaintFlowAnalysisResult {
1414
private final DifferentTypedPair<TaintFlowImpl, SameTypedPair<LocationDetails>> resultMap;
15+
private final boolean isTaintFlowPathIncluded;
1516
private final TaintFlowPath path;
1617

1718
public SingleTaintFlowAnalysisResult(
1819
DifferentTypedPair<TaintFlowImpl, SameTypedPair<LocationDetails>> resultMap,
19-
TaintFlowPath path) {
20+
TaintFlowPath path,
21+
boolean isTaintFlowPathIncluded) {
2022
this.resultMap = resultMap;
2123
this.path = path;
24+
this.isTaintFlowPathIncluded = isTaintFlowPathIncluded;
2225
}
2326

2427

@@ -29,4 +32,8 @@ public DifferentTypedPair<TaintFlowImpl, SameTypedPair<LocationDetails>> getLoca
2932
public TaintFlowPath getPath() {
3033
return path;
3134
}
35+
36+
public boolean isTaintFlowPathIncluded() {
37+
return isTaintFlowPathIncluded;
38+
}
3239
}

0 commit comments

Comments
 (0)