Skip to content

Commit

Permalink
#100 Added data-flow path to results
Browse files Browse the repository at this point in the history
  • Loading branch information
johspaeth committed Nov 26, 2018
1 parent 32ca991 commit 89fca79
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

public class AnalysisSeedWithEnsuredPredicate extends IAnalysisSeed{

private ForwardBoomerangResults<TransitionFunction> analysisResults;
private ForwardBoomerangResults<TransitionFunction> results;
private Set<EnsuredCryptSLPredicate> ensuredPredicates = Sets.newHashSet();
private ExtendedIDEALAnaylsis problem;
private boolean analyzed;
Expand All @@ -38,18 +38,18 @@ public void execute() {
cryptoScanner.getAnalysisListener().seedStarted(this);
ExtendedIDEALAnaylsis solver = getOrCreateAnalysis();
solver.run(this);
analysisResults = solver.getResults();
results = solver.getResults();
for(EnsuredCryptSLPredicate pred : ensuredPredicates)
ensurePredicates(pred);
cryptoScanner.getAnalysisListener().onSeedFinished(this, analysisResults);
cryptoScanner.getAnalysisListener().onSeedFinished(this, results);
analyzed = true;
}

protected void ensurePredicates(EnsuredCryptSLPredicate pred) {
if(analysisResults == null)
if(results == null)
return;

for(Cell<Statement, Val, TransitionFunction> c : analysisResults.asStatementValWeightTable().cellSet()){
for(Cell<Statement, Val, TransitionFunction> c : results.asStatementValWeightTable().cellSet()){
predicateHandler.addNewPred(this,c.getRowKey(), c.getColumnKey(), pred);
}
}
Expand Down Expand Up @@ -101,4 +101,5 @@ public void addEnsuredPredicate(EnsuredCryptSLPredicate pred) {
public String toString() {
return "AnalysisSeedWithEnsuredPredicate:"+this.asNode() +" " + ensuredPredicates;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public class AnalysisSeedWithSpecification extends IAnalysisSeed {

private final ClassSpecification spec;
private ExtendedIDEALAnaylsis analysis;
private ForwardBoomerangResults<TransitionFunction> results;
private Collection<EnsuredCryptSLPredicate> ensuredPredicates = Sets.newHashSet();
private Multimap<Statement, State> typeStateChange = HashMultimap.create();
private Collection<EnsuredCryptSLPredicate> indirectlyEnsuredPredicates = Sets.newHashSet();
Expand Down
13 changes: 12 additions & 1 deletion CryptoAnalysis/src/main/java/crypto/analysis/IAnalysisSeed.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Collections;
import java.util.Set;

import boomerang.WeightedForwardQuery;
import boomerang.jimple.Statement;
import boomerang.jimple.Val;
import boomerang.results.ForwardBoomerangResults;
import crypto.predicates.PredicateHandler;
import soot.SootMethod;
import sync.pds.solver.nodes.Node;
import typestate.TransitionFunction;

public abstract class IAnalysisSeed extends WeightedForwardQuery<TransitionFunction> {

protected final CryptoScanner cryptoScanner;
protected final PredicateHandler predicateHandler;
protected ForwardBoomerangResults<TransitionFunction> results;
private String objectId;

public IAnalysisSeed(CryptoScanner scanner, Statement stmt, Val fact, TransitionFunction func){
Expand All @@ -40,7 +45,13 @@ public String getObjectId() {
this.objectId = new BigInteger(1, md.digest(this.toString().getBytes())).toString(16);
}
return this.objectId;

}


public Set<Node<Statement,Val>> getDataFlowPath(){
if(results == null) {
return Collections.emptySet();
}
return results.getDataFlowPath();
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package crypto.analysis.errors;

import java.util.Set;


import boomerang.jimple.Statement;
import boomerang.jimple.Val;
import crypto.analysis.IAnalysisSeed;
import crypto.rules.CryptSLRule;
import sync.pds.solver.nodes.Node;

public abstract class ErrorWithObjectAllocation extends AbstractError{
private final IAnalysisSeed objectAllocationLocation;
Expand All @@ -21,4 +26,8 @@ protected String getObjectType() {
return " on object of type " + this.objectAllocationLocation.asNode().fact().value().getType();
return "";
}

public Set<Node<Statement,Val>> getDataFlowPath() {
return objectAllocationLocation.getDataFlowPath();
}
}

0 comments on commit 89fca79

Please sign in to comment.