Add support to solc json file where the non-json text was removed (fix #153)

pull/169/head
Josselin 6 years ago
parent c2ff6585db
commit 64343da44a
  1. 10
      slither/solc_parsing/slitherSolc.py

@ -41,8 +41,18 @@ class SlitherSolc(Slither):
def _parse_contracts_from_json(self, json_data):
try:
data_loaded = json.loads(json_data)
# Truffle AST
if 'ast' in data_loaded:
self._parse_contracts_from_loaded_json(data_loaded['ast'], data_loaded['sourcePath'])
return True
# solc AST, where the non-json text was removed
else:
if 'attributes' in data_loaded:
filename = data_loaded['attributes']['absolutePath']
else:
filename = data_loaded['absolutePath']
self._parse_contracts_from_loaded_json(data_loaded, filename)
return True
except ValueError:
first = json_data.find('{')

Loading…
Cancel
Save