Merge pull request #219 from crytic/dev-fix-linecolumncalculations

Fix for regression in line/column number calculations
pull/222/head
Feist Josselin 6 years ago committed by GitHub
commit 02ce42a280
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      slither/core/slither_core.py
  2. 3
      slither/slither.py
  3. 12
      slither/solc_parsing/slitherSolc.py

@ -56,6 +56,14 @@ class Slither(Context):
"""str: Filename."""
return self._filename
def _add_source_code(self, path):
"""
:param path:
:return:
"""
with open(path, encoding='utf8', newline='') as f:
self.source_code[path] = f.read()
# endregion
###################################################################################
###################################################################################

@ -65,8 +65,7 @@ class Slither(SlitherSolc):
for path, ast in cryticCompile.asts.items():
self._parse_contracts_from_loaded_json(ast, path)
with open(path) as f:
self.source_code[path] = f.read()
self._add_source_code(path)
self._detectors = []
self._printers = []

@ -89,9 +89,7 @@ class SlitherSolc(Slither):
if 'sourcePaths' in data_loaded:
for sourcePath in data_loaded['sourcePaths']:
if os.path.isfile(sourcePath):
with open(sourcePath, encoding='utf8', newline='') as f:
source_code = f.read()
self.source_code[sourcePath] = source_code
self._add_source_code(sourcePath)
if data_loaded[self.get_key()] == 'root':
self._solc_version = '0.3'
@ -152,15 +150,11 @@ class SlitherSolc(Slither):
self._source_units[sourceUnit] = name
if os.path.isfile(name) and not name in self.source_code:
with open(name, encoding='utf8', newline='') as f:
source_code = f.read()
self.source_code[name] = source_code
self._add_source_code(name)
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', newline='') as f:
source_code = f.read()
self.source_code[name] = source_code
self._add_source_code(lib_name)
# endregion
###################################################################################

Loading…
Cancel
Save