1818import re
1919from fnmatch import fnmatch
2020import sys
21+ import os
22+ from random import randrange
2123
2224import sigma
2325import yaml
@@ -992,17 +994,15 @@ def generateQuery(self, parsed):
992994 #Generate ES QS Query
993995 return [{ 'query' : { 'query_string' : { 'query' : super ().generateQuery (parsed ) } } }]
994996
995-
996997class ElasticSearchRuleBackend (ElasticsearchQuerystringBackend ):
997- identifier = "elasticsearch -rule"
998+ identifier = "es -rule"
998999 active = True
9991000
10001001 def __init__ (self , * args , ** kwargs ):
10011002 super ().__init__ (* args , ** kwargs )
10021003 self .tactics = self ._load_mitre_file ("tactics" )
10031004 self .techniques = self ._load_mitre_file ("techniques" )
10041005
1005-
10061006 def _load_mitre_file (self , mitre_type ):
10071007 try :
10081008 backend_dir = os .path .normpath (os .path .join (os .path .dirname (os .path .abspath (__file__ )), ".." , ".." , "config" , "mitre" ))
@@ -1013,7 +1013,7 @@ def _load_mitre_file(self, mitre_type):
10131013 except (IOError , OSError ) as e :
10141014 print ("Failed to open {} configuration file '%s': %s" .format (path , str (e )), file = sys .stderr )
10151015 return []
1016- except json .JSONDecoder as e :
1016+ except json .JSONDecodeError as e :
10171017 print ("Failed to parse {} configuration file '%s' as valid YAML: %s" % (path , str (e )), file = sys .stderr )
10181018 return []
10191019
@@ -1025,7 +1025,6 @@ def generate(self, sigmaparser):
10251025 rule = self .create_rule (configs )
10261026 return rule
10271027
1028-
10291028 def create_threat_description (self , tactics_list , techniques_list ):
10301029 threat_list = list ()
10311030 for tactic in tactics_list :
@@ -1134,4 +1133,4 @@ def create_rule(self, configs):
11341133 "threat" : threat ,
11351134 "version" : 1
11361135 }
1137- return json .dumps (rule )
1136+ return json .dumps (rule )
0 commit comments