Permalink
Browse files

Resolve E127 continuation line over indented

  • Loading branch information...
pwnbus committed Oct 31, 2018
1 parent db5c6c9 commit 3fbeae46113a44d7cbf36f1d91bf186088a4dea2
Showing with 56 additions and 49 deletions.
  1. +0 −1 .flake8
  2. +6 −4 alerts/alert_worker.py
  3. +11 −9 benchmarking/workers/json2Mozdef.py
  4. +6 −4 bot/mozdefbot.py
  5. +6 −4 bot/mozdefbot_slack.py
  6. +2 −2 mq/plugins/fxaFixup.py
  7. +4 −6 mq/plugins/googleFixup.py
  8. +21 −19 rest/index.py
@@ -9,7 +9,6 @@ ignore =
E123 # closing bracket does not match indentation of opening bracket's line
E124 # closing bracket does not match visual indentation
E125 # continuation line with same indent as next logical line
E127 # continuation line over-indented for visual indent
E128 # continuation line under-indented for visual indent
E225 # missing whitespace around operator
E226 # missing whitespace around arithmetic operator
@@ -67,10 +67,12 @@ def on_message(self, body, message):
def main():
# connect and declare the message queue/kombu objects.
# Event server/exchange/queue
mqConnString = 'amqp://{0}:{1}@{2}:{3}//'.format(options.mquser,
options.mqpassword,
options.mqalertserver,
options.mqport)
mqConnString = 'amqp://{0}:{1}@{2}:{3}//'.format(
options.mquser,
options.mqpassword,
options.mqalertserver,
options.mqport
)
mqAlertConn = Connection(mqConnString)
# Exchange for alerts we pass to plugins
@@ -77,15 +77,17 @@ def postLogs(logcache):
for i in range(0,10):
print(i)
alog=dict(eventtime=pytz.timezone('UTC').localize(datetime.now()).isoformat(),
hostname=socket.gethostname(),
processid=os.getpid(),
processname=sys.argv[0],
severity='INFO',
summary='joe login failed',
category='authentication',
tags=[],
details=[])
alog = dict(
eventtime=pytz.timezone('UTC').localize(datetime.now()).isoformat(),
hostname=socket.gethostname(),
processid=os.getpid(),
processname=sys.argv[0],
severity='INFO',
summary='joe login failed',
category='authentication',
tags=[],
details=[]
)
alog['details']=dict(success=True,username='mozdef')
alog['tags']=['mozdef','stresstest']
@@ -355,10 +355,12 @@ def on_message(self, body, message):
def consumeAlerts(ircBot):
# connect and declare the message queue/kombu objects.
# server/exchange/queue
mqConnString = 'amqp://{0}:{1}@{2}:{3}//'.format(options.mquser,
options.mqpassword,
options.mqalertserver,
options.mqport)
mqConnString = 'amqp://{0}:{1}@{2}:{3}//'.format(
options.mquser,
options.mqpassword,
options.mqalertserver,
options.mqport
)
mqAlertConn = Connection(mqConnString)
# Exchange for alerts we pass to plugins
@@ -190,10 +190,12 @@ def on_message(self, body, message):
def consumeAlerts(bot):
# connect and declare the message queue/kombu objects.
# server/exchange/queue
mqConnString = 'amqp://{0}:{1}@{2}:{3}//'.format(options.mquser,
options.mqpassword,
options.mqalertserver,
options.mqport)
mqConnString = 'amqp://{0}:{1}@{2}:{3}//'.format(
options.mquser,
options.mqpassword,
options.mqalertserver,
options.mqport
)
mqAlertConn = Connection(mqConnString)
# Exchange for alerts we pass to plugins
@@ -87,8 +87,8 @@ def onMessage(self, message, metadata):
# handle the case of an escaped list:
# "remoteAddressChain": "[\"1.2.3.4\",\"5.6.7.8\",\"127.0.0.1\"]"
if (isinstance(message['details']['remoteAddressChain'], unicode) and
message['details']['remoteAddressChain'][0]=='[' and
message['details']['remoteAddressChain'][-1]==']'):
message['details']['remoteAddressChain'][0] == '[' and
message['details']['remoteAddressChain'][-1] == ']'):
# remove the brackets and double quotes
for i in ['[',']','"']:
message['details']['remoteAddressChain']=message['details']['remoteAddressChain'].replace(i,'')
@@ -20,14 +20,12 @@ def onMessage(self, message, metadata):
# and do any clean up
# check for details.kind like 'admin#reports#activity'
if ('details' in message.keys() and
'kind' in message['details'].keys() and
'activity' in message['details']['kind']):
if ('details' in message and 'kind' in message['details'] and
'activity' in message['details']['kind']):
# details.etag might be quoted..unquote it
if 'etag' in message['details'].keys():
if 'etag' in message['details']:
message['details']['etag'] = message['details']['etag'].replace('"', '')
metadata['doc_type']= 'google'
metadata['doc_type'] = 'google'
return (message, metadata)
@@ -347,12 +347,14 @@ def createIncident():
incident['dateMitigated'] = validateDate(body.get('dateMitigated'))
incident['dateContained'] = validateDate(body.get('dateContained'))
dates = [incident['dateOpened'],
incident['dateClosed'],
incident['dateReported'],
incident['dateVerified'],
incident['dateMitigated'],
incident['dateContained']]
dates = [
incident['dateOpened'],
incident['dateClosed'],
incident['dateReported'],
incident['dateVerified'],
incident['dateMitigated'],
incident['dateContained']
]
# Validating all the dates for the format
if False in dates:
@@ -586,19 +588,19 @@ def verisSummary(verisRegex=None):
# aggregate the veris tags from the incidents collection and return as json
client = MongoClient(options.mongohost, options.mongoport)
# use meteor db
incidents= client.meteor['incidents']
iveris=incidents.aggregate([
{"$match":{"tags":{"$exists":True}}},
{"$unwind": "$tags"},
{"$match":{"tags":{"$regex":''}}}, # regex for tag querying
{"$project": {"dateOpened": 1,
"tags": 1,
"phase": 1,
"_id": 0
}}
])
incidents = client.meteor['incidents']
iveris = incidents.aggregate([
{"$match": {"tags": {"$exists": True}}},
{"$unwind": "$tags"},
{"$match": {"tags": {"$regex": ''}}},
{"$project": {
"dateOpened": 1,
"tags": 1,
"phase": 1,
"_id": 0
}}
])
if iveris:
return json.dumps(list(iveris), default=json_util.default)
else:

0 comments on commit 3fbeae4

Please sign in to comment.