AlienVault-OTX / OTX-Python-SDK

The Python SDK for AlienVault OTX
Other
358 stars 162 forks source link

Unicode decode error in OTXv2.py when calling "getall()" #6

Closed Neo23x0 closed 9 years ago

Neo23x0 commented 9 years ago

With the new version of OTX-Python-SDK I get an error when calling getall(), which has not been there with the older version of the SDK.

It can be reproduced with my get-otx-iocs.py script and the right subscriptions. https://github.com/Neo23x0/Loki/blob/master/threatintel/get-otx-iocs.py

As it happens in line 53 of OTXv2.py when decoding the whole response, it is diffucult to determin which pulse has the UNICODE characters that cannot be decoded.

prometheus:threatintel neo$ python get-otx-iocs_flo.py
Starting OTX feed download ...
Traceback (most recent call last):
  File "get-otx-iocs_flo.py", line 142, in <module>
    otx_receiver.get_iocs_last()
  File "get-otx-iocs_flo.py", line 50, in get_iocs_last
    self.events = self.otx.getall()
  File "/Library/Python/2.7/site-packages/OTXv2.py", line 62, in getall
    json_data = self.get(next)
  File "/Library/Python/2.7/site-packages/OTXv2.py", line 53, in get
    data = response.read().decode()
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 128233: ordinal not in range(128)
jaimeblasco commented 9 years ago

@Neo23x0 https://github.com/AlienVault-Labs/OTX-Python-SDK/commit/802503ac581ebb2edb61d7127b7acc17f96f395c Should fix it. Can you try now?

Neo23x0 commented 9 years ago

Yes - that fixed it. Thanks for the quick response.