17
17
"""
18
18
19
19
import copy
20
- from typing import Any
20
+ from typing import Any , List
21
21
22
22
import yaml
23
23
24
24
from app .converter .backends .sigma .const import SIGMA_RULE_DETAILS
25
25
from app .converter .backends .sigma .mapping import SigmaMappings , sigma_mappings , SigmaLogSourceSignature
26
26
from app .converter .core .compiler import DataStructureCompiler
27
27
from app .converter .core .exceptions .core import StrictPlatformFieldException
28
- from app .converter .core .mapping import SourceMapping
28
+ from app .converter .core .mapping import SourceMapping , DEFAULT_MAPPING_NAME
29
29
from app .converter .core .models .field import Field , Keyword
30
30
from app .converter .core .models .functions .types import ParsedFunctions
31
31
from app .converter .core .models .group import Group
@@ -229,11 +229,18 @@ def generate_detection(self, data: Any, source_mapping: SourceMapping) -> dict:
229
229
self .reset_counters ()
230
230
231
231
return detection
232
+
233
+ def __get_source_mapping (self , source_mapping_ids : List [str ]) -> SourceMapping :
234
+ for source_mapping_id in source_mapping_ids :
235
+ if source_mapping := self .mappings .get_source_mapping (source_mapping_id ):
236
+ return source_mapping
237
+
238
+ return self .mappings .get_source_mapping (DEFAULT_MAPPING_NAME )
232
239
233
240
def generate (self , query , meta_info : MetaInfoContainer , functions : ParsedFunctions ):
234
241
self .reset_counters ()
235
242
236
- source_mapping = self .mappings . get_source_mapping (meta_info .source_mapping_ids [ 0 ] )
243
+ source_mapping = self .__get_source_mapping (meta_info .source_mapping_ids )
237
244
log_source_signature : SigmaLogSourceSignature = source_mapping .log_source_signature
238
245
sigma_condition = copy .deepcopy (query )
239
246
prepared_data_structure = DataStructureCompiler ().generate (tokens = sigma_condition )
@@ -243,7 +250,7 @@ def generate(self, query, meta_info: MetaInfoContainer, functions: ParsedFunctio
243
250
"id" : meta_info .id ,
244
251
"description" : meta_info .description ,
245
252
"status" : "experimental" ,
246
- "author" : "" ,
253
+ "author" : meta_info . author ,
247
254
"references" : meta_info .references ,
248
255
"tags" : meta_info .tags ,
249
256
"logsource" : log_source_signature .log_sources ,
0 commit comments