Consensys / pythx

A Python library for the MythX smart contract security analysis platform
MIT License
33 stars 12 forks source link

A lot of commands crash because `client_tool_name` is not specified. #43

Closed cleanunicorn closed 5 years ago

cleanunicorn commented 5 years ago

Description

A lot of commands fail with: TypeError: __init__() got an unexpected keyword argument 'client_tool_name'.

Login worked but when I tried to check the list of analyses or a specific analysis, I get the error.

What I Did

$ pythx ps
Traceback (most recent call last):
  File "/home/daniel/.local/bin/pythx", line 10, in <module>
    sys.exit(cli())
  File "/home/daniel/.local/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/daniel/.local/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/daniel/.local/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/daniel/.local/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/daniel/.local/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/daniel/.local/lib/python3.7/site-packages/pythx/cli/main.py", line 143, in ps
    resp = utils.ps_core(config, staging, number)
  File "/home/daniel/.local/lib/python3.7/site-packages/pythx/cli/utils.py", line 138, in ps_core
    resp = c.analysis_list()
  File "/home/daniel/.local/lib/python3.7/site-packages/pythx/api/client.py", line 191, in analysis_list
    return self._assemble_send_parse(req, respmodels.AnalysisListResponse)
  File "/home/daniel/.local/lib/python3.7/site-packages/pythx/api/client.py", line 89, in _assemble_send_parse
    return self.handler.parse_response(resp, resp_model)
  File "/home/daniel/.local/lib/python3.7/site-packages/pythx/api/handler.py", line 164, in parse_response
    m = model.from_json(resp)
  File "/home/daniel/.local/lib/python3.7/site-packages/pythx/models/response/base.py", line 54, in from_json
    return cls.from_dict(parsed)
  File "/home/daniel/.local/lib/python3.7/site-packages/pythx/models/response/analysis_list.py", line 45, in from_dict
    analyses = [Analysis.from_dict(a) for a in d["analyses"]]
  File "/home/daniel/.local/lib/python3.7/site-packages/pythx/models/response/analysis_list.py", line 45, in <listcomp>
    analyses = [Analysis.from_dict(a) for a in d["analyses"]]
  File "/home/daniel/.local/lib/python3.7/site-packages/pythx/models/response/analysis.py", line 64, in from_dict
    return cls(**d)
TypeError: __init__() got an unexpected keyword argument 'client_tool_name'
s0b0lev commented 5 years ago

@cleanunicorn this issue relates to PR: https://github.com/dmuhs/pythx/pull/31

muellerberndt commented 5 years ago

Same here with the example from the README:

$ python wachhund.py 
Traceback (most recent call last):
  File "wachhund.py", line 8, in <module>
    resp = c.analyze(bytecode="0xfe")
  File "/Users/bernhardmueller/.pyenv/versions/pythx/lib/python3.6/site-packages/pythx/api/client.py", line 235, in analyze
    return self._assemble_send_parse(req, respmodels.AnalysisSubmissionResponse)
  File "/Users/bernhardmueller/.pyenv/versions/pythx/lib/python3.6/site-packages/pythx/api/client.py", line 89, in _assemble_send_parse
    return self.handler.parse_response(resp, resp_model)
  File "/Users/bernhardmueller/.pyenv/versions/pythx/lib/python3.6/site-packages/pythx/api/handler.py", line 164, in parse_response
    m = model.from_json(resp)
  File "/Users/bernhardmueller/.pyenv/versions/pythx/lib/python3.6/site-packages/pythx/models/response/base.py", line 54, in from_json
    return cls.from_dict(parsed)
  File "/Users/bernhardmueller/.pyenv/versions/pythx/lib/python3.6/site-packages/pythx/models/response/analysis_submission.py", line 28, in from_dict
    return cls(analysis=Analysis.from_dict(d))
  File "/Users/bernhardmueller/.pyenv/versions/pythx/lib/python3.6/site-packages/pythx/models/response/analysis.py", line 64, in from_dict
    return cls(**d)
TypeError: __init__() got an unexpected keyword argument 'client_tool_name'
(pythx) cerebral-cortex:mythx-wachhund bernhardmueller$ python wachhund.py 
Traceback (most recent call last):
  File "wachhund.py", line 8, in <module>
    resp = c.analyze(bytecode="0xfe")
  File "/Users/bernhardmueller/.pyenv/versions/pythx/lib/python3.6/site-packages/pythx/api/client.py", line 235, in analyze
    return self._assemble_send_parse(req, respmodels.AnalysisSubmissionResponse)
  File "/Users/bernhardmueller/.pyenv/versions/pythx/lib/python3.6/site-packages/pythx/api/client.py", line 89, in _assemble_send_parse
    return self.handler.parse_response(resp, resp_model)
  File "/Users/bernhardmueller/.pyenv/versions/pythx/lib/python3.6/site-packages/pythx/api/handler.py", line 164, in parse_response
    m = model.from_json(resp)
  File "/Users/bernhardmueller/.pyenv/versions/pythx/lib/python3.6/site-packages/pythx/models/response/base.py", line 54, in from_json
    return cls.from_dict(parsed)
  File "/Users/bernhardmueller/.pyenv/versions/pythx/lib/python3.6/site-packages/pythx/models/response/analysis_submission.py", line 28, in from_dict
    return cls(analysis=Analysis.from_dict(d))
  File "/Users/bernhardmueller/.pyenv/versions/pythx/lib/python3.6/site-packages/pythx/models/response/analysis.py", line 64, in from_dict
    return cls(**d)
TypeError: __init__() got an unexpected keyword argument 'client_tool_name'
dmuhs commented 5 years ago

These faults were connected to a newly added API field in the status response - denoting the client tool ID the request was sent with. This was not supported by the internal PythX domain models so far, which is why the parsing routines errored out. PR #31 aimed to fix it, but first related only to staging. After the move to production I have merged this now.

You guys caught me in a transition period :stuck_out_tongue: If you install version 1.1.8 now, all should work fine.