16
16
)
17
17
18
18
from contentctl .objects .macro import Macro
19
- from contentctl .objects .lookup import Lookup
19
+ from contentctl .objects .lookup import Lookup , FileBackedLookup , KVStoreLookup
20
20
if TYPE_CHECKING :
21
21
from contentctl .input .director import DirectorOutputDto
22
22
from contentctl .objects .baseline import Baseline
@@ -285,10 +285,8 @@ def annotations(self) -> dict[str, Union[List[str], int, str]]:
285
285
286
286
annotations_dict : dict [str , str | list [str ] | int ] = {}
287
287
annotations_dict ["analytic_story" ] = [story .name for story in self .tags .analytic_story ]
288
- annotations_dict ["confidence" ] = self .tags .confidence
289
288
if len (self .tags .cve or []) > 0 :
290
289
annotations_dict ["cve" ] = self .tags .cve
291
- annotations_dict ["impact" ] = self .tags .impact
292
290
annotations_dict ["type" ] = self .type
293
291
annotations_dict ["type_list" ] = [self .type ]
294
292
# annotations_dict["version"] = self.version
@@ -480,6 +478,11 @@ def serialize_model(self):
480
478
"source" : self .source ,
481
479
"nes_fields" : self .nes_fields ,
482
480
}
481
+ if self .rba is not None :
482
+ model ["risk_severity" ] = self .rba .severity
483
+ model ['tags' ]['risk_score' ] = self .rba .risk_score
484
+ else :
485
+ model ['tags' ]['risk_score' ] = 0
483
486
484
487
# Only a subset of macro fields are required:
485
488
all_macros : list [dict [str , str | list [str ]]] = []
@@ -497,27 +500,26 @@ def serialize_model(self):
497
500
498
501
all_lookups : list [dict [str , str | int | None ]] = []
499
502
for lookup in self .lookups :
500
- if lookup . collection is not None :
503
+ if isinstance ( lookup , KVStoreLookup ) :
501
504
all_lookups .append (
502
505
{
503
506
"name" : lookup .name ,
504
507
"description" : lookup .description ,
505
508
"collection" : lookup .collection ,
506
509
"case_sensitive_match" : None ,
507
- "fields_list" : lookup .fields_list
510
+ "fields_list" : lookup .fields_to_fields_list_conf_format
508
511
}
509
512
)
510
- elif lookup . filename is not None :
513
+ elif isinstance ( lookup , FileBackedLookup ) :
511
514
all_lookups .append (
512
515
{
513
516
"name" : lookup .name ,
514
517
"description" : lookup .description ,
515
518
"filename" : lookup .filename .name ,
516
519
"default_match" : "true" if lookup .default_match else "false" ,
517
520
"case_sensitive_match" : "true" if lookup .case_sensitive_match else "false" ,
518
- "match_type" : lookup .match_type ,
519
- "min_matches" : lookup .min_matches ,
520
- "fields_list" : lookup .fields_list
521
+ "match_type" : lookup .match_type_to_conf_format ,
522
+ "min_matches" : lookup .min_matches
521
523
}
522
524
)
523
525
model ['lookups' ] = all_lookups # type: ignore
@@ -790,7 +792,7 @@ def ensureProperRBAConfig(self):
790
792
"""
791
793
792
794
793
- if self .deployment .alert_action .rba . enabled is False or self .deployment .alert_action .rba is None :
795
+ if self .deployment .alert_action .rba is None or self .deployment .alert_action .rba . enabled is False :
794
796
# confirm we don't have an RBA config
795
797
if self .rba is None :
796
798
return self
0 commit comments