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

GoogleSafebrowsing Analyzer Fails with AttributeErrors #92

Closed
denied39 opened this issue Sep 7, 2017 · 7 comments
Closed

GoogleSafebrowsing Analyzer Fails with AttributeErrors #92

denied39 opened this issue Sep 7, 2017 · 7 comments
Labels
category:invalid Issue is related to an invalid request

Comments

@denied39
Copy link

denied39 commented Sep 7, 2017

GoogleSafebrowsing Analyzer Fails with AttributeErrors

Request Type

Bug

Work Environment

Question Answer
OS version (server) Ubuntu 16.04.3
OS version (client) 10
Cortex Analyzer Name GoogleSafebrowsing
Cortex Analyzer Version 2.0
Cortex Version 1.1.3
Browser type & version Google Chrome

Description

After adding in the GoogleSafebrowsing API key, the analyzer fails with multiple AttributeErrors.
First failure:
Error: Invalid output Traceback (most recent call last): File "./safebrowsing_analyzer.py", line 61, in SafebrowsingAnalyzer().run() File "./safebrowsing_analyzer.py", line 12, in init self.api_key = self.get_param('config.key', None, 'No Google API key provided.') AttributeError: SafebrowsingAnalyzer instance has no attribute 'get_param'
(after fixing that)
Second failure:
Error: Invalid output Traceback (most recent call last): File "./safebrowsing_analyzer.py", line 61, in SafebrowsingAnalyzer().run() File "./safebrowsing_analyzer.py", line 51, in run result = self.sb.query_url(self.get_data()) AttributeError: SafebrowsingAnalyzer instance has no attribute 'get_data'

Steps to Reproduce

(keep this section only if the issue relates to a bug)

  1. Add API key to application.conf
  2. Restart Cortex
  3. Run GoogleSafebrowsing Analyzer against a URL

Possible Solutions

First Error:
Change get_param on lines 12-13 of safebrowsing_analyzer.py to getParam

Second Error:
Change get_data on line 51 of safebrowsing_analyzer.py to getData

Complementary information

After making the above changes, the analyzer now runs without error.

@3c7
Copy link
Contributor

3c7 commented Sep 7, 2017

Have you updated cortexutils? Because https://github.com/CERT-BDF/Cortex-Analyzers/blob/master/contrib/cortexutils/analyzer.py definitely implements get_param.

(Edit: and get_data, of course)

@nadouani nadouani added the category:invalid Issue is related to an invalid request label Sep 7, 2017
@nadouani
Copy link
Contributor

nadouani commented Sep 7, 2017

Yes this looks like an outdated version of cortexutils library.

@nadouani nadouani closed this as completed Sep 7, 2017
@denied39
Copy link
Author

denied39 commented Sep 7, 2017

Maybe I'm doing something wrong, but after I updated the cortexutils, and changed the safebrowsing_analyzer.py back to get_param and get_data, it's still failing with AttributeErrors.
image
image

I checked /opt/Cortex-A/contrib/cortexutils/analyzer.py (I downloaded the analyzers again, just in case) and I see the get_param implementation. Not sure what to try now.

@nadouani nadouani reopened this Sep 7, 2017
@nadouani
Copy link
Contributor

nadouani commented Sep 7, 2017

@denied39 can you please try the following steps:

  • open the python interpreter
  • type from cortexutils.analyzer import Analyzer
  • type help(Analyzer)
  • check that get_param method exists

@3c7
Copy link
Contributor

3c7 commented Sep 7, 2017

Another error source might be a different python installation/version. Something like, you installed cortexutils for python3 but use python2 for executing the analyzers. That can happen if the pip command is linked to python3 -mpip but python executes the python 2.7 interpreter.

@denied39
Copy link
Author

denied39 commented Sep 7, 2017

@nadouani the get_param does not exist (running on python v2.7.12)
@3c7 if I run python3 and then try the same commands, I do get the get_param method.

I ran pip2 to upgrade the cortexutils, and now it runs without error. I think this issue can be closed now. Thanks for everyone's help.

@nadouani
Copy link
Contributor

nadouani commented Sep 7, 2017

Cool, thanks to @3c7 too

@nadouani nadouani closed this as completed Sep 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:invalid Issue is related to an invalid request
Projects
None yet
Development

No branches or pull requests

3 participants