2017-03-24 19:28:01 +03:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
# Copyright (c) 2017 Mozilla Corporation
|
|
|
|
|
|
|
|
|
|
|
|
from lib.alerttask import AlertTask
|
2018-10-17 01:33:58 +03:00
|
|
|
from mozdef_util.query_models import SearchQuery, TermMatch
|
2017-03-24 19:28:01 +03:00
|
|
|
|
|
|
|
|
|
|
|
class AlertCloudtrailDeadman(AlertTask):
|
|
|
|
def main(self):
|
|
|
|
search_query = SearchQuery(hours=1)
|
|
|
|
|
|
|
|
search_query.add_must([
|
2018-03-03 00:29:30 +03:00
|
|
|
TermMatch('source', 'cloudtrail')
|
2017-03-24 19:28:01 +03:00
|
|
|
])
|
|
|
|
|
|
|
|
self.filtersManual(search_query)
|
|
|
|
self.searchEventsSimple()
|
|
|
|
self.walkEvents()
|
|
|
|
|
|
|
|
# Set alert properties
|
|
|
|
# if no events found
|
|
|
|
def onNoEvent(self):
|
|
|
|
category = 'deadman'
|
|
|
|
tags = ['cloudtrail', 'aws']
|
|
|
|
severity = 'ERROR'
|
|
|
|
|
|
|
|
summary = 'No cloudtrail events found the last hour'
|
|
|
|
|
|
|
|
# Create the alert object based on these properties
|
|
|
|
return self.createAlertDict(summary, category, tags, [], severity=severity)
|