fix: Making pep8 happy

pull/380/head
chrisr3d 2020-03-10 11:15:16 +01:00
parent 55664dadb9
commit 0b4d6738de
No known key found for this signature in database
GPG Key ID: 6BBED1B63A6D639F
1 changed files with 6 additions and 6 deletions

View File

@ -18,16 +18,17 @@ misp_types_in = ['sha256', 'ip', 'ip-src', 'ip-dst', 'uri', 'url', 'domain', 'ho
mispattributes = {'input': misp_types_in, mispattributes = {'input': misp_types_in,
'format': 'misp_standard'} 'format': 'misp_standard'}
class SophosLabsApi(): class SophosLabsApi():
def __init__(self, client_id, client_secret): def __init__(self, client_id, client_secret):
self.misp_event = MISPEvent() self.misp_event = MISPEvent()
self.client_id = client_id self.client_id = client_id
self.client_secret= client_secret self.client_secret = client_secret
self.authToken = f"{self.client_id}:{self.client_secret}" self.authToken = f"{self.client_id}:{self.client_secret}"
self.baseurl = 'de.api.labs.sophos.com' self.baseurl = 'de.api.labs.sophos.com'
d = {'grant_type': 'client_credentials'} d = {'grant_type': 'client_credentials'}
h = {'Authorization': f"Basic {base64.b64encode(self.authToken.encode('UTF-8')).decode('ascii')}",\ h = {'Authorization': f"Basic {base64.b64encode(self.authToken.encode('UTF-8')).decode('ascii')}",
'Content-Type': 'application/x-www-form-urlencoded'} 'Content-Type': 'application/x-www-form-urlencoded'}
r = requests.post('https://api.labs.sophos.com/oauth2/token', headers=h, data=d) r = requests.post('https://api.labs.sophos.com/oauth2/token', headers=h, data=d)
if r.status_code == 200: if r.status_code == 200:
j = json.loads(r.text) j = json.loads(r.text)
@ -83,12 +84,12 @@ class SophosLabsApi():
sophos_object.add_attribute('URL Categorisation', type='text', value=j['productivityCategory']) sophos_object.add_attribute('URL Categorisation', type='text', value=j['productivityCategory'])
else: else:
sophos_object.add_attribute('URL Categorisation', type='text', value='No category assocaited with IoC') sophos_object.add_attribute('URL Categorisation', type='text', value='No category assocaited with IoC')
if 'riskLevel' in j: if 'riskLevel' in j:
sophos_object.add_attribute('URL Risk Level', type='text', value=j['riskLevel']) sophos_object.add_attribute('URL Risk Level', type='text', value=j['riskLevel'])
else: else:
sophos_object.add_attribute('URL Risk Level', type='text', value='No risk level associated with IoC') sophos_object.add_attribute('URL Risk Level', type='text', value='No risk level associated with IoC')
if 'securityCategory' in j: if 'securityCategory' in j:
sophos_object.add_attribute('URL Security Category', type='text', value=j['securityCategory']) sophos_object.add_attribute('URL Security Category', type='text', value=j['securityCategory'])
else: else:
@ -121,4 +122,3 @@ def introspection():
def version(): def version():
moduleinfo['config'] = moduleconfig moduleinfo['config'] = moduleconfig
return moduleinfo return moduleinfo