Rewrote logsource definition merging to set generator

This commit is contained in:
Thomas Patzke 2018-09-12 22:29:51 +02:00
parent 1d7722c1cb
commit 210f7ac044

View File

@ -142,9 +142,9 @@ class SigmaLogsourceConfiguration:
self.conditions = None self.conditions = None
elif type(logsource) == list and all([isinstance(o, SigmaLogsourceConfiguration) for o in logsource]): # list of SigmaLogsourceConfigurations: merge according to mergemethod elif type(logsource) == list and all([isinstance(o, SigmaLogsourceConfiguration) for o in logsource]): # list of SigmaLogsourceConfigurations: merge according to mergemethod
# Merge category, product and service # Merge category, product and service
categories = set([ ls.category for ls in logsource if ls.category != None ]) categories = { ls.category for ls in logsource if ls.category is not None }
products = set([ ls.product for ls in logsource if ls.product != None ]) products = { ls.product for ls in logsource if ls.product is not None }
services = set([ ls.service for ls in logsource if ls.service != None]) services = { ls.service for ls in logsource if ls.service is not None }
if len(categories) > 1 or len(products) > 1 or len(services) > 1: if len(categories) > 1 or len(products) > 1 or len(services) > 1:
raise ValueError("Merged SigmaLogsourceConfigurations must have disjunct categories (%s), products (%s) and services (%s)" % (str(categories), str(products), str(services))) raise ValueError("Merged SigmaLogsourceConfigurations must have disjunct categories (%s), products (%s) and services (%s)" % (str(categories), str(products), str(services)))