Permalink
Browse files

Fixup unused variables check

  • Loading branch information...
pwnbus committed Dec 14, 2018
1 parent df84a19 commit 46be867d2fa69da6ce208930e9ab299c978b18b4
@@ -17,4 +17,3 @@ ignore =
E402 # module level import not at top of file
E501 # line too long
E722 # do not use bare except'
F841 # local variable 'CIDR' is assigned to but never used
@@ -65,7 +65,7 @@ def onMessage(self, message):
}
]
})
r = requests.post(
requests.post(
'https://events.pagerduty.com/generic/2010-04-15/create_event.json',
headers=headers,
data=payload,
@@ -127,7 +127,7 @@ def ipLocation(ip):
if geoDict['country_code'] in ('US'):
if geoDict['metro_code']:
location = location + '/{0}'.format(geoDict['metro_code'])
except Exception as e:
except Exception:
location = ""
return location

@@ -152,7 +152,7 @@ def s3_upload_file(file_path, bucket_name, key_name):
conn = boto.connect_s3(aws_access_key_id=options.aws_access_key_id, aws_secret_access_key=options.aws_secret_access_key)
try:
bucket = conn.get_bucket(bucket_name, validate=False)
except boto.exception.S3ResponseError as e:
except boto.exception.S3ResponseError:
conn.create_bucket(bucket_name)
bucket = conn.get_bucket(bucket_name, validate=False)

@@ -224,7 +224,7 @@ def s3_upload_file(file_path, bucket_name, key_name):
conn = boto.connect_s3(aws_access_key_id=options.aws_access_key_id, aws_secret_access_key=options.aws_secret_access_key)
try:
bucket = conn.get_bucket(bucket_name, validate=False)
except boto.exception.S3ResponseError as e:
except boto.exception.S3ResponseError:
conn.create_bucket(bucket_name)
bucket = conn.get_bucket(bucket_name, validate=False)

@@ -100,7 +100,7 @@ def send(self, timestamp=None, summary=None, category=None, severity=None, tags=
raise MozDefError('Summary is a required field')

try:
r = self.httpsession.post(self.url, json.dumps(log_msg, encoding='utf-8'), verify=self.verify_certificate)
self.httpsession.post(self.url, json.dumps(log_msg, encoding='utf-8'), verify=self.verify_certificate)

except Exception as e:
if not self.fire_and_forget_mode:
@@ -57,7 +57,7 @@ def setConfig(option,value,configfile):
def postLogs(logcache):
# post logs asynchronously with requests workers and check on the results
# expects a queue object from the multiprocessing library
posts=[]
# posts=[]
try:
while not logcache.empty():
postdata=logcache.get_nowait()
@@ -70,7 +70,7 @@ def postLogs(logcache):
# append to posts if this is long running and you want
# events to try again later.
# posts.append((r,postdata,url))
except Empty as e:
except Empty:
pass
# for p, postdata, url in posts:
# try:
@@ -27,7 +27,7 @@ def status():
@route('/test')
@route('/test/')
def testindex():
ip = request.environ.get('REMOTE_ADDR')
# ip = request.environ.get('REMOTE_ADDR')
# response.headers['X-IP'] = '{0}'.format(ip)
response.status=200

@@ -53,7 +53,7 @@ def bulkindex():
# valid json?
try:
eventDict=json.loads(i)
except ValueError as e:
except ValueError:
response.status=500
return
# don't post the items telling us where to post things..
@@ -79,7 +79,7 @@ def eventsindex():
# valid json?
try:
eventDict=json.loads(anevent)
except ValueError as e:
except ValueError:
response.status=500
return
# let the message queue worker who gets this know where it was posted
@@ -101,7 +101,7 @@ def cefindex():
# valid json?
try:
cefDict=json.loads(anevent)
except ValueError as e:
except ValueError:
response.status=500
return
# let the message queue worker who gets this know where it was posted
@@ -129,7 +129,7 @@ def customindex(application):
# valid json?
try:
customDict=json.loads(anevent)
except ValueError as e:
except ValueError:
response.status=500
return
# let the message queue worker who gets this know where it was posted
@@ -308,8 +308,6 @@ def __init__(self, mqConnection, taskQueue, esConnection):

def authenticate(self):
if options.cloudtrail_arn not in ['<cloudtrail_arn>', 'cloudtrail_arn']:
role_manager_args = {}

role_manager = RoleManager(**get_aws_credentials(
options.region,
options.accesskey,
@@ -369,7 +367,7 @@ def run(self):
self.on_message(event)

self.taskQueue.delete_message(msg)
except (SSLEOFError, SSLError, socket.error) as e:
except (SSLEOFError, SSLError, socket.error):
logger.info('Received network related error...reconnecting')
time.sleep(5)
self.connection, self.taskQueue = connect_sqs(
@@ -37,7 +37,7 @@ def ipLocation(self, ip):
return geoDict
else:
location['location'] = 'unknown'
except ValueError as e:
except ValueError:
pass
return location

@@ -50,7 +50,7 @@ def _enable_cors(*args, **kwargs):
@route('/test/')
def test():
'''test endpoint for..testing'''
ip = request.environ.get('REMOTE_ADDR')
# ip = request.environ.get('REMOTE_ADDR')
# response.headers['X-IP'] = '{0}'.format(ip)
response.status = 200

@@ -143,7 +143,7 @@ def index():
# valid json?
try:
requestDict = json.loads(arequest)
except ValueError as e:
except ValueError:
response.status = 500

if 'ipaddress' in requestDict.keys() and isIPv4(requestDict['ipaddress']):
@@ -167,7 +167,7 @@ def ipintel():
# valid json?
try:
requestDict = json.loads(arequest)
except ValueError as e:
except ValueError:
response.status = 500
if 'ipaddress' in requestDict.keys() and isIPv4(requestDict['ipaddress']):
response.content_type = "application/json"
@@ -192,7 +192,7 @@ def index():
# valid json?
try:
requestDict = json.loads(arequest)
except ValueError as e:
except ValueError:
response.status = 500
return
if 'ipaddress' in requestDict.keys() and isIPv4(requestDict['ipaddress']):
@@ -55,7 +55,7 @@ def onMessage(self, request, response):
request.body.close()
try:
requestDict = json.loads(arequest)
except ValueError as e:
except ValueError:
response.status = 500

print(requestDict, requestDict.keys())
@@ -158,7 +158,6 @@ def onMessage(self, request, response):
'''
# format/validate request.json:
ipaddress = None
CIDR = None
sendToBHVPC = False

# loop through the fields of the form
@@ -357,7 +357,7 @@ def test_write_with_id(self):
saved_event = self.es_client.save_event(body=event, doc_id=event_id)
assert saved_event['_id'] == event_id
self.flush(self.event_index_name)
fetched_event = self.es_client.get_event_by_id(event_id)
self.es_client.get_event_by_id(event_id)


class TestGetIndices(ElasticsearchClientTest):

0 comments on commit 46be867

Please sign in to comment.