Skip to content

Commit

Permalink
make use of actual integration tests! state: compiles + executable; f…
Browse files Browse the repository at this point in the history
…ixed dependencies; tests fail
  • Loading branch information
swissiety committed Oct 15, 2024
1 parent 5bca69d commit 5aec810
Show file tree
Hide file tree
Showing 47 changed files with 1,222 additions and 1,226 deletions.
11 changes: 11 additions & 0 deletions boomerangPDS/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
<groupId>de.fraunhofer.iem</groupId>
<artifactId>boomerangScope</artifactId>
</dependency>
<dependency>
<groupId>de.fraunhofer.iem</groupId>
<artifactId>boomerangScope-Soot</artifactId>
<version>3.1.2-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.fraunhofer.iem</groupId>
<artifactId>synchronizedPDS</artifactId>
Expand Down Expand Up @@ -68,6 +74,11 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.4.0</version>
<executions>
<execution>
<phase>integration-test</phase>
</execution>
</executions>
<configuration>
<excludes>
<exclude>**/*LongTest.java</exclude>
Expand Down
7 changes: 5 additions & 2 deletions boomerangPDS/src/main/java/boomerang/Boomerang.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ public class Boomerang extends WeightedBoomerang<Weight.NoWeight> {
private OneWeightFunctions<Edge, Val, Field, Weight.NoWeight> fieldWeights;
private OneWeightFunctions<Edge, Val, Edge, Weight.NoWeight> callWeights;

public Boomerang(CallGraph callGraph, DataFlowScope scope, ScopeFactory scopeFactory) {
public Boomerang(CallGraph callGraph, DataFlowScope scope, FrameworkScopeFactory scopeFactory) {
super(callGraph, scope, scopeFactory);
}

public Boomerang(
CallGraph callGraph, DataFlowScope scope, BoomerangOptions opt, ScopeFactory scopeFactory) {
CallGraph callGraph,
DataFlowScope scope,
BoomerangOptions opt,
FrameworkScopeFactory scopeFactory) {
super(callGraph, scope, opt, scopeFactory);
}

Expand Down
2 changes: 1 addition & 1 deletion boomerangPDS/src/main/java/boomerang/BoomerangOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import boomerang.scene.Method;
import boomerang.scene.Statement;
import boomerang.scene.Val;
import boomerang.sparse.SparsificationStrategy;
import boomerang.stats.IBoomerangStats;
import java.util.Optional;
import sparse.SparsificationStrategy;

public interface BoomerangOptions {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
import boomerang.scene.Method;
import boomerang.scene.Statement;
import boomerang.scene.Val;
import boomerang.sparse.SparsificationStrategy;
import boomerang.stats.IBoomerangStats;
import boomerang.stats.SimpleBoomerangStats;
import com.google.common.base.Joiner;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import sparse.SparsificationStrategy;

public class DefaultBoomerangOptions implements BoomerangOptions {

Expand Down Expand Up @@ -221,7 +221,6 @@ public boolean allowMultipleQueries() {
public SparsificationStrategy getSparsificationStrategy() {
return new SparsificationStrategy.NoSparsification();
}
;

@Override
public boolean handleSpecialInvokeAsNormalPropagation() {
Expand Down
9 changes: 6 additions & 3 deletions boomerangPDS/src/main/java/boomerang/WeightedBoomerang.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
import wpds.interfaces.WPAStateListener;

public abstract class WeightedBoomerang<W extends Weight> {
protected final ScopeFactory scopeFactory;
protected final FrameworkScopeFactory scopeFactory;
protected ObservableICFG<Statement, Method> icfg;
protected ObservableControlFlowGraph cfg;
private static final Logger LOGGER = LoggerFactory.getLogger(WeightedBoomerang.class);
Expand Down Expand Up @@ -396,7 +396,10 @@ protected FieldWritePOI createItem(FieldWritePOI key) {
private INode<Val> rootQuery;

public WeightedBoomerang(
CallGraph cg, DataFlowScope scope, BoomerangOptions options, ScopeFactory scopeFactory) {
CallGraph cg,
DataFlowScope scope,
BoomerangOptions options,
FrameworkScopeFactory scopeFactory) {
this.scopeFactory = scopeFactory;
this.options = options;
this.options.checkValid();
Expand All @@ -419,7 +422,7 @@ public WeightedBoomerang(
this.queryGraph = new QueryGraph<>(this);
}

public WeightedBoomerang(CallGraph cg, DataFlowScope scope, ScopeFactory scopeFactory) {
public WeightedBoomerang(CallGraph cg, DataFlowScope scope, FrameworkScopeFactory scopeFactory) {
this(cg, scope, new DefaultBoomerangOptions(), scopeFactory);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ public abstract class WholeProgramBoomerang<W extends Weight> extends WeightedBo
private CallGraph callGraph;

public WholeProgramBoomerang(
CallGraph cg, DataFlowScope scope, BoomerangOptions opts, ScopeFactory scopeFactory) {
CallGraph cg,
DataFlowScope scope,
BoomerangOptions opts,
FrameworkScopeFactory scopeFactory) {
super(cg, scope, opts, scopeFactory);
this.callGraph = cg;
}

public WholeProgramBoomerang(CallGraph cg, DataFlowScope scope, ScopeFactory scopeFactory) {
public WholeProgramBoomerang(
CallGraph cg, DataFlowScope scope, FrameworkScopeFactory scopeFactory) {
this(cg, scope, new DefaultBoomerangOptions(), scopeFactory);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public enum NoCalleeFoundFallbackOptions {
private Set<Statement> queriedInvokeExpr = Sets.newHashSet();
;

public BoomerangResolver(CallGraph cg, DataFlowScope scope, ScopeFactory scopeFactory) {
public BoomerangResolver(CallGraph cg, DataFlowScope scope, FrameworkScopeFactory scopeFactory) {
this.solver = new Boomerang(cg, scope, scopeFactory);
this.precomputedCallGraph = cg;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import boomerang.scene.Method;
import boomerang.scene.Statement;
import boomerang.scene.Val;
import boomerang.sparse.SparsificationStrategy;
import boomerang.sparse.eval.PropagationCounter;
import java.util.*;
import sparse.SparsificationStrategy;

public class StaticCFG implements ObservableControlFlowGraph {

Expand Down Expand Up @@ -59,15 +57,15 @@ private void propagateSparse(
SuccessorListener l, Method method, Statement curr, SparseAliasingCFG sparseCFG) {
Set<Unit> successors = sparseCFG.getGraph().successors(SootAdapter.asStmt(curr));
for (Unit succ : successors) {
PropagationCounter.getInstance(sparsificationStrategy).countForward();
sparsificationStrategy.getCounter().countForward();
l.getSuccessor(SootAdapter.asStatement(succ, method));
}
}
*/

private void propagateDefault(SuccessorListener l) {
for (Statement s : l.getCurr().getMethod().getControlFlowGraph().getSuccsOf(l.getCurr())) {
PropagationCounter.getInstance(sparsificationStrategy).countForward();
sparsificationStrategy.getCounter().countForward();
l.getSuccessor(s);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import boomerang.scene.CallGraph;
import boomerang.scene.ControlFlowGraph.Edge;
import boomerang.scene.DataFlowScope;
import boomerang.scene.ScopeFactory;
import boomerang.scene.FrameworkScopeFactory;
import boomerang.scene.Val;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
Expand Down Expand Up @@ -43,7 +43,7 @@ public DemandDrivenGuidedAnalysis(
BoomerangOptions options,
DataFlowScope dataFlowScope,
CallGraph callGraph,
ScopeFactory scopeFactory) {
FrameworkScopeFactory scopeFactory) {
spec = specification;
scope = dataFlowScope;
this.callGraph = callGraph;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

public class ForwardBoomerangResults<W extends Weight> extends AbstractBoomerangResults<W> {

private final ScopeFactory scopeFactory;
private final FrameworkScopeFactory scopeFactory;
private final ForwardQuery query;
private final boolean timedout;
private final IBoomerangStats<W> stats;
Expand All @@ -50,7 +50,7 @@ public class ForwardBoomerangResults<W extends Weight> extends AbstractBoomerang
private boolean pruneImplictFlows;

public ForwardBoomerangResults(
ScopeFactory scopeFactory,
FrameworkScopeFactory scopeFactory,
ForwardQuery query,
ObservableICFG<Statement, Method> icfg,
ObservableControlFlowGraph cfg,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ protected void normalFlow(Method method, Node<ControlFlowGraph.Edge, Val> currNo
curr.getStart().getMethod().getControlFlowGraph().getPredsOf(curr.getStart())) {
Collection<State> flow = computeNormalFlow(method, new Edge(pred, curr.getStart()), value);
for (State s : flow) {
// TODO: [ms] re-enable sparse
// PropagationCounter.getInstance(options.getSparsificationStrategy()).countBackward();
options.getSparsificationStrategy().getCounter().countBackward();
propagate(currNode, s);
}
}
Expand All @@ -199,7 +198,6 @@ protected void normalFlow(Method method, Node<ControlFlowGraph.Edge, Val> currNo

/*
// TODO: [ms] re-enable sparse
private void propagateSparse(Method method, Node<Edge, Val> currNode, Edge curr, Val value) {
Statement propStmt = curr.getStart();
SparseAliasingCFG sparseCFG = getSparseCFG(query, method, value, propStmt);
Expand All @@ -211,7 +209,7 @@ private void propagateSparse(Method method, Node<Edge, Val> currNode, Edge curr,
computeNormalFlow(
method, new Edge(SootAdapter.asStatement(pred, method), propStmt), value);
for (State s : flow) {
PropagationCounter.getInstance(options.getSparsificationStrategy()).countBackward();
options.getSparsificationStrategy().getCounter().countBackward();
propagate(currNode, s);
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ public abstract class PathTrackingBoomerang extends WeightedBoomerang<DataFlowPa
private OneWeightFunctions<Edge, Val, Field, DataFlowPathWeight> fieldWeights;
private PathTrackingWeightFunctions callWeights;

public PathTrackingBoomerang(CallGraph cg, DataFlowScope scope, ScopeFactory scopeFactory) {
super(cg, scope, scopeFactory);
public PathTrackingBoomerang(
CallGraph cg, DataFlowScope scope, FrameworkScopeFactory frameworkScopeFactory) {
super(cg, scope, frameworkScopeFactory);
}

public PathTrackingBoomerang(
CallGraph cg, DataFlowScope scope, BoomerangOptions opt, ScopeFactory scopeFactory) {
super(cg, scope, opt, scopeFactory);
CallGraph cg,
DataFlowScope scope,
BoomerangOptions opt,
FrameworkScopeFactory frameworkScopeFactory) {
super(cg, scope, opt, frameworkScopeFactory);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
import boomerang.scene.AllocVal;
import boomerang.scene.ControlFlowGraph.Edge;
import boomerang.scene.Method;
import boomerang.scene.SootDataFlowScope;
import boomerang.scene.Statement;
import boomerang.scene.Val;
import boomerang.scene.jimple.BoomerangPretransformer;
import boomerang.scene.jimple.IntAndStringBoomerangOptions;
import boomerang.scene.jimple.JimpleMethod;
import boomerang.scene.jimple.SootCallGraph;
import boomerang.solver.BackwardBoomerangSolver;
import boomerang.soot.SootDataFlowScope;
import boomerang.soot.SootFrameworkFactoryFramework;
import boomerang.soot.jimple.BoomerangPretransformer;
import boomerang.soot.jimple.JimpleMethod;
import boomerang.soot.jimple.SootCallGraph;
import com.google.common.collect.Lists;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -54,7 +55,8 @@ public void killOnSystemExitBackwardTestInteger() {
new Boomerang(
sootCallGraph,
SootDataFlowScope.make(Scene.v()),
new CustomIntAndStringBoomerangOptions());
new CustomIntAndStringBoomerangOptions(),
new SootFrameworkFactoryFramework());

System.out.println("Solving query: " + query);
BackwardBoomerangResults<NoWeight> backwardQueryResults = solver.solve(query);
Expand All @@ -80,7 +82,10 @@ public void killOnSystemExitBackwardTest() {
SootCallGraph sootCallGraph = new SootCallGraph();
Boomerang solver =
new Boomerang(
sootCallGraph, SootDataFlowScope.make(Scene.v()), new CustomBoomerangOptions());
sootCallGraph,
SootDataFlowScope.make(Scene.v()),
new CustomBoomerangOptions(),
new SootFrameworkFactoryFramework());

System.out.println("Solving query: " + query);
BackwardBoomerangResults<NoWeight> backwardQueryResults = solver.solve(query);
Expand All @@ -103,7 +108,10 @@ public void killOnSystemExitForwardTest() {
SootCallGraph sootCallGraph = new SootCallGraph();
Boomerang solver =
new Boomerang(
sootCallGraph, SootDataFlowScope.make(Scene.v()), new CustomBoomerangOptions());
sootCallGraph,
SootDataFlowScope.make(Scene.v()),
new CustomBoomerangOptions(),
new SootFrameworkFactoryFramework());

System.out.println("Solving query: " + query);
ForwardBoomerangResults<NoWeight> res = solver.solve(query);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@
import boomerang.guided.targets.WrappedInStringTwiceTest;
import boomerang.scene.*;
import boomerang.scene.ControlFlowGraph.Edge;
import boomerang.scene.jimple.BoomerangPretransformer;
import boomerang.scene.jimple.IntAndStringBoomerangOptions;
import boomerang.scene.jimple.JimpleMethod;
import boomerang.soot.SootDataFlowScope;
import boomerang.soot.SootFrameworkFactoryFramework;
import boomerang.soot.jimple.BoomerangPretransformer;
import boomerang.soot.jimple.JimpleMethod;
import boomerang.soot.jimple.SootCallGraph;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import java.nio.file.Path;
Expand Down Expand Up @@ -409,7 +412,10 @@ public int analysisTimeoutMS() {
public boolean allowMultipleQueries() {
return true;
}
});
},
SootDataFlowScope.make(Scene.v()),
new SootCallGraph(),
new SootFrameworkFactoryFramework());

QueryGraph<NoWeight> queryGraph = demandDrivenGuidedAnalysis.run(query);
demandDrivenGuidedAnalysis.cleanUp();
Expand Down
Loading

0 comments on commit 5aec810

Please sign in to comment.