Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,24 @@ Alternatively, you can pass your API key directly using the `--etherscan-api-key

```
Options:
-a,--address <arg> Address of an Ethereum smart contract
-a,--address <arg> Address of an Ethereum smart contract.
--abi <arg> ABI of the bytecode to be analyzed (JSON format).
--abi-path <arg> Filepath of the ABI file
-b,--bytecode <arg> Bytecode to be analyzed (e.g., 0x6080...)
--benchmark <arg> Filepath of the benchmark
--bytecode-path <arg> Filepath of the bytecode file
-c,--cores <arg> Number of cores used in benchmark
--checker-all Enable all security checkers
--checker-reentrancy Enable reentrancy checker
--checker-timestampdependency Enable timestamp-dependency checker
--checker-txorigin Enable tx-origin checker
--etherscan-api-key <arg> Insert your Etherscan API key
--link-unsound-jumps-to-all-jumpdest Link all unsound jumps to all jumpdest
--output-directory-path <arg> Filepath of the output directory
--stack-set-size <arg> Dimension of stack-set (default: 8)
--stack-size <arg> Dimension of stack (default: 32)
--use-live-storage Use the live storage in SLOAD
--abi-path <arg> Filepath of the ABI file.
-b,--bytecode <arg> Bytecode to be analyzed (e.g., 0x6080...).
--benchmark <arg> Filepath of the benchmark.
--bytecode-path <arg> Filepath of the bytecode file.
-c,--cores <arg> Number of cores used in benchmark.
--checker-all Enable all security checkers.
--checker-reentrancy Enable reentrancy checker.
--checker-timestampdependency Enable timestamp-dependency checker.
--checker-txorigin Enable tx-origin checker.
--etherscan-api-key <arg> Insert your Etherscan API key.
--link-unsound-jumps-to-all-jumpdest Link all unsound jumps to all jumpdest.
--output-directory-path <arg> Filepath of the output directory.
--show-all-instructions-in-cfg Show all instructions in the CFG representation.
--stack-set-size <arg> Dimension of stack-set (default: 8).
--stack-size <arg> Dimension of stack (default: 32).
--use-live-storage Use the live storage in SLOAD.
```

## The Abstract Stack Set Domain
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/it/unipr/EVMLiSA.java
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,8 @@ private void setupGlobalOptions(CommandLine cmd) {
EVMLiSA.setTestMode();
if (cmd.hasOption("paper-stats"))
EVMLiSA.setPaperMode();
if (cmd.hasOption("show-all-instructions-in-cfg"))
DOTFileManager.showAllInstructions();
}

private Options getOptions() {
Expand Down Expand Up @@ -949,6 +951,13 @@ private Options getOptions() {
.hasArg(false)
.build();

Option showAllInstructionsInCFG = Option.builder()
.longOpt("show-all-instructions-in-cfg")
.desc("Show all instructions in the Control Flow Graph representation.")
.required(false)
.hasArg(false)
.build();

options.addOption(addressOption);
options.addOption(bytecodeOption);
options.addOption(bytecodePathOption);
Expand All @@ -968,6 +977,7 @@ private Options getOptions() {
options.addOption(abiOption);
options.addOption(useTestModeOption);
options.addOption(usePaperStats);
options.addOption(showAllInstructionsInCFG);

return options;
}
Expand Down
19 changes: 18 additions & 1 deletion src/main/java/it/unipr/utils/DOTFileManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@ public class DOTFileManager {
public static String blueColor = "#6FA8DC";
public static String blackColor = "#000000";

public static boolean showAllInstructions = false;

/**
* Sets a flag to show all instructions.
*/
public static void showAllInstructions() {
showAllInstructions = true;
}

/**
* Generates a DOT graph from the provided basic blocks and writes it to the
* specified output path. The graph includes nodes for each basic block,
* edges for outgoing edges, and a legend for color interpretation.
*
* @param basicBlocks an array of JSON objects representing basic blocks
* @param outputPath the file path where the .dot file will be written
*/
public static void generateDotGraph(JSONArray basicBlocks, String outputPath) {
StringBuilder dotGraph = new StringBuilder();
dotGraph.append("digraph CFG {\n");
Expand All @@ -36,7 +53,7 @@ public static void generateDotGraph(JSONArray basicBlocks, String outputPath) {
if (block.has("label"))
label.append(block.getString("label")).append("\\n- - - - - - - - - - - -\\n");

if (instructions.length() > 5) {
if (!showAllInstructions && instructions.length() > 5) {
JSONObject firstInstr = instructions.getJSONObject(0);
JSONObject secondInstr = instructions.getJSONObject(1);
JSONObject secondLastInstr = instructions.getJSONObject(instructions.length() - 2);
Expand Down