зеркало из https://github.com/mozilla/MozDef.git
Fix parsing values for rest plugins
This commit is contained in:
Родитель
581c597c11
Коммит
ca037892eb
|
@ -204,21 +204,20 @@ class message(object):
|
|||
# loop through the fields of the form
|
||||
# and fill in our values
|
||||
try:
|
||||
for i in request.json:
|
||||
for field in request.json:
|
||||
# were we checked?
|
||||
if self.name in i:
|
||||
blockfqdn = i.values()[0]
|
||||
if 'fqdn' in i:
|
||||
fqdn = i.values()[0]
|
||||
if 'duration' in i:
|
||||
duration = i.values()[0]
|
||||
if 'comment' in i:
|
||||
comment = i.values()[0]
|
||||
if 'referenceid' in i:
|
||||
referenceID = i.values()[0]
|
||||
if 'userid' in i:
|
||||
userid = i.values()[0]
|
||||
|
||||
if self.name in field:
|
||||
blockfqdn = field[self.name]
|
||||
if 'fqdn' in field:
|
||||
fqdn = field['fqdn']
|
||||
if 'duration' in field:
|
||||
duration = field['duration']
|
||||
if 'comment' in field:
|
||||
comment = field['comment']
|
||||
if 'referenceid' in field:
|
||||
referenceID = field['referenceid']
|
||||
if 'userid' in field:
|
||||
userid = field['userid']
|
||||
if blockfqdn and fqdn is not None:
|
||||
if isFQDN(fqdn):
|
||||
whitelisted = False
|
||||
|
|
|
@ -10,7 +10,6 @@ import requests
|
|||
from configlib import getConfig, OptionParser
|
||||
from datetime import datetime, timedelta
|
||||
from pymongo import MongoClient
|
||||
|
||||
from mozdef_util.utilities.logger import logger
|
||||
|
||||
|
||||
|
@ -191,7 +190,7 @@ class message(object):
|
|||
headers=headers,
|
||||
data=post_data)
|
||||
if response.ok:
|
||||
logger.info('%s: notification sent to statuspage.io\n' % (str(ipcidr)))
|
||||
logger.debug('%s: notification sent to statuspage.io\n' % (str(ipcidr)))
|
||||
else:
|
||||
logger.error('%s: statuspage.io notification failed %s\n' % (str(ipcidr), response.json()))
|
||||
except Exception as e:
|
||||
|
@ -201,7 +200,7 @@ class message(object):
|
|||
else:
|
||||
logger.error('%s: is not a valid ip address\n' % (ipaddress))
|
||||
except Exception as e:
|
||||
logger.error('Error while blocking %s: %s\n' % (ipaddress, e))
|
||||
logger.exception('Error while blocking %s: %s\n' % (ipaddress, e))
|
||||
|
||||
def onMessage(self, request, response):
|
||||
'''
|
||||
|
@ -221,23 +220,23 @@ class message(object):
|
|||
userid = None
|
||||
blockip = False
|
||||
|
||||
# loop through the fields of the form
|
||||
# and fill in our values
|
||||
try:
|
||||
for i in request.json:
|
||||
# loop through the fields of the form
|
||||
# and fill in our values
|
||||
for field in request.json:
|
||||
# were we checked?
|
||||
if self.name in i:
|
||||
blockip = i.values()[0]
|
||||
if 'ipaddress' in i:
|
||||
ipaddress = i.values()[0]
|
||||
if 'duration' in i:
|
||||
duration = i.values()[0]
|
||||
if 'comment' in i:
|
||||
comment = i.values()[0]
|
||||
if 'referenceid' in i:
|
||||
referenceID = i.values()[0]
|
||||
if 'userid' in i:
|
||||
userid = i.values()[0]
|
||||
if self.name in field:
|
||||
blockip = field[self.name]
|
||||
if 'ipaddress' in field:
|
||||
ipaddress = field['ipaddress']
|
||||
if 'duration' in field:
|
||||
duration = field['duration']
|
||||
if 'comment' in field:
|
||||
comment = field['comment']
|
||||
if 'referenceid' in field:
|
||||
referenceID = field['referenceid']
|
||||
if 'userid' in field:
|
||||
userid = field['userid']
|
||||
|
||||
if blockip and ipaddress is not None:
|
||||
# figure out the CIDR mask
|
||||
|
|
|
@ -164,13 +164,12 @@ class message(object):
|
|||
# loop through the fields of the form
|
||||
# and fill in our values
|
||||
try:
|
||||
for i in request.json:
|
||||
for field in request.json:
|
||||
# were we checked?
|
||||
if self.name in i:
|
||||
sendToBHVPC = i.values()[0]
|
||||
if 'ipaddress' in i:
|
||||
ipaddress = i.values()[0]
|
||||
|
||||
if self.name in field:
|
||||
sendToBHVPC = field[self.name]
|
||||
if 'ipaddress' in field:
|
||||
ipaddress = field['ipaddress']
|
||||
# are we configured?
|
||||
if self.multioptions is None:
|
||||
logger.error("Customs server blockip requested but not configured\n")
|
||||
|
|
|
@ -126,21 +126,19 @@ class message(object):
|
|||
# loop through the fields of the form
|
||||
# and fill in our values
|
||||
try:
|
||||
for i in request.json:
|
||||
# were we checked?
|
||||
if self.name in i.keys():
|
||||
watchitem = i.values()[0]
|
||||
if 'watchcontent' in i.keys():
|
||||
watchcontent = i.values()[0]
|
||||
if 'duration' in i.keys():
|
||||
duration = i.values()[0]
|
||||
if 'comment' in i.keys():
|
||||
comment = i.values()[0]
|
||||
if 'referenceid' in i.keys():
|
||||
referenceID = i.values()[0]
|
||||
if 'userid' in i.keys():
|
||||
userid = i.values()[0]
|
||||
|
||||
for field in request.json:
|
||||
if self.name in field:
|
||||
watchitem = field[self.name]
|
||||
if 'watchcontent' in field:
|
||||
watchcontent = field['watchcontent']
|
||||
if 'duration' in field:
|
||||
duration = field['duration']
|
||||
if 'comment' in field:
|
||||
comment = field['comment']
|
||||
if 'referenceid' in field:
|
||||
referenceID = field['referenceid']
|
||||
if 'userid' in field:
|
||||
userid = field['userid']
|
||||
if watchitem and watchcontent is not None:
|
||||
if len(watchcontent) < 2:
|
||||
logger.error('{0} does not meet requirements. Not added. \n'.format(watchcontent))
|
||||
|
|
Загрузка…
Ссылка в новой задаче