HurricaneLabs / machinae

Machinae Security Intelligence Collector
MIT License
504 stars 101 forks source link

Exception in the JSON output option #14

Closed Den1al closed 8 years ago

Den1al commented 8 years ago

There's an exception when trying to output via the JSON flag, Traceback (most recent call last): File "/usr/local/bin/machinae", line 9, in <module> load_entry_point('machinae==1.3.2', 'console_scripts', 'machinae')() File "/usr/local/lib/python3.5/dist-packages/machinae/cmd.py", line 183, in main cmd.run() File "/usr/local/lib/python3.5/dist-packages/machinae/cmd.py", line 167, in run output = outputs.MachinaeOutput.get_formatter(fmt).run(self.results) File "/usr/local/lib/python3.5/dist-packages/machinae/outputs.py", line 142, in run for record in super().run(result_sets): File "/usr/local/lib/python3.5/dist-packages/machinae/outputs.py", line 115, in run for result in item.resultset: AttributeError: 'ErrorResult' object has no attribute 'resultset'

I have managed to fix it by forcing a value check in line 115 in "/usr/local/lib/python3.5/dist-packages/machinae/outputs.py".

mcm commented 8 years ago

@Den1al thanks for the report. This should be fixed in 1.3.3, would you mind testing? It should output a JSON with error information now.

Den1al commented 8 years ago

Still not working. Traceback (most recent call last): File "/usr/local/bin/machinae", line 9, in <module> load_entry_point('machinae==1.3.3', 'console_scripts', 'machinae')() File "/usr/local/lib/python3.4/dist-packages/machinae/cmd.py", line 183, in main cmd.run() File "/usr/local/lib/python3.4/dist-packages/machinae/cmd.py", line 167, in run output = outputs.MachinaeOutput.get_formatter(fmt).run(self.results) File "/usr/local/lib/python3.4/dist-packages/machinae/outputs.py", line 139, in run self.print(json.dumps(record)) File "/usr/lib/python3.4/json/__init__.py", line 230, in dumps return _default_encoder.encode(obj) File "/usr/lib/python3.4/json/encoder.py", line 192, in encode chunks = self.iterencode(o, _one_shot=True) File "/usr/lib/python3.4/json/encoder.py", line 250, in iterencode return _iterencode(o, 0) File "/usr/lib/python3.4/json/encoder.py", line 173, in default raise TypeError(repr(o) + " is not JSON serializable") TypeError: HTTPError('503 Server Error: Service Temporarily Unavailable for url: https://www.spamhaus.org/query/domain/google.com',) is not JSON serializable

FYI, I am using now 1.3.3.

mcm commented 8 years ago

@Den1al sorry about that, I just fixed this, actually tested my fix, and uploaded 1.3.4. Please give the new version a shot and let me know if that fixes it.

mcm commented 8 years ago

@Den1al did the new version end up fixing this for you? My guess is a yes based on the thumbs up, I'm going to mark this closed but if you're still having issues we can reopen it.