コード例 #1
0
def has_dependencies_installed():
    try:
        import z3
        import z3.z3util
        z3_version = z3.get_version_string()
        tested_z3_version = '4.5.1'
        if compare_versions(z3_version, tested_z3_version) > 0:
            logging.warning(
                "You are using an untested version of z3. %s is the officially tested version"
                % tested_z3_version)
    except:
        logging.critical(
            "Z3 is not available. Please install z3 from https://github.com/Z3Prover/z3."
        )
        return False

    if not cmd_exists("evm"):
        logging.critical(
            "Please install evm from go-ethereum and make sure it is in the path."
        )
        return False
    else:
        cmd = "evm --version"
        out = run_command(cmd).strip()
        evm_version = re.findall(r"evm version (\d*.\d*.\d*)", out)[0]
        tested_evm_version = '1.7.3'
        if compare_versions(evm_version, tested_evm_version) > 0:
            logging.warning(
                "You are using evm version %s. The supported version is %s" %
                (evm_version, tested_evm_version))

    if not cmd_exists("lityc"):
        logging.critical(
            "lityc is missing. Please install the solidity compiler and make sure lityc is in the path."
        )
        return False
    else:
        cmd = "lityc --version"
        out = run_command(cmd).strip()
        lityc_version = re.findall(r"Version: (\d*.\d*.\d*)", out)[0]
        tested_lityc_version = '0.4.19'
        if compare_versions(lityc_version, tested_lityc_version) > 0:
            logging.warning(
                "You are using lityc version %s, The latest supported version is %s"
                % (lityc_version, tested_lityc_version))

    return True
コード例 #2
0
 def get_source_list(self, filename):
     if self.allow_paths:
         cmd = "lityc --disable-oyente --combined-json ast %s %s --allow-paths %s" % (self.remap, filename, self.allow_paths)
     else:
         cmd = "lityc --disable-oyente --combined-json ast %s %s" % (self.remap, filename)
     out = run_command(cmd)
     out = json.loads(out)
     return out["sources"]
コード例 #3
0
 def _load_position_groups(cls):
     if cls.allow_paths:
         cmd = "lityc --disable-oyente --combined-json asm %s %s --allow-paths %s" % (
             cls.remap, cls.parent_filename, cls.allow_paths)
     else:
         cmd = "lityc --disable-oyente --combined-json asm %s %s" % (
             cls.remap, cls.parent_filename)
     out = run_command(cmd)
     out = json.loads(out)
     return out['contracts']
コード例 #4
0
 def _get_sig_to_func_by_contract(cls):
     if cls.allow_paths:
         cmd = 'lityc --disable-oyente --combined-json hashes %s %s --allow-paths %s' % (
             cls.remap, cls.parent_filename, cls.allow_paths)
     else:
         cmd = 'lityc --disable-oyente --combined-json hashes %s %s' % (
             cls.remap, cls.parent_filename)
     out = run_command(cmd)
     out = json.loads(out)
     return out['contracts']
コード例 #5
0
    def _compile_solidity(self):
        if not self.allow_paths:
            cmd = "lityc --disable-oyente --bin-runtime %s %s" % (self.remap,
                                                                  self.source)
        else:
            cmd = "lityc --disable-oyente --bin-runtime %s %s --allow-paths %s" % (
                self.remap, self.source, self.allow_paths)
        err = ''
        if self.compilation_err:
            out, err = run_command_with_err(cmd)
            err = re.sub(self.root_path, "", err)
        else:
            out = run_command(cmd)

        libs = re.findall(r"_+(.*?)_+", out)
        libs = set(libs)
        if libs:
            return self._link_libraries(self.source, libs)
        else:
            return self._extract_bin_str(out, err)