orf / xcat

XPath injection tool
https://xcat.readthedocs.org/
MIT License
367 stars 74 forks source link

Python3.4 fails to serialize socket on deepcopy #14

Closed dwendt closed 7 years ago

dwendt commented 8 years ago

Hey,

https://github.com/orf/xcat/blob/1e568d36bb9540069601459abaaa95a6cdcfce08/xcat/lib/requests/detector.py#L28

This does a deepcopy on RequestMaker, however RequestMaker has a handle to a socket somewhere. It fails like so:

  File "/usr/local/lib/python3.4/dist-packages/xcat-0.7.1-py3.4.egg/xcat/xcat.py", line 343, in test_injection
  File "/usr/local/lib/python3.4/dist-packages/xcat-0.7.1-py3.4.egg/xcat/lib/requests/detector.py", line 28, in change_parameter
  File "/usr/lib/python3.4/copy.py", line 182, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File "/usr/lib/python3.4/copy.py", line 300, in _reconstruct
    state = deepcopy(state, memo)
  File "/usr/lib/python3.4/copy.py", line 155, in deepcopy
    y = copier(x, memo)
  File "/usr/lib/python3.4/copy.py", line 246, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/lib/python3.4/copy.py", line 182, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File "/usr/lib/python3.4/copy.py", line 300, in _reconstruct
    state = deepcopy(state, memo)
  File "/usr/lib/python3.4/copy.py", line 155, in deepcopy
    y = copier(x, memo)
  File "/usr/lib/python3.4/copy.py", line 246, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/lib/python3.4/copy.py", line 182, in deepcopy
    y = _reconstruct(x, rv, 1, memo)
  File "/usr/lib/python3.4/copy.py", line 300, in _reconstruct
    state = deepcopy(state, memo)
  File "/usr/lib/python3.4/copy.py", line 155, in deepcopy
    y = copier(x, memo)
  File "/usr/lib/python3.4/copy.py", line 246, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/usr/lib/python3.4/copy.py", line 174, in deepcopy
    rv = reductor(2)
  File "/usr/lib/python3.4/socket.py", line 167, in __getstate__
    raise TypeError("Cannot serialize socket object")
TypeError: Cannot serialize socket object

I'm thinking it's the asyncio.Semaphore instance the object has, but I can't figure out how that could be replaced. Any thoughts?

orf commented 8 years ago

Urgh that whole part is a mess to be honest, and pretty hacky. It will be a socket open somewhere in the RequestMaker, I've made some changes to that recently which might be causing it. I've got some time scheduled to work on this, so I'll take a look (but more likely just chuck that whole part out).

I'm away from my computer for a few days so I can't test, but could you try the cli-redesign branch? It's a partial rewrite, it might not be affected by this.

orf commented 7 years ago

Closing for #16