misp-modules/misp_modules/modules/import_mod/testimport.py

65 lines
1.7 KiB
Python
Raw Normal View History

2016-08-04 08:00:09 +02:00
import json
import base64
import csv
misperrors = {'error': 'Error'}
userConfig = {
2016-08-04 09:12:10 +02:00
'number1': {
2016-08-04 08:00:09 +02:00
'type': 'Integer',
'regex': '/^[0-4]$/i',
'errorMessage': 'Expected a number in range [0-4]',
'message': 'Column number used for value'
},
2016-08-04 09:12:10 +02:00
'some_string': {
'type': 'String',
'message': 'A text field'
2016-08-04 08:00:09 +02:00
},
2016-08-04 09:12:10 +02:00
'boolean_field': {
'type': 'Boolean',
'message': 'Boolean field test'
2016-08-04 08:00:09 +02:00
},
'comment': {
'type': 'Integer',
'message': 'Column number used for comment'
}
};
inputSource = ['file', 'paste']
moduleinfo = {'version': '0.2', 'author': 'Andras Iklody',
'description': 'Simple CSV import tool with mapable columns',
'module-type': ['import']}
moduleconfig = []
def handler(q=False):
if q is False:
return False
r = {'results': []}
request = json.loads(q)
request["data"] = base64.b64decode(request["data"])
fields = ["value", "category", "type", "comment"]
r = {"results":[{"values":["192.168.56.1"], "types":["ip-src"], "categories":["Network activity"]}]}
return r
def introspection():
modulesetup = {}
try:
userConfig
modulesetup['userConfig'] = userConfig
except NameError:
pass
try:
inputSource
modulesetup['inputSource'] = inputSource
except NameError:
pass
return modulesetup
def version():
moduleinfo['config'] = moduleconfig
return moduleinfo