mirror of https://github.com/MISP/misp-modules
fix: Fixed pep8 + some copy paste issues introduced with the latest commits
parent
3ab67b23b6
commit
d2661c7a20
|
@ -26,5 +26,6 @@ minimum_required_fields = ('type', 'uuid', 'value')
|
|||
checking_error = 'containing at least a "type" field and a "value" field'
|
||||
standard_error_message = 'This module requires an "attribute" field as input'
|
||||
|
||||
|
||||
def check_input_attribute(attribute, requirements=minimum_required_fields):
|
||||
return all(feature in attribute for feature in requirements)
|
||||
|
|
|
@ -111,6 +111,7 @@ def handler(q=False):
|
|||
request = json.loads(q)
|
||||
if not request.get('attribute') or not check_input_attribute(request['attribute']):
|
||||
return {'error': f'{standard_error_message}, which should contain at least a type, a value and an uuid.'}
|
||||
attribute = request['attribute']
|
||||
if attribute.get('type') != 'vulnerability':
|
||||
misperrors['error'] = 'Vulnerability id missing.'
|
||||
return misperrors
|
||||
|
|
|
@ -149,6 +149,7 @@ def handler(q=False):
|
|||
|
||||
if not request.get('attribute') or not check_input_attribute(request['attribute']):
|
||||
return {'error': f'{standard_error_message}, which should contain at least a type, a value and an uuid.'}
|
||||
attribute = request['attribute']
|
||||
if not any(input_type == attribute['type'] for input_type in mispattributes['input']):
|
||||
return {'error': 'Unsupported attribute type.'}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ def handler(q=False):
|
|||
q = json.loads(q)
|
||||
if "config" not in q or "api-key" not in q["config"]:
|
||||
return {"error": "Ransomcoindb API key is missing"}
|
||||
if not q.get('attribute') or not check_input_attribute(attribute, requirements=('type', 'value')):
|
||||
if not q.get('attribute') or not check_input_attribute(q['attribute'], requirements=('type', 'value')):
|
||||
return {'error': f'{standard_error_message}, {checking_error}.'}
|
||||
if q['attribute']['type'] not in mispattributes['input']:
|
||||
return {'error': 'Unsupported attribute type.'}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
from. import check_input_attribute, checking_error, standard_error_message
|
||||
from pymisp import MISPEvent, MISPObject
|
||||
import json
|
||||
import requests
|
||||
import base64
|
||||
from. import check_input_attribute, checking_error, standard_error_message
|
||||
from pymisp import MISPEvent, MISPObject
|
||||
from urllib.parse import quote
|
||||
|
||||
moduleinfo = {'version': '1.0',
|
||||
|
@ -107,9 +107,9 @@ def handler(q=False):
|
|||
It's free to sign up here https://aws.amazon.com/marketplace/pp/B07SLZPMCS."
|
||||
return misperrors
|
||||
to_check = (('type', 'value'), ('type', 'value1'))
|
||||
if not request.get('attribute') or not any(check_input_attribute(request['attribute'], requirements=check) for check in to_check):
|
||||
if not j.get('attribute') or not any(check_input_attribute(j['attribute'], requirements=check) for check in to_check):
|
||||
return {'error': f'{standard_error_message}, {checking_error}.'}
|
||||
attribute = request['attribute']
|
||||
attribute = j['attribute']
|
||||
if attribute['type'] not in misp_types_in:
|
||||
return {'error': 'Unsupported attribute type.'}
|
||||
client = SophosLabsApi(j['config']['client_id'], j['config']['client_secret'])
|
||||
|
|
Loading…
Reference in New Issue