Skip to content

Commit c636e46

Browse files
committed
Added soundness checker at the end of each analysis
1 parent 5f30071 commit c636e46

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/main/java/it/unipr/analysis/MyLogger.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ public String getJson() {
181181
return json.toString(4);
182182
}
183183

184+
public boolean isSound() {
185+
return unsoundJumps == 0 && maybeUnsoundJumps == 0;
186+
}
187+
184188
@Override
185189
public String toString() {
186190
return address + divider +

src/main/java/it/unipr/crossChainAnalysis/CrossChainAnalysis.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package it.unipr.crossChainAnalysis;
22

3+
import it.unipr.EVMLiSA;
34
import it.unipr.analysis.*;
45
import it.unipr.cfg.EVMCFG;
56
import it.unipr.cfg.ProgramCounterLocation;
@@ -23,6 +24,7 @@
2324
import java.nio.file.Path;
2425
import java.nio.file.Paths;
2526
import java.util.HashSet;
27+
import java.util.Objects;
2628
import java.util.Set;
2729
import java.util.concurrent.ExecutorService;
2830
import java.util.concurrent.Executors;
@@ -196,10 +198,15 @@ private void startAnalysis() throws InterruptedException {
196198
contract.setCFG(checker.getComputedCFG());
197199
contract.computeFunctionEntrypoints();
198200

199-
// TODO we must check the soundness
200-
// Set<Statement> soundlySolved = EVMLiSA.getSoundlySolvedJumps(checker, lisa, program);
201-
// MyLogger myLogger = EVMLiSA.dumpStatistics(checker, soundlySolved);
201+
// check soundness
202+
if (!Objects.requireNonNull(
203+
EVMLiSA.dumpStatistics(checker,
204+
EVMLiSA.getSoundlySolvedJumps(checker, lisa, program)))
205+
.isSound())
206+
log.warn("UNSOUND on {}", contract.getName());
202207

208+
} catch (NullPointerException npe) {
209+
log.error("Error checking soundness in bytecode {}: {}", contract.getName(), npe.getMessage());
203210
} catch (Exception e) {
204211
log.error("Error processing bytecode {}: {}", contract.getName(), e.getMessage());
205212
}

0 commit comments

Comments
 (0)