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. 14
      slither/solc_parsing/slitherSolc.py

@ -41,8 +41,18 @@ class SlitherSolc(Slither):
def _parse_contracts_from_json(self, json_data): def _parse_contracts_from_json(self, json_data):
try: try:
data_loaded = json.loads(json_data) data_loaded = json.loads(json_data)
self._parse_contracts_from_loaded_json(data_loaded['ast'], data_loaded['sourcePath']) # Truffle AST
return True 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: except ValueError:
first = json_data.find('{') first = json_data.find('{')

Loading…
Cancel
Save