Exemple #1
0
def analyze_solidity(input_type='solidity'):
    global args

    x = dtimer()
    is_runtime = not(args.init)
    print is_runtime
    if input_type == 'solidity':
        helper = InputHelper(InputHelper.SOLIDITY, source=args.source,evm=args.evm,runtime=is_runtime)
    elif input_type == 'standard_json':
        helper = InputHelper(InputHelper.STANDARD_JSON, source=args.source,evm=args.evm, allow_paths=args.allow_paths)
    elif input_type == 'standard_json_output':
        helper = InputHelper(InputHelper.STANDARD_JSON_OUTPUT, source=args.source,evm=args.evm)
    inputs = helper.get_inputs()
    hashes = process_hashes(args.source)
    
    y = dtimer()
    print("*************************************************************")
    print("Compilation time: "+str(y-x)+"s")
    print("*************************************************************")
    results, exit_code = run_solidity_analysis(inputs,hashes)
    helper.rm_tmp_files()

    if global_params.WEB:
        six.print_(json.dumps(results))
    return exit_code
Exemple #2
0
def analyze_solidity(input_type='solidity'):
    global args

    if input_type == 'solidity':
        helper = InputHelper(InputHelper.SOLIDITY,
                             source=args.source,
                             evm=args.evm,
                             compilation_err=args.compilation_error,
                             root_path=args.root_path,
                             remap=args.remap,
                             allow_paths=args.allow_paths)
    elif input_type == 'standard_json':
        helper = InputHelper(InputHelper.STANDARD_JSON,
                             source=args.source,
                             evm=args.evm,
                             allow_paths=args.allow_paths)
    elif input_type == 'standard_json_output':
        helper = InputHelper(InputHelper.STANDARD_JSON_OUTPUT,
                             source=args.source,
                             evm=args.evm)
    inputs = helper.get_inputs()
    results, exit_code = run_solidity_analysis(inputs)
    helper.rm_tmp_files()

    if global_params.WEB:
        six.print_(json.dumps(results))
    return exit_code
Exemple #3
0
def analyze_solidity(input_type='solidity'):
    global args

    if input_type == 'solidity':
        helper = InputHelper(InputHelper.SOLIDITY, source=args.source)
    elif input_type == 'standard_json':
        helper = InputHelper(InputHelper.STANDARD_JSON,
                             source=args.source,
                             allow_paths=args.allow_paths)
    inputs = helper.get_inputs()
    results, exit_code = run_solidity_analysis(inputs)
    helper.rm_tmp_files()

    if global_params.WEB:
        six.print_(json.dumps(results))
    return exit_code
Exemple #4
0
def __get_dataset_selection():
    downloaded_datasets = __get_downloaded_datasets()
    input_helper = InputHelper(help='\nSelect training dataset to be used:',
                               options=downloaded_datasets,
                               default=0)
    dataset = input_helper.get_output()
    return dataset
Exemple #5
0
def analyze_bytecode():
    global args

    x = dtimer()
    helper = InputHelper(InputHelper.BYTECODE, source=args.source,evm = args.evm)
    inp = helper.get_inputs()[0]
    y = dtimer()
    print("*************************************************************")
    print("Compilation time: "+str(y-x)+"s")
    print("*************************************************************")

    r = check_c_translation_dependencies()
    
    if r:
        svc_options={}
        if args.verify:
            svc_options["verify"]=args.verify
        if args.invalid:
            svc_options["invalid"]=args.invalid
        
        result, exit_code = symExec.run(disasm_file=inp['disasm_file'],cfg = args.control_flow_graph,saco = args.saco,debug = args.debug,evm_version = evm_version_modifications,cfile = args.cfile,svc=svc_options,go = args.goto)
        helper.rm_tmp_files()
    else:
        exit_code = -1
        print("Option Error: --verify option is only applied to c translation.\n")
    if global_params.WEB:
        six.print_(json.dumps(result))

    return exit_code
def analyze_bytecode():
    global args

    helper = InputHelper(InputHelper.BYTECODE, source=args.source)
    inp = helper.get_inputs()[0]

    result, exit_code = symExec.run(disasm_file=inp['disasm_file'])
    helper.rm_tmp_files()

    return exit_code
Exemple #7
0
def analyze_solidity(input_type='solidity'):
    global args

    x = dtimer()

    if input_type == 'solidity':
        helper = InputHelper(InputHelper.SOLIDITY,
                             source=args.source,
                             evm=args.evm)
    elif input_type == 'standard_json':
        helper = InputHelper(InputHelper.STANDARD_JSON,
                             source=args.source,
                             evm=args.evm,
                             allow_paths=args.allow_paths)
    elif input_type == 'standard_json_output':
        helper = InputHelper(InputHelper.STANDARD_JSON_OUTPUT,
                             source=args.source,
                             evm=args.evm)
    inputs = helper.get_inputs()
    hashes = process_hashes(args.source)

    y = dtimer()
    print("*************************************************************")
    print("Compilation time: " + str(y - x) + "s")
    print("*************************************************************")

    if check_optimize_dependencies():
        i = 0
        found = False
        while (i < len(inputs) and (not found)):
            if inputs[i]["c_name"] == args.contract_name:
                inp = inputs[i]
                found = True
            i += 1
        results, exit_code = run_solidity_analysis_optimized(inp, hashes)
    else:
        results, exit_code = run_solidity_analysis(inputs, hashes)
        helper.rm_tmp_files()

    if global_params.WEB:
        six.print_(json.dumps(results))
    return exit_code
Exemple #8
0
def analyze_bytecode():
    global args

    helper = InputHelper(InputHelper.BYTECODE, source=args.source)
    inp = helper.get_inputs()[0]

    result, exit_code = symExec.run(disasm_file=inp['disasm_file'])
    helper.rm_tmp_files()

    if global_params.WEB:
        six.print_(json.dumps(result))

    return exit_code
Exemple #9
0
def analyze_bytecode():
    global args

    helper = InputHelper(InputHelper.BYTECODE, source=args.source)
    inp = helper.get_inputs()[0]

    result, exit_code = analyze(disasm_file=inp['disasm_file'])
    helper.rm_tmp_files()

    if global_params.WEB:
        six.print_(json.dumps(result))

    if global_params.UNIT_TEST == 2 or global_params.UNIT_TEST == 3:
        exit_code = os.WEXITSTATUS(cmd)
        if exit_code != 0:
            exit(exit_code)
    return exit_code
Exemple #10
0
def analyze_bytecode():
    global args

    x = dtimer()
    helper = InputHelper(InputHelper.BYTECODE,
                         source=args.source,
                         evm=args.evm)
    inp = helper.get_inputs()[0]
    y = dtimer()
    print("Compilation time: " + str(y - x) + "s")

    result, exit_code = symExec.run(disasm_file=inp['disasm_file'],
                                    cfg=args.control_flow_graph,
                                    nop=args.evm_opcodes,
                                    saco=args.saco)
    helper.rm_tmp_files()

    if global_params.WEB:
        six.print_(json.dumps(result))

    return exit_code
Exemple #11
0
def __get_command_selection():
    input_helper = InputHelper(help='\nSelect command to be used:',
                               options=['train', 'test', 'list'],
                               default=0)
    command = input_helper.get_output()
    return command