Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Add handling of securitygroups in cloudtrail plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
pwnbus committed Mar 15, 2018
1 parent 378c3d1 commit 3445ebd
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mq/plugins/cloudtrail.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ def onMessage(self, message, metadata):
'raw_value': str(endpoint_str)
}

# Handle details.responseelements.securityGroups strings
if 'securityGroups' in message['details']['responseelements']:
securityGroups_str = message['details']['responseelements']['securityGroups']
if type(securityGroups_str) is not dict:
message['details']['responseelements']['securityGroups'] = {
'raw_value': str(securityGroups_str)
}

# Handle details.additionaleventdata strings
if 'additionaleventdata' in message['details']:
additionaleventdata_str = message['details']['additionaleventdata']
Expand Down
24 changes: 24 additions & 0 deletions tests/mq/plugins/test_cloudtrail.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,27 @@ def test_ebs_optimized(self):
}
assert retmessage == expected_message
assert retmeta == {}

def test_securityGroups(self):
msg = {
'source': 'cloudtrail',
'details': {
'responseelements': {
'securityGroups': 'astringvalue',
}
}
}
(retmessage, retmeta) = self.plugin.onMessage(msg, {})

expected_message = {
'source': 'cloudtrail',
'details': {
'responseelements': {
'securityGroups': {
'raw_value': 'astringvalue',
}
}
}
}
assert retmessage == expected_message
assert retmeta == {}

0 comments on commit 3445ebd

Please sign in to comment.