Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError NoneType exception from run_by_name if no analyzers are installed #23

Closed
michaelweiser opened this issue Oct 20, 2020 · 1 comment
Assignees
Labels
Milestone

Comments

@michaelweiser
Copy link

In a testing environment I have a Cortex in a Docker container that is still missing analysers. So the list of analysers returned by the API is empty. This causes the following exception when calling cortex4py.analyzers.run_by_name() with any name:

'NoneType' object has no attribute 'id'
Traceback (most recent call last):
  File "/home/m/PeekabooAV-Installer/PeekabooAV/peekaboo/ruleset/engine.py", line 193, in run
    result = rule.evaluate(sample)
  File "/home/m/PeekabooAV-Installer/PeekabooAV/peekaboo/ruleset/rules.py", line 754, in evaluate
    self.submit_to_cortex(sample, cortex_analyzer)
  File "/home/m/PeekabooAV-Installer/PeekabooAV/peekaboo/ruleset/rules.py", line 226, in submit_to_cortex
    job_id = self.cortex.submit(sample, analyzer)
  File "/home/m/PeekabooAV-Installer/PeekabooAV/peekaboo/toolbox/cortex.py", line 543, in submit
    job = self.api.analyzers.run_by_name(analyzer.name, params)
  File "/home/m/pd/lib/python3.8/site-packages/cortex4py/controllers/analyzers.py", line 89, in run_by_name
    return self.run_by_id(analyzer.id, observable, **kwargs)
AttributeError: 'NoneType' object has no attribute 'id'

I can handle the NoneType exception in my code but wanted to report the issue here in case you think it should rather be wrapped into a module-specific exception such as cortex4py.exceptions.NotFoundError or cortex4py.analyzers.run_by_name() signal error by e.g. returning None.

@nadouani nadouani self-assigned this Jun 23, 2021
@nadouani nadouani added the bug label Jun 23, 2021
@nadouani
Copy link
Contributor

I'll fix this using an extract from what has been committed in #22. thanks @michaelweiser

@nadouani nadouani added this to the 2.1.0 milestone Jun 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants