Skip to content

Commit 0f53c69

Browse files
authored
Merge pull request #345 from splunk/integration_testing_rba_migration
Migrate integration testing to RBA paradigm - Step 2
2 parents da39152 + 1de20e8 commit 0f53c69

File tree

7 files changed

+171
-224
lines changed

7 files changed

+171
-224
lines changed

contentctl/actions/detection_testing/infrastructures/DetectionTestingInfrastructure.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,7 @@ def retry_search_until_timeout(
10941094
job = self.get_conn().search(query=search, **kwargs)
10951095
results = JSONResultsReader(job.results(output_mode="json"))
10961096

1097+
# TODO (cmcginley): @ljstella you're removing this ultimately, right?
10971098
# Consolidate a set of the distinct observable field names
10981099
observable_fields_set = set([o.name for o in detection.tags.observable]) # keeping this around for later
10991100
risk_object_fields_set = set([o.name for o in detection.tags.observable if "Victim" in o.role ]) # just the "Risk Objects"
@@ -1121,7 +1122,10 @@ def retry_search_until_timeout(
11211122
missing_risk_objects = risk_object_fields_set - results_fields_set
11221123
if len(missing_risk_objects) > 0:
11231124
# Report a failure in such cases
1124-
e = Exception(f"The observable field(s) {missing_risk_objects} are missing in the detection results")
1125+
e = Exception(
1126+
f"The risk object field(s) {missing_risk_objects} are missing in the "
1127+
"detection results"
1128+
)
11251129
test.result.set_job_content(
11261130
job.content,
11271131
self.infrastructure,
@@ -1137,6 +1141,8 @@ def retry_search_until_timeout(
11371141
# on a field. In this case, the field will appear but will not contain any values
11381142
current_empty_fields: set[str] = set()
11391143

1144+
# TODO (cmcginley): @ljstella is this something we're keeping for testing as
1145+
# well?
11401146
for field in observable_fields_set:
11411147
if result.get(field, 'null') == 'null':
11421148
if field in risk_object_fields_set:

contentctl/objects/constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
"Actions on Objectives": 7
8080
}
8181

82+
# TODO (cmcginley): @ljstella should this be removed? also referenced in new_content.py
8283
SES_OBSERVABLE_ROLE_MAPPING = {
8384
"Other": -1,
8485
"Unknown": 0,
@@ -93,6 +94,7 @@
9394
"Observer": 9
9495
}
9596

97+
# TODO (cmcginley): @ljstella should this be removed? also referenced in new_content.py
9698
SES_OBSERVABLE_TYPE_MAPPING = {
9799
"Unknown": 0,
98100
"Hostname": 1,
@@ -135,6 +137,7 @@
135137
"Impact": "TA0040"
136138
}
137139

140+
# TODO (cmcginley): is this just for the transition testing?
138141
RBA_OBSERVABLE_ROLE_MAPPING = {
139142
"Attacker": 0,
140143
"Victim": 1

contentctl/objects/correlation_search.py

Lines changed: 68 additions & 74 deletions
Large diffs are not rendered by default.

contentctl/objects/detection_tags.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
from pydantic import (
55
BaseModel,
66
Field,
7-
NonNegativeInt,
8-
PositiveInt,
97
computed_field,
108
UUID4,
119
HttpUrl,
@@ -34,25 +32,26 @@
3432
from contentctl.objects.atomic import AtomicEnrichment, AtomicTest
3533
from contentctl.objects.annotated_types import MITRE_ATTACK_ID_TYPE, CVE_TYPE
3634

35+
3736
class DetectionTags(BaseModel):
3837
# detection spec
3938

4039
model_config = ConfigDict(validate_default=False, extra='forbid')
4140
analytic_story: list[Story] = Field(...)
4241
asset_type: AssetType = Field(...)
4342
group: list[str] = []
44-
43+
4544
mitre_attack_id: List[MITRE_ATTACK_ID_TYPE] = []
4645
nist: list[NistCategory] = []
4746

47+
# TODO (cmcginley): observable should be removed as well, yes?
4848
# TODO (#249): Add pydantic validator to ensure observables are unique within a detection
4949
observable: List[Observable] = []
5050
product: list[SecurityContentProductName] = Field(..., min_length=1)
5151
throttling: Optional[Throttling] = None
5252
security_domain: SecurityDomain = Field(...)
5353
cve: List[CVE_TYPE] = []
5454
atomic_guid: List[AtomicTest] = []
55-
5655

5756
# enrichment
5857
mitre_attack_enrichments: List[MitreAttackEnrichment] = Field([], validate_default=True)
@@ -84,7 +83,7 @@ def cis20(self) -> list[Cis18Value]:
8483

8584
# TODO (#268): Validate manual_test has length > 0 if not None
8685
manual_test: Optional[str] = None
87-
86+
8887
# The following validator is temporarily disabled pending further discussions
8988
# @validator('message')
9089
# def validate_message(cls,v,values):

contentctl/objects/drilldown.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class Drilldown(BaseModel):
2323
"but it is NOT the default value and must be supplied explicitly.",
2424
min_length= 1)
2525

26+
# TODO (cmcginley): @ljstella the drilldowns will need to be updated
2627
@classmethod
2728
def constructDrilldownsFromDetection(cls, detection: Detection) -> list[Drilldown]:
2829
victim_observables = [o for o in detection.tags.observable if o.role[0] == "Victim"]

contentctl/objects/observable.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from pydantic import BaseModel, field_validator, ConfigDict
22
from contentctl.objects.constants import SES_OBSERVABLE_TYPE_MAPPING, RBA_OBSERVABLE_ROLE_MAPPING
33

4+
# TODO (cmcginley): should this class be removed?
45

56
class Observable(BaseModel):
67
model_config = ConfigDict(extra="forbid")

0 commit comments

Comments
 (0)