MISP / MISP/misp-modules

XForceExchange: Not handling errors

Open
#376 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
377
Forks
280
Avg merge
2d 2h
Merged PRs (30d)
10

Description

Original Report: https://gitter.im/MISP/Support?at=5e5acf064eefc06dcf27f477

 2020-02-28 14:33:38,855 - misp-modules - ERROR - Something went wrong:
 Traceback (most recent call last):
   File "/usr/local/lib/python3.7/site-packages/misp_modules/__init__.py", line 201, in post
     response = yield tornado.gen.with_timeout(timeout, self.run_request(jsonpayload))
   File "/usr/local/lib/python3.7/site-packages/tornado/gen.py", line 735, in run
     value = future.result()
   File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
     result = self.fn(*self.args, **self.kwargs)
   File "/usr/local/lib/python3.7/site-packages/misp_modules/__init__.py", line 189, in run_request
     response = mhandlers[x['module']].handler(q=jsonpayload)
   File "modules/expansion/xforceexchange.py", line 164, in handler
     parser.parse()
   File "modules/expansion/xforceexchange.py", line 43, in parse
     getattr(self, to_call)(self.attribute.value)
   File "modules/expansion/xforceexchange.py", line 125, in _parse_ip
     self._parse_dns(value)
   File "modules/expansion/xforceexchange.py", line 108, in _parse_dns
     if dns_result.get('Passive') and dns_result['Passive'].get('records'):
 AttributeError: 'NoneType' object has no attribute 'get'

https://github.com/MISP/misp-modules/blob/master/misp_modules/modules/expansion/xforceexchange.py#L107-L108

_api_call can return NoneType either via exception, or non 200 HTTP code. This problem appears to be not handled in all calls to _api_call

I do not have an API key to even test this, so can't even begin to figure out the solution.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in misp_modules/modules/expansion/xforceexchange.py, especially _api_call and the _parse_dns traceback around lines 107-108. Review every shown call site for exception and non-200 responses, then verify that failed API responses no longer produce the reported NoneType AttributeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.