diff --git a/setup.py b/setup.py index 9b4902e727..9308b43a74 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ description='Slither is a Solidity static analysis framework written in Python 3.', url='https://github.com/trailofbits/slither', author='Trail of Bits', - version='0.6.0', + version='0.6.1', packages=find_packages(), python_requires='>=3.6', install_requires=['prettytable>=0.7.2', 'pysha3>=1.0.2'], diff --git a/slither/__main__.py b/slither/__main__.py index 1b79d54c08..6213eedc42 100644 --- a/slither/__main__.py +++ b/slither/__main__.py @@ -450,6 +450,11 @@ def parse_args(detector_classes, printer_classes): action='store_true', default=defaults_flag_in_config['legacy_ast']) + parser.add_argument('--ignore-return-value', + help=argparse.SUPPRESS, + action='store_true', + default=False) + # if the json is splitted in different files parser.add_argument('--splitted', help=argparse.SUPPRESS, @@ -591,6 +596,8 @@ def main_impl(all_detector_classes, all_printer_classes): logger.info('%s analyzed (%d contracts)', filename, number_contracts) else: logger.info('%s analyzed (%d contracts), %d result(s) found', filename, number_contracts, len(results)) + if args.ignore_return_value: + return exit(results) except Exception: diff --git a/slither/core/source_mapping/source_mapping.py b/slither/core/source_mapping/source_mapping.py index 2a0ffa6a65..c4df7ff249 100644 --- a/slither/core/source_mapping/source_mapping.py +++ b/slither/core/source_mapping/source_mapping.py @@ -19,12 +19,12 @@ def _compute_line(source_code, start, length): Not done in an efficient way """ total_length = len(source_code) - source_code = source_code.split('\n') + source_code = source_code.splitlines(True) counter = 0 i = 0 lines = [] while counter < total_length: - counter += len(source_code[i]) +1 + counter += len(source_code[i]) i = i+1 if counter > start: lines.append(i) diff --git a/slither/solc_parsing/slitherSolc.py b/slither/solc_parsing/slitherSolc.py index c2bffdd4c2..5fa3c160e3 100644 --- a/slither/solc_parsing/slitherSolc.py +++ b/slither/solc_parsing/slitherSolc.py @@ -89,7 +89,7 @@ def _parse_contracts_from_loaded_json(self, data_loaded, filename): if 'sourcePaths' in data_loaded: for sourcePath in data_loaded['sourcePaths']: if os.path.isfile(sourcePath): - with open(sourcePath, encoding='utf8') as f: + with open(sourcePath, encoding='utf8', newline='') as f: source_code = f.read() self.source_code[sourcePath] = source_code @@ -152,13 +152,13 @@ def _parse_source_unit(self, data, filename): self._source_units[sourceUnit] = name if os.path.isfile(name) and not name in self.source_code: - with open(name, encoding='utf8') as f: + with open(name, encoding='utf8', newline='') as f: source_code = f.read() self.source_code[name] = source_code else: lib_name = os.path.join('node_modules', name) if os.path.isfile(lib_name) and not name in self.source_code: - with open(lib_name, encoding='utf8') as f: + with open(lib_name, encoding='utf8', newline='') as f: source_code = f.read() self.source_code[name] = source_code