From 89fca79506835832b3d6527d46a255ecf80de684 Mon Sep 17 00:00:00 2001 From: Johannes Spaeth Date: Tue, 27 Nov 2018 00:26:27 +0100 Subject: [PATCH] #100 Added data-flow path to results --- .../analysis/AnalysisSeedWithEnsuredPredicate.java | 11 ++++++----- .../analysis/AnalysisSeedWithSpecification.java | 1 - .../main/java/crypto/analysis/IAnalysisSeed.java | 13 ++++++++++++- .../analysis/errors/ErrorWithObjectAllocation.java | 9 +++++++++ 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/CryptoAnalysis/src/main/java/crypto/analysis/AnalysisSeedWithEnsuredPredicate.java b/CryptoAnalysis/src/main/java/crypto/analysis/AnalysisSeedWithEnsuredPredicate.java index a6c06e45f..e78a25cbe 100644 --- a/CryptoAnalysis/src/main/java/crypto/analysis/AnalysisSeedWithEnsuredPredicate.java +++ b/CryptoAnalysis/src/main/java/crypto/analysis/AnalysisSeedWithEnsuredPredicate.java @@ -24,7 +24,7 @@ public class AnalysisSeedWithEnsuredPredicate extends IAnalysisSeed{ - private ForwardBoomerangResults analysisResults; + private ForwardBoomerangResults results; private Set ensuredPredicates = Sets.newHashSet(); private ExtendedIDEALAnaylsis problem; private boolean analyzed; @@ -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 c : analysisResults.asStatementValWeightTable().cellSet()){ + for(Cell c : results.asStatementValWeightTable().cellSet()){ predicateHandler.addNewPred(this,c.getRowKey(), c.getColumnKey(), pred); } } @@ -101,4 +101,5 @@ public void addEnsuredPredicate(EnsuredCryptSLPredicate pred) { public String toString() { return "AnalysisSeedWithEnsuredPredicate:"+this.asNode() +" " + ensuredPredicates; } + } diff --git a/CryptoAnalysis/src/main/java/crypto/analysis/AnalysisSeedWithSpecification.java b/CryptoAnalysis/src/main/java/crypto/analysis/AnalysisSeedWithSpecification.java index 4efcffda2..a6789eea8 100644 --- a/CryptoAnalysis/src/main/java/crypto/analysis/AnalysisSeedWithSpecification.java +++ b/CryptoAnalysis/src/main/java/crypto/analysis/AnalysisSeedWithSpecification.java @@ -68,7 +68,6 @@ public class AnalysisSeedWithSpecification extends IAnalysisSeed { private final ClassSpecification spec; private ExtendedIDEALAnaylsis analysis; - private ForwardBoomerangResults results; private Collection ensuredPredicates = Sets.newHashSet(); private Multimap typeStateChange = HashMultimap.create(); private Collection indirectlyEnsuredPredicates = Sets.newHashSet(); diff --git a/CryptoAnalysis/src/main/java/crypto/analysis/IAnalysisSeed.java b/CryptoAnalysis/src/main/java/crypto/analysis/IAnalysisSeed.java index f77088629..283bf73fd 100644 --- a/CryptoAnalysis/src/main/java/crypto/analysis/IAnalysisSeed.java +++ b/CryptoAnalysis/src/main/java/crypto/analysis/IAnalysisSeed.java @@ -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 { protected final CryptoScanner cryptoScanner; protected final PredicateHandler predicateHandler; + protected ForwardBoomerangResults results; private String objectId; public IAnalysisSeed(CryptoScanner scanner, Statement stmt, Val fact, TransitionFunction func){ @@ -40,7 +45,13 @@ public String getObjectId() { this.objectId = new BigInteger(1, md.digest(this.toString().getBytes())).toString(16); } return this.objectId; - } + + public Set> getDataFlowPath(){ + if(results == null) { + return Collections.emptySet(); + } + return results.getDataFlowPath(); + } } diff --git a/CryptoAnalysis/src/main/java/crypto/analysis/errors/ErrorWithObjectAllocation.java b/CryptoAnalysis/src/main/java/crypto/analysis/errors/ErrorWithObjectAllocation.java index d2b08e70e..a87678280 100644 --- a/CryptoAnalysis/src/main/java/crypto/analysis/errors/ErrorWithObjectAllocation.java +++ b/CryptoAnalysis/src/main/java/crypto/analysis/errors/ErrorWithObjectAllocation.java @@ -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; @@ -21,4 +26,8 @@ protected String getObjectType() { return " on object of type " + this.objectAllocationLocation.asNode().fact().value().getType(); return ""; } + + public Set> getDataFlowPath() { + return objectAllocationLocation.getDataFlowPath(); + } }