Skip to content

Commit

Permalink
Merge pull request #127 from nevillegrech/feat/tac_gen_cli_arg
Browse files Browse the repository at this point in the history
Add optional CLI argument for tac gen config file path
  • Loading branch information
sifislag authored Mar 1, 2024
2 parents c3fceb5 + 74a0aa7 commit 10de8a7
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions gigahorse.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
import json
import logging
import shutil
import re
import sys
import time
from collections import defaultdict
from multiprocessing import Process, SimpleQueue, Manager, Event, cpu_count
from typing import List, Tuple, Type, Any, Dict, DefaultDict
from typing import List, Tuple, Any, Dict, DefaultDict
from os.path import join, getsize
import os

Expand All @@ -21,7 +20,7 @@

## Constants

TAC_GEN_CONFIG_FILE = 'tac_gen_config.json'
DEFAULT_TAC_GEN_CONFIG_FILE = join(GIGAHORSE_DIR, 'tac_gen_config.json')

DEFAULT_RESULTS_FILE = 'results.json'
"""File to write results to by default."""
Expand Down Expand Up @@ -192,6 +191,13 @@
default=False,
help="Run souffle in interpreted mode.")

parser.add_argument(
"--tac_gen_config",
nargs="?",
default=DEFAULT_TAC_GEN_CONFIG_FILE,
metavar="TAC_GEN_CONFIG",
help="the location of the TAC generation configuration file",
)

def get_working_dir(contract_name: str) -> str:
return join(os.path.abspath(args.working_dir), os.path.split(contract_name)[1].split('.')[0])
Expand Down Expand Up @@ -589,7 +595,7 @@ def run_gigahorse(args, fact_generator: AbstractFactGenerator) -> None:

args = parser.parse_args()

tac_gen_config_json = os.path.join(os.path.dirname(os.path.abspath(__file__)),TAC_GEN_CONFIG_FILE)
tac_gen_config_json = args.tac_gen_config
with open(tac_gen_config_json, 'r') as config:
tac_gen_config = json.loads(config.read())
if len(tac_gen_config["handlers"]) == 0: #if no handlers defined, default to classic decompilation
Expand Down

0 comments on commit 10de8a7

Please sign in to comment.