fix: Making pep8 happy

pull/415/head
chrisr3d 2020-06-30 23:10:35 +02:00
parent de8d78cc70
commit 26b0357ac7
No known key found for this signature in database
GPG Key ID: 6BBED1B63A6D639F
3 changed files with 8 additions and 8 deletions

View File

@ -88,18 +88,18 @@ def handler(q=False):
else: else:
misperrors['error'] = "Unsupported attributes type" misperrors['error'] = "Unsupported attributes type"
return misperrors return misperrors
listed = [] listeds = []
info = [] infos = []
ipRev = '.'.join(ip.split('.')[::-1]) ipRev = '.'.join(ip.split('.')[::-1])
for rbl in rbls: for rbl in rbls:
query = '{}.{}'.format(ipRev, rbl) query = '{}.{}'.format(ipRev, rbl)
try: try:
txt = resolver.query(query, 'TXT') txt = resolver.query(query, 'TXT')
listed.append(query) listeds.append(query)
info.append([str(t) for t in txt]) infos.append([str(t) for t in txt])
except Exception: except Exception:
continue continue
result = "\n".join(["{}: {}".format(l, " - ".join(i)) for l, i in zip(listed, info)]) result = "\n".join([f"{listed}: {' - '.join(info)}" for listed, info in zip(listeds, infos)])
if not result: if not result:
return {'error': 'No data found by querying known RBLs'} return {'error': 'No data found by querying known RBLs'}
return {'results': [{'types': mispattributes.get('output'), 'values': result}]} return {'results': [{'types': mispattributes.get('output'), 'values': result}]}

View File

@ -244,11 +244,11 @@ def __any_mandatory_misp_field(header):
def __special_parsing(data, delimiter): def __special_parsing(data, delimiter):
return list(tuple(l.strip() for l in line[0].split(delimiter)) for line in csv.reader(io.TextIOWrapper(io.BytesIO(data.encode()), encoding='utf-8')) if line and not line[0].startswith('#')) return list(tuple(part.strip() for part in line[0].split(delimiter)) for line in csv.reader(io.TextIOWrapper(io.BytesIO(data.encode()), encoding='utf-8')) if line and not line[0].startswith('#'))
def __standard_parsing(data): def __standard_parsing(data):
return list(tuple(l.strip() for l in line) for line in csv.reader(io.TextIOWrapper(io.BytesIO(data.encode()), encoding='utf-8')) if line and not line[0].startswith('#')) return list(tuple(part.strip() for part in line) for line in csv.reader(io.TextIOWrapper(io.BytesIO(data.encode()), encoding='utf-8')) if line and not line[0].startswith('#'))
def handler(q=False): def handler(q=False):

View File

@ -99,7 +99,7 @@ def handler(q=False):
results = process_analysis_json(json.loads(data.decode('utf-8'))) results = process_analysis_json(json.loads(data.decode('utf-8')))
except ValueError: except ValueError:
log.warning('MISP modules {0} failed: uploaded file is not a zip or json file.'.format(request['module'])) log.warning('MISP modules {0} failed: uploaded file is not a zip or json file.'.format(request['module']))
return {'error': 'Uploaded file is not a zip or json file.'.format(request['module'])} return {'error': 'Uploaded file is not a zip or json file.'}
pass pass
# keep only unique entries based on the value field # keep only unique entries based on the value field
results = list({v['values']: v for v in results}.values()) results = list({v['values']: v for v in results}.values())