Skip to content

Commit

Permalink
Fixes error when there are no reports returned
Browse files Browse the repository at this point in the history
Fixes

```
intel_client.py", line 62, in get_reports
    reports.extend(resp_json.get('resources', []))
TypeError: 'NoneType' object is not iterable
```
  • Loading branch information
cudeso authored and jshcodes committed Dec 16, 2022
1 parent e3b99ba commit 4283ad5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cs_misp_import/intel_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ def get_reports(self, start_time):
offset += resp_json.get('meta', {}).get('pagination', {}).get('limit', 5000)
first_run = False

reports.extend(resp_json.get('resources', []))
resources = resp_json.get('resources', [])
if resources is not None and len(resources) > 0:
reports.extend(resp_json.get('resources', []))

return reports

Expand Down Expand Up @@ -149,4 +151,4 @@ def get_actor_name_list(self):
def __check_metadata(resp_json):
if (resp_json.get('meta', {}).get('pagination', {}).get('total') is None) \
or (resp_json.get('meta', {}).get('pagination', {}).get('limit') is None):
raise Exception(f'Unable to decode pagination metadata from response. Response is {resp_json}.')
raise Exception(f'Unable to decode pagination metadata from response. Response is {resp_json}.')

0 comments on commit 4283ad5

Please sign in to comment.