mirror of https://github.com/MISP/misp-modules
fix: Making pep8 happy
parent
fc54785d6b
commit
c9c6f69bd4
|
@ -1,37 +1,35 @@
|
||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
try:
|
try:
|
||||||
from google import google
|
from google import google
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("GoogleAPI not installed. Command : pip install git+https://github.com/abenassi/Google-Search-API")
|
print("GoogleAPI not installed. Command : pip install git+https://github.com/abenassi/Google-Search-API")
|
||||||
|
|
||||||
misperrors = {'error': 'Error'}
|
misperrors = {'error': 'Error'}
|
||||||
mispattributes = {'input': ['url'], 'output': ['text']}
|
mispattributes = {'input': ['url'], 'output': ['text']}
|
||||||
moduleinfo = {'author': 'Oun & Gindt', 'description': 'An expansion hover module to expand google search information about an URL', 'module-type': ['hover']}
|
moduleinfo = {'author': 'Oun & Gindt', 'module-type': ['hover'],
|
||||||
|
'description': 'An expansion hover module to expand google search information about an URL'}
|
||||||
|
|
||||||
|
|
||||||
def handler(q=False):
|
def handler(q=False):
|
||||||
if q is False:
|
if q is False:
|
||||||
return False
|
return False
|
||||||
request = json.loads(q)
|
request = json.loads(q)
|
||||||
if request.get('url'):
|
if not request.get('url'):
|
||||||
toquery = request['url']
|
return {'error': "Unsupported attributes type"}
|
||||||
else:
|
num_page = 1
|
||||||
misperrors['error'] = "Unsupported attributes type"
|
res = ""
|
||||||
return misperrors
|
search_results = google.search(request['url'], num_page)
|
||||||
|
for i in range(3):
|
||||||
|
res += "("+str(i+1)+")" + '\t'
|
||||||
|
res += json.dumps(search_results[i].description, ensure_ascii=False)
|
||||||
|
res += '\n\n'
|
||||||
|
return {'results': [{'types': mispattributes['output'], 'values':res}]}
|
||||||
|
|
||||||
num_page = 1
|
|
||||||
res = ""
|
|
||||||
search_results = google.search(request['url'], num_page)
|
|
||||||
for i in range(3):
|
|
||||||
res += "("+str(i+1)+")" + '\t'
|
|
||||||
res += json.dumps(search_results[i].description, ensure_ascii=False)
|
|
||||||
res += '\n\n'
|
|
||||||
return {'results': [{'types': mispattributes['output'], 'values':res}]}
|
|
||||||
|
|
||||||
def introspection():
|
def introspection():
|
||||||
return mispattributes
|
return mispattributes
|
||||||
|
|
||||||
|
|
||||||
def version():
|
def version():
|
||||||
return moduleinfo
|
return moduleinfo
|
||||||
|
|
Loading…
Reference in New Issue