Skip to content

Commit

Permalink
Fix attack requests from snare-develop (#149)
Browse files Browse the repository at this point in the history
* phase#1

* Fix tests
  • Loading branch information
viskey98 authored and afeena committed Jul 11, 2018
1 parent 83b36c6 commit 14bfbe7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions snare/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async def submit_slurp(self, data):
self.logger.error('Error submitting slurp: %s', e)

async def handle_request(self, request):
self.logger.info('Request path: {0}'.format(request.path))
self.logger.info('Request path: {0}'.format(request.path_qs))
data = self.tanner_handler.create_data(request, 200)
if request.method == 'POST':
post_data = await request.post()
Expand All @@ -51,10 +51,10 @@ async def handle_request(self, request):

# Log the event to slurp service if enabled
if self.run_args.slurp_enabled:
await self.submit_slurp(request.path)
await self.submit_slurp(request.path_qs)

content, content_type, headers, status_code = await self.tanner_handler.parse_tanner_response(
request.path, event_result['response']['message']['detection'])
request.path_qs, event_result['response']['message']['detection'])

response_headers = multidict.CIMultiDict()

Expand Down
2 changes: 1 addition & 1 deletion snare/tanner_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def create_data(self, request, response_status):
header = {key: value for (key, value) in request.headers.items()}
data['method'] = request.method
data['headers'] = header
data['path'] = request.path
data['path'] = request.path_qs
if ('Cookie' in header):
data['cookies'] = {
cookie.split('=')[0]: cookie.split('=')[1] for cookie in header['Cookie'].split(';')
Expand Down
2 changes: 1 addition & 1 deletion snare/tests/test_create_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def setUp(self):
self.response_status = "test_status"
self.data = None
self.expected_data = {
'method': 'POST', 'path': '/',
'method': 'POST', 'path': 'http://test_url/',
'headers': {'Host': 'test_host', 'status': 200,
'Cookie': 'sess_uuid=prev_test_uuid; test_cookie=test'},
'uuid': '9c10172f-7ce2-4fb4-b1c6-abc70141db56',
Expand Down
4 changes: 2 additions & 2 deletions snare/tests/test_handle_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ def test_submit_request_slurp(self):
async def test():
await self.handler.handle_request(self.request)
self.loop.run_until_complete(test())
self.handler.submit_slurp.assert_called_with(self.request.path)
self.handler.submit_slurp.assert_called_with(self.request.path_qs)

def test_parse_response(self):

async def test():
await self.handler.handle_request(self.request)
self.loop.run_until_complete(test())
self.handler.tanner_handler.parse_tanner_response.assert_called_with(self.request.path, {'type': 1})
self.handler.tanner_handler.parse_tanner_response.assert_called_with(self.request.path_qs, {'type': 1})

def tearDown(self):
shutil.rmtree(self.main_page_path)

0 comments on commit 14bfbe7

Please sign in to comment.