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

Autofocus analyzer v1 #473

Merged
merged 1 commit into from
Jan 14, 2020
Merged

Autofocus analyzer v1 #473

merged 1 commit into from
Jan 14, 2020

Conversation

amr-cossi
Copy link
Contributor

@amr-cossi amr-cossi commented Apr 24, 2019

#472

  • Add docs to analyzer requirements in CortexDocs repo

@jeromeleonard jeromeleonard self-requested a review October 1, 2019 06:29
@jeromeleonard jeromeleonard added the scope:analyzer Issue is analyzer related label Oct 1, 2019
@jeromeleonard jeromeleonard modified the milestones: 2.2.0, 2.3.0 Oct 1, 2019
@jeromeleonard jeromeleonard modified the milestones: 2.3.0, 2.4.0 Nov 28, 2019
@nadouani nadouani added category:new-analyzer New analyzer submitted status:needs-docs and removed scope:analyzer Issue is analyzer related labels Jan 9, 2020
@nadouani
Copy link
Contributor

nadouani commented Jan 9, 2020

Hello @amr-cossi Thanks for the PR, we are reviewing it.

Is it possible to add a PR for https://github.com/TheHive-Project/CortexDocs/blob/master/analyzer_requirements.md

@amr-cossi
Copy link
Contributor Author

Yes I'll do it.

@nadouani nadouani merged commit d470a4f into TheHive-Project:develop Jan 14, 2020
nadouani added a commit that referenced this pull request Jan 14, 2020
@jeromeleonard
Copy link
Contributor

Hello @amr-cossi,

Do you have any idea about this issue pls (#612 (comment)) ?

Made some tests with the lib on my side (without valid api key). I received the same error message (ClientError(...), 'API key is not set. Library requires AutoFocusAPI.api_key to be set, or apikeyto be provided via configuration file.')

>>> from autofocus import AFSample, AFConnectionActivity, AFUserAgentFragment, AFRelatedMacro, AutoFocusAPI
>>> AutoFocusAPI.api_key='blah'
>>> AFSample.get("8404e06ff383275462298e830bebe9540fab2092eca5523649d74e6e596ac23d")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jerome/Devel/venv/Cortex-Analyzers3/lib/python3.7/site-packages/autofocus/models/sample.py", line 237, in get
    return SampleFactory().get(*args, **kwargs)
  File "/Users/jerome/Devel/venv/Cortex-Analyzers3/lib/python3.7/site-packages/autofocus/factories/sample.py", line 403, in get
    for sample in self.search(query, attributes=attributes):
  File "/Users/jerome/Devel/venv/Cortex-Analyzers3/lib/python3.7/site-packages/autofocus/factories/sample.py", line 190, in _not_coro
    for res in self._api_search("/samples/search", query, scope, sort_by, sort_order, fields, limit):
  File "/Users/jerome/Devel/venv/Cortex-Analyzers3/lib/python3.7/site-packages/autofocus/factories/base.py", line 735, in _not_coro
    for res in req_class(path, post_data=post_data, async_req=async_req).run():
  File "/Users/jerome/Devel/venv/Cortex-Analyzers3/lib/python3.7/site-packages/autofocus/factories/base.py", line 521, in __init__
    super().__init__(*args, **kwargs)
  File "/Users/jerome/Devel/venv/Cortex-Analyzers3/lib/python3.7/site-packages/autofocus/factories/base.py", line 217, in __init__
    raise ClientError("API key is not set. Library requires AutoFocusAPI.api_key to be set, or apikey"
autofocus.exceptions.ClientError: (ClientError(...), 'API key is not set. Library requires AutoFocusAPI.api_key to be set, or apikeyto be provided via configuration file.')

Sounds like the value of the key is never read by the library.

@amr-cossi
Copy link
Contributor Author

amr-cossi commented Feb 12, 2020

Hi,
Love breaking changes without documentation in libraries.
I confirm that it was working in v3.0.1 and it is broken since they have changed the way config in handled.
We can open an issue on the Github of the library but in the meantime, I have a quick workaround :

import os
os.environ["AUTOFOCUS_APIKEY"] = "blah"
from autofocus import AFSample, AFConnectionActivity, AFUserAgentFragment, AFRelatedMacro, AutoFocusAPI
AFSample.get("9040e9fda52931c9472c90ecad5b74295cdb9cf7b68e2b89219700f6a8bff5ac")

The environment variable has to be set before the import.

@jeromeleonard
Copy link
Contributor

thanks for your quick reply. ok :( It looks tricky to pass the configuration of the analyzer from Cortex to the program in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:new-analyzer New analyzer submitted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants