Skip to content

Commit 9b158ce

Browse files
initial commit; migrated integration testing to RBA structures; littered code w/ comments for cleanup before merge
1 parent 285acf1 commit 9b158ce

File tree

9 files changed

+175
-209
lines changed

9 files changed

+175
-209
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/abstract_security_content_objects/detection_abstract.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ def source(self) -> str:
279279

280280
deployment: Deployment = Field({})
281281

282+
# TODO (cmcginley): @ljstella removing the refs to confidence and impact?
282283
@computed_field
283284
@property
284285
def annotations(self) -> dict[str, Union[List[str], int, str]]:

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: 69 additions & 68 deletions
Large diffs are not rendered by default.

contentctl/objects/detection_tags.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,17 @@ class DetectionTags(BaseModel):
4242
analytic_story: list[Story] = Field(...)
4343
asset_type: AssetType = Field(...)
4444
group: list[str] = []
45+
46+
# TODO (cmcginley): should confidence, impact and the risk_score property be removed?
4547
confidence: NonNegativeInt = Field(...,le=100)
4648
impact: NonNegativeInt = Field(...,le=100)
4749
@computed_field
4850
@property
4951
def risk_score(self) -> int:
5052
return round((self.confidence * self.impact)/100)
51-
53+
54+
# TODO (cmcginley): @ljstella what's happening w/ severity, given it's use of the top-level
55+
# risk_score?
5256
@computed_field
5357
@property
5458
def severity(self)->RiskSeverity:
@@ -69,14 +73,14 @@ def severity(self)->RiskSeverity:
6973
mitre_attack_id: List[MITRE_ATTACK_ID_TYPE] = []
7074
nist: list[NistCategory] = []
7175

76+
# TODO (cmcginley): observable should be removed as well, yes?
7277
# TODO (#249): Add pydantic validator to ensure observables are unique within a detection
7378
observable: List[Observable] = []
7479
product: list[SecurityContentProductName] = Field(..., min_length=1)
7580
throttling: Optional[Throttling] = None
7681
security_domain: SecurityDomain = Field(...)
7782
cve: List[CVE_TYPE] = []
7883
atomic_guid: List[AtomicTest] = []
79-
8084

8185
# enrichment
8286
mitre_attack_enrichments: List[MitreAttackEnrichment] = Field([], validate_default=True)
@@ -144,6 +148,7 @@ def cis20(self) -> list[Cis18Value]:
144148
# )
145149
# return v
146150

151+
# TODO (cmcginley): @ljstella removing risk_score and severity from serialization?
147152
@model_serializer
148153
def serialize_model(self):
149154
# Since this field has no parent, there is no need to call super() serialization function

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")

contentctl/objects/rba.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class ThreatObjectType(str, Enum):
3838
TLS_HASH = "tls_hash"
3939
URL = "url"
4040

41+
# TODO (cmcginley): class names should be capitalized
4142
class risk_object(BaseModel):
4243
field: str
4344
type: RiskObjectType

0 commit comments

Comments
 (0)