mirror of https://github.com/MISP/misp-modules
Add indent field for export
parent
6953b847e5
commit
24c51a6e21
|
@ -8,11 +8,8 @@ moduleinfo = {'version': '1',
|
||||||
'description': 'export lite',
|
'description': 'export lite',
|
||||||
'module-type': ['export']}
|
'module-type': ['export']}
|
||||||
|
|
||||||
#~ config form admin site but do not work
|
moduleconfig = ["indent_json_export"]
|
||||||
#~ moduleconfig = ["indent_json_export"]
|
|
||||||
moduleconfig = []
|
|
||||||
|
|
||||||
#~ mispattributes = {'input':'all'} ?
|
|
||||||
mispattributes = {}
|
mispattributes = {}
|
||||||
outputFileExtension = "json"
|
outputFileExtension = "json"
|
||||||
responseType = "application/json"
|
responseType = "application/json"
|
||||||
|
@ -20,11 +17,20 @@ responseType = "application/json"
|
||||||
def handler(q=False):
|
def handler(q=False):
|
||||||
if q is False:
|
if q is False:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
request = json.loads(q)
|
request = json.loads(q)
|
||||||
|
|
||||||
|
config = {}
|
||||||
if "config" in request:
|
if "config" in request:
|
||||||
config = request["config"]
|
config = request["config"]
|
||||||
else:
|
else:
|
||||||
config = {"indent_json_export":None}
|
config = {"indent_json_export" : None}
|
||||||
|
|
||||||
|
if config['indent_json_export'] is not None:
|
||||||
|
try:
|
||||||
|
config['indent_json_export'] = int(config['indent_json_export'])
|
||||||
|
except:
|
||||||
|
config['indent_json_export'] = None
|
||||||
|
|
||||||
if 'data' not in request:
|
if 'data' not in request:
|
||||||
return False
|
return False
|
||||||
|
@ -46,8 +52,8 @@ def handler(q=False):
|
||||||
liteAttr['value'] = attr['value']
|
liteAttr['value'] = attr['value']
|
||||||
liteEvent['Event']['Attribute'].append(liteAttr)
|
liteEvent['Event']['Attribute'].append(liteAttr)
|
||||||
|
|
||||||
return {"response":[],
|
return {'response' : [],
|
||||||
'data': str(base64.b64encode(
|
'data' : str(base64.b64encode(
|
||||||
bytes(
|
bytes(
|
||||||
json.dumps(liteEvent, indent=config['indent_json_export']),
|
json.dumps(liteEvent, indent=config['indent_json_export']),
|
||||||
'utf-8')),
|
'utf-8')),
|
||||||
|
|
Loading…
Reference in New Issue