Skip to content

Commit 3474096

Browse files
committed
added more logging
1 parent 3f0b24e commit 3474096

1 file changed

Lines changed: 29 additions & 27 deletions

File tree

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package soot.jimple.infoflow.river;
22

3+
import java.util.HashSet;
4+
import java.util.Set;
5+
36
import org.slf4j.Logger;
47
import org.slf4j.LoggerFactory;
8+
59
import soot.jimple.infoflow.InfoflowManager;
610
import soot.jimple.infoflow.handlers.PostAnalysisHandler;
711
import soot.jimple.infoflow.results.DataFlowResult;
@@ -10,43 +14,41 @@
1014
import soot.jimple.infoflow.solver.cfg.IInfoflowCFG;
1115
import soot.jimple.infoflow.sourcesSinks.definitions.SourceSinkCondition;
1216

13-
import java.util.Collections;
14-
import java.util.HashSet;
15-
import java.util.Set;
16-
1717
/**
18-
* Checks whether conditional sinks met their condition and filter those which did not.
18+
* Checks whether conditional sinks met their condition and filter those which
19+
* did not.
1920
*
2021
* @author Tim Lange
2122
*/
2223
public class ConditionalFlowPostProcessor implements PostAnalysisHandler {
23-
protected final Logger logger = LoggerFactory.getLogger(getClass());
24+
protected final Logger logger = LoggerFactory.getLogger(getClass());
2425

25-
InfoflowManager manager;
26+
InfoflowManager manager;
2627

27-
public ConditionalFlowPostProcessor(InfoflowManager manager) {
28-
this.manager = manager;
29-
}
28+
public ConditionalFlowPostProcessor(InfoflowManager manager) {
29+
this.manager = manager;
30+
}
3031

31-
@Override
32-
public InfoflowResults onResultsAvailable(InfoflowResults results, IInfoflowCFG cfg) {
33-
if (results.size() == 0)
34-
return results;
32+
@Override
33+
public InfoflowResults onResultsAvailable(InfoflowResults results, IInfoflowCFG cfg) {
34+
if (results.size() == 0)
35+
return results;
3536

36-
logger.info("Filtering conditional flows...");
37-
HashSet<ResultSinkInfo> tbr = new HashSet<>();
37+
logger.info("Filtering conditional flows, starting with {} flows...", results.numConnections());
38+
HashSet<ResultSinkInfo> tbr = new HashSet<>();
3839

39-
for (DataFlowResult dfRes : results.getResultSet()) {
40-
Set<SourceSinkCondition> conditions = dfRes.getSink().getDefinition().getConditions();
41-
// One of the conditions must match. Within both, a class name and a signature must match.
42-
if (conditions != null && !conditions.isEmpty()
43-
&& conditions.stream().noneMatch(cond -> cond.evaluate(dfRes, results)))
44-
tbr.add(dfRes.getSink());
45-
}
40+
for (DataFlowResult dfRes : results.getResultSet()) {
41+
Set<SourceSinkCondition> conditions = dfRes.getSink().getDefinition().getConditions();
42+
// One of the conditions must match. Within both, a class name and a signature
43+
// must match.
44+
if (conditions != null && !conditions.isEmpty()
45+
&& conditions.stream().noneMatch(cond -> cond.evaluate(dfRes, results)))
46+
tbr.add(dfRes.getSink());
47+
}
4648

47-
logger.info(String.format("Removed %d flows not meeting their conditions", tbr.size()));
48-
results.removeAll(tbr);
49+
logger.info(String.format("Removed %d flows not meeting their conditions", tbr.size()));
50+
results.removeAll(tbr);
4951

50-
return results;
51-
}
52+
return results;
53+
}
5254
}

0 commit comments

Comments
 (0)