Skip to content

Commit

Permalink
Make use of bugfixes in IDEAL
Browse files Browse the repository at this point in the history
  • Loading branch information
smeyer198 committed Feb 4, 2025
1 parent 9986514 commit 88890c2
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 658 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void registerExpectedPredicate(ExpectedPredicate expectedPredicate) {
}

for (AnalysisSeedWithSpecification seed : scanner.getAnalysisSeedsWithSpec()) {
Collection<Statement> invokedMethods = seed.getInvokedMethods();
Collection<Statement> invokedMethods = seed.getInvokedMethodStatements();

if (invokedMethods.contains(statement)) {
seed.registerExpectedPredicate(predicate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class AnalysisSeedWithSpecification extends IAnalysisSeed {
private boolean internalConstraintsSatisfied;

private final Multimap<Statement, State> typeStateChange = HashMultimap.create();
private final Map<ControlFlowGraph.Edge, DeclaredMethod> allCallsOnObject;
private final Collection<Statement> allCallsOnObject;

private final Multimap<Statement, Integer> relevantStatements = HashMultimap.create();
private final Collection<AbstractPredicate> indirectlyEnsuredPredicates = new HashSet<>();
Expand All @@ -65,7 +65,7 @@ public AnalysisSeedWithSpecification(
super(scanner, statement, fact, results);

this.specification = specification;
this.allCallsOnObject = results.getInvokedMethodOnInstance();
this.allCallsOnObject = results.getInvokeStatementsOnInstance();

Definitions.ConstraintsDefinition definition =
new Definitions.ConstraintsDefinition(
Expand Down Expand Up @@ -109,15 +109,16 @@ public void execute() {

/** Check the FORBIDDEN section and report corresponding errors */
private void evaluateForbiddenMethods() {
for (Map.Entry<ControlFlowGraph.Edge, DeclaredMethod> calledMethod :
allCallsOnObject.entrySet()) {
Optional<CrySLForbiddenMethod> forbiddenMethod =
isForbiddenMethod(calledMethod.getValue());
for (Statement statement : allCallsOnObject) {
if (!statement.containsInvokeExpr()) {
continue;
}

DeclaredMethod declaredMethod = statement.getInvokeExpr().getMethod();
Optional<CrySLForbiddenMethod> forbiddenMethod = isForbiddenMethod(declaredMethod);

if (forbiddenMethod.isPresent()) {
Collection<CrySLMethod> alternatives = forbiddenMethod.get().getAlternatives();
Statement statement = calledMethod.getKey().getStart();
DeclaredMethod declaredMethod = calledMethod.getValue();

ForbiddenMethodError error =
new ForbiddenMethodError(
Expand Down Expand Up @@ -301,7 +302,7 @@ private boolean isMethodToAcceptingState(DeclaredMethod method) {

@Override
public void beforePredicateChecks(Collection<IAnalysisSeed> seeds) {
for (Statement statement : getInvokedMethods()) {
for (Statement statement : getInvokedMethodStatements()) {
relevantStatements.put(statement, -1);
}

Expand Down Expand Up @@ -817,20 +818,10 @@ public CrySLRule getSpecification() {
return specification;
}

public Map<ControlFlowGraph.Edge, DeclaredMethod> getAllCallsOnObject() {
public Collection<Statement> getInvokedMethodStatements() {
return allCallsOnObject;
}

public Collection<Statement> getInvokedMethods() {
Collection<Statement> statements = new HashSet<>();

for (ControlFlowGraph.Edge edge : allCallsOnObject.keySet()) {
statements.add(edge.getStart());
}

return statements;
}

public Collection<EnsuredPredicate> getEnsuredPredicatesAtStatement(Statement statement) {
return ensuredPredicates.get(statement);
}
Expand Down
13 changes: 2 additions & 11 deletions CryptoAnalysis/src/main/java/crypto/analysis/IAnalysisSeed.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package crypto.analysis;

import boomerang.results.ForwardBoomerangResults;
import boomerang.scene.ControlFlowGraph;
import boomerang.scene.Method;
import boomerang.scene.Statement;
import boomerang.scene.Type;
import boomerang.scene.Val;
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.Table;
Expand Down Expand Up @@ -49,18 +47,11 @@ public IAnalysisSeed(
this.fact = fact;
this.analysisResults = results;

this.errorCollection = new HashSet<>();

this.statementValWeightTable = HashBasedTable.create();
for (Table.Cell<ControlFlowGraph.Edge, Val, TransitionFunction> cell :
results.asEdgeValWeightTable().cellSet()) {
statementValWeightTable.put(
cell.getRowKey().getStart(), cell.getColumnKey(), cell.getValue());
}
this.statementValWeightTable = results.asStatementValWeightTable();

this.errorCollection = new HashSet<>();
this.expectedPredicates = HashMultimap.create();
this.predicateStateChangeListeners = new HashSet<>();

this.ensuredPredicates = HashMultimap.create();
this.unEnsuredPredicates = HashMultimap.create();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package crypto.constraints;

import boomerang.scene.ControlFlowGraph;
import boomerang.scene.Statement;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
Expand Down Expand Up @@ -53,11 +52,7 @@ public void initialize() {

private void initializeCollectedCalls() {
collectedCalls.clear();

Collection<ControlFlowGraph.Edge> edges = seed.getAllCallsOnObject().keySet();
for (ControlFlowGraph.Edge edge : edges) {
collectedCalls.add(edge.getStart());
}
collectedCalls.addAll(seed.getInvokedMethodStatements());
}

private void initializeExtractedValues() {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 88890c2

Please sign in to comment.