mirror of https://github.com/MISP/misp-modules
chg: [qrcode] various fixes to make it PEP compliant
parent
a0fce1bc90
commit
d5180e7e79
|
@ -20,6 +20,7 @@ cryptocurrencies = {'bitcoin'}
|
||||||
schemas = {'http://', 'https://', 'ftp://'}
|
schemas = {'http://', 'https://', 'ftp://'}
|
||||||
moduleconfig = []
|
moduleconfig = []
|
||||||
|
|
||||||
|
|
||||||
def handler(q=False):
|
def handler(q=False):
|
||||||
if q is False:
|
if q is False:
|
||||||
return False
|
return False
|
||||||
|
@ -27,7 +28,7 @@ def handler(q=False):
|
||||||
filename = q['attachment']
|
filename = q['attachment']
|
||||||
try:
|
try:
|
||||||
img_array = np.fromstring(binascii.a2b_base64(q['data']), np.uint8)
|
img_array = np.fromstring(binascii.a2b_base64(q['data']), np.uint8)
|
||||||
except:
|
except Exception as e:
|
||||||
err = "Couldn't fetch attachment (JSON 'data' is empty). Are you using the 'Query enrichment' action?"
|
err = "Couldn't fetch attachment (JSON 'data' is empty). Are you using the 'Query enrichment' action?"
|
||||||
misperrors['error'] = err
|
misperrors['error'] = err
|
||||||
print(err)
|
print(err)
|
||||||
|
@ -46,7 +47,7 @@ def handler(q=False):
|
||||||
for item in cryptocurrencies:
|
for item in cryptocurrencies:
|
||||||
if item in result:
|
if item in result:
|
||||||
try:
|
try:
|
||||||
currency, address, extra = re.split('\:|\?', result)
|
currency, address, extra = re.split('\:|\?', result)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
if currency in cryptocurrencies:
|
if currency in cryptocurrencies:
|
||||||
|
@ -60,7 +61,7 @@ def handler(q=False):
|
||||||
print(e)
|
print(e)
|
||||||
else:
|
else:
|
||||||
print(address)
|
print(address)
|
||||||
for item in schemas:
|
for item in schemas:
|
||||||
if item in result:
|
if item in result:
|
||||||
try:
|
try:
|
||||||
url = result
|
url = result
|
||||||
|
@ -77,6 +78,7 @@ def handler(q=False):
|
||||||
misperrors['error'] = "Couldn't decode QR code in attachment."
|
misperrors['error'] = "Couldn't decode QR code in attachment."
|
||||||
return misperrors
|
return misperrors
|
||||||
|
|
||||||
|
|
||||||
def introspection():
|
def introspection():
|
||||||
return mispattributes
|
return mispattributes
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue