Browse Source

fix: Making pep8 happy

pull/415/head
chrisr3d 1 year ago
parent
commit
26b0357ac7
No known key found for this signature in database GPG Key ID: 6BBED1B63A6D639F
  1. 10
      misp_modules/modules/expansion/rbl.py
  2. 4
      misp_modules/modules/import_mod/csvimport.py
  3. 2
      misp_modules/modules/import_mod/threatanalyzer_import.py

10
misp_modules/modules/expansion/rbl.py

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

4
misp_modules/modules/import_mod/csvimport.py

@ -244,11 +244,11 @@ def __any_mandatory_misp_field(header):
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):
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):

2
misp_modules/modules/import_mod/threatanalyzer_import.py

@ -99,7 +99,7 @@ def handler(q=False):
results = process_analysis_json(json.loads(data.decode('utf-8')))
except ValueError:
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
# keep only unique entries based on the value field
results = list({v['values']: v for v in results}.values())

Loading…
Cancel
Save