Consensys / mythx-cli

A command line interface for the MythX smart contract security analysis API
https://mythx-cli.readthedocs.io/
MIT License
84 stars 29 forks source link

Mythx decodedLocations Error #85

Closed Miller-kk closed 4 years ago

Miller-kk commented 4 years ago

Description

Below is the console in problem. When analyzing files through mythx-cli, it seems that the problem is that the json received through mythx is not properly decoded. Is it a mythx-cli problem or is it a problem with my local server?

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/mythx_models/base.py", line 85, in validate
    jsonschema.validate(candidate, cls.schema)
  File "/usr/local/lib/python3.6/dist-packages/jsonschema/validators.py", line 934, in validate
    raise error
jsonschema.exceptions.ValidationError: False is not of type 'object'

Failed validating 'type' in schema['items']['properties']['issues']['items']['properties']['decodedLocations']['items']['items']:
    {'properties': {'column': {'type': 'integer'},
                    'line': {'type': 'integer'}},
     'required': ['column', 'line'],
     'type': 'object'}

On instance[0]['issues'][0]['decodedLocations'][1][2]:
    False

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/mythx", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.6/dist-packages/mythx_cli/cli.py", line 73, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/click/decorators.py", line 27, in new_func
    return f(get_current_context().obj, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/mythx_cli/cli.py", line 508, in analyze
    resp: DetectedIssuesResponse = ctx["client"].report(uuid)
  File "/usr/local/lib/python3.6/dist-packages/pythx/api/client.py", line 318, in report
    return self._assemble_send_parse(req, respmodels.DetectedIssuesResponse)
  File "/usr/local/lib/python3.6/dist-packages/pythx/api/client.py", line 90, in _assemble_send_parse
    return self.handler.parse_response(resp, resp_model)
  File "/usr/local/lib/python3.6/dist-packages/pythx/api/handler.py", line 174, in parse_response
    m = model.from_json(resp)
  File "/usr/local/lib/python3.6/dist-packages/mythx_models/base.py", line 31, in from_json
    return cls.from_dict(parsed)
  File "/usr/local/lib/python3.6/dist-packages/mythx_models/response/detected_issues.py", line 111, in from_dict
    cls.validate(d)
  File "/usr/local/lib/python3.6/dist-packages/mythx_models/base.py", line 87, in validate
    raise ValidationError(e)
mythx_models.exceptions.ValidationError: False is not of type 'object'

Failed validating 'type' in schema['items']['properties']['issues']['items']['properties']['decodedLocations']['items']['items']:
    {'properties': {'column': {'type': 'integer'},
                    'line': {'type': 'integer'}},
     'required': ['column', 'line'],
     'type': 'object'}

On instance[0]['issues'][0]['decodedLocations'][1][2]:
    False

What I Did

mythx --api-key "keyValue"--format json analyze --solc-version 0.4.24 testset/itu.sol
dmuhs commented 4 years ago

This is a validation error in the MythX models library - a dependency of the CLI. Could you try to reinstall with pip install -U mythx-cli ? If your version didn't change, you might have to add the --force-reinstall flag. 🙂

Some background: mythx-models is a library that is concerned with parsing and serialising API requests and responses. Whenever there is a change in the API's format, validation errors can occur. I try to keep up with the changes and publish regular patch release ls for that library. These are picked up automatically with new PythX/CLI installs. Older versions might require an update.

dmuhs commented 4 years ago

Closing this due to inactivity