mirror of https://github.com/MISP/misp-modules
chg: Taking into consideration if a user agent is specified in the module configuration
parent
6d19549184
commit
8aca19ba68
|
@ -4,7 +4,7 @@ import json
|
||||||
misperrors = {'error': 'Error'}
|
misperrors = {'error': 'Error'}
|
||||||
mispattributes = {'input': ['mac-address'], 'output': ['text']}
|
mispattributes = {'input': ['mac-address'], 'output': ['text']}
|
||||||
moduleinfo = {'version': '0.1', 'author': 'Aurélien Schwab', 'description': 'Module to access Macvendors API.', 'module-type': ['hover']}
|
moduleinfo = {'version': '0.1', 'author': 'Aurélien Schwab', 'description': 'Module to access Macvendors API.', 'module-type': ['hover']}
|
||||||
moduleconfig = ['user-agent'] # TODO take this into account in the code
|
moduleconfig = ['user-agent']
|
||||||
|
|
||||||
macvendors_api_url = 'https://api.macvendors.com/'
|
macvendors_api_url = 'https://api.macvendors.com/'
|
||||||
default_user_agent = 'MISP-Module'
|
default_user_agent = 'MISP-Module'
|
||||||
|
@ -21,7 +21,8 @@ def handler(q=False):
|
||||||
else:
|
else:
|
||||||
misperrors['error'] = "Unsupported attributes type"
|
misperrors['error'] = "Unsupported attributes type"
|
||||||
return misperrors
|
return misperrors
|
||||||
r = requests.get(macvendors_api_url + mac, headers={'user-agent': default_user_agent}) # Real request
|
user_agent = request['config']['user-agent'] if request.get('config') and request['config'].get('user-agent') else default_user_agent
|
||||||
|
r = requests.get(macvendors_api_url + mac, headers={'user-agent': user_agent}) # Real request
|
||||||
if r.status_code == 200: # OK (record found)
|
if r.status_code == 200: # OK (record found)
|
||||||
response = r.text
|
response = r.text
|
||||||
if response:
|
if response:
|
||||||
|
|
Loading…
Reference in New Issue