def alertPlugins(self, alert): """ Send alerts through a plugin system """ plugin_dir = os.path.join(os.path.dirname(__file__), "../plugins") plugin_set = AlertPluginSet(plugin_dir, ALERT_PLUGINS) alertDict = plugin_set.run_plugins(alert)[0] return alertDict
def __init__(self): self.alert_name = self.__class__.__name__ self.main_query = None # Used to store any alerts that were thrown self.alert_ids = [] # List of events self.events = None # List of aggregations # e.g. when aggregField is email: [{value:'*****@*****.**',count:1337,events:[...]}, ...] self.aggregations = None self.log.debug("starting {0}".format(self.alert_name)) self.log.debug(RABBITMQ) self.log.debug(ES) self._configureKombu() self._configureES() self.event_indices = ['events', 'events-previous'] plugin_dir = os.path.join(os.path.dirname(__file__), "../plugins") self.plugin_set = AlertPluginSet(plugin_dir, ALERT_PLUGINS)
options.queueName = getConfig('alertqueuename', 'alertPlugins', options.configfile) # queue topic options.alerttopic = getConfig('alerttopic', 'mozdef.*', options.configfile) # how many messages to ask for at once options.prefetch = getConfig('prefetch', 50, options.configfile) options.mquser = getConfig('mquser', 'guest', options.configfile) options.mqpassword = getConfig('mqpassword', 'guest', options.configfile) options.mqport = getConfig('mqport', 5672, options.configfile) # mqack=True sets persistant delivery, False sets transient delivery options.mqack = getConfig('mqack', True, options.configfile) if __name__ == '__main__': parser = OptionParser() parser.add_option("-c", dest='configfile', default=sys.argv[0].replace('.py', '.conf'), help="configuration file to use") (options, args) = parser.parse_args() initConfig() initLogger(options) action_dir = os.path.abspath( os.path.join(os.path.dirname(__file__), 'actions')) action_set = AlertPluginSet(action_dir, ALERT_ACTIONS) main()
options.configfile) # queue topic options.alerttopic = getConfig( 'alerttopic', 'mozdef.*', options.configfile) # how many messages to ask for at once options.prefetch = getConfig('prefetch', 50, options.configfile) options.mquser = getConfig('mquser', 'guest', options.configfile) options.mqpassword = getConfig('mqpassword', 'guest', options.configfile) options.mqport = getConfig('mqport', 5672, options.configfile) # mqack=True sets persistant delivery, False sets transient delivery options.mqack = getConfig('mqack', True, options.configfile) if __name__ == '__main__': parser = OptionParser() parser.add_option("-c", dest='configfile', default=sys.argv[0].replace('.py', '.conf'), help="configuration file to use") (options, args) = parser.parse_args() initConfig() initLogger(options) plugin_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'plugins')) plugin_set = AlertPluginSet(plugin_dir, ALERT_PLUGINS) main()