Skip to content

Commit 4f192d4

Browse files
cleanup; resolving comments
1 parent ae320d7 commit 4f192d4

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

contentctl/actions/detection_testing/infrastructures/DetectionTestingInfrastructure.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,12 +369,6 @@ def execute(self):
369369
return
370370

371371
try:
372-
# NOTE: (THIS CODE HAS MOVED) we handle skipping entire detections differently than
373-
# we do skipping individual test cases; we skip entire detections by excluding
374-
# them to an entirely separate queue, while we skip individual test cases via the
375-
# BaseTest.skip() method, such as when we are skipping all integration tests (see
376-
# DetectionBuilder.skipIntegrationTests)
377-
# TODO: are we skipping by production status elsewhere?
378372
detection = self.sync_obj.inputQueue.pop()
379373
self.sync_obj.currentTestingQueue[self.get_name()] = detection
380374
except IndexError:

contentctl/objects/correlation_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333

3434
# Suppress logging by default; enable for local testing
35-
ENABLE_LOGGING = True
35+
ENABLE_LOGGING = False
3636
LOG_LEVEL = logging.DEBUG
3737
LOG_PATH = "correlation_search.log"
3838

contentctl/objects/risk_event.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import re
2-
from typing import Union, Optional
32

43
from pydantic import BaseModel, Field, PrivateAttr, field_validator, computed_field
54

65
from contentctl.objects.errors import ValidationFailed
76
from contentctl.objects.detection import Detection
87
from contentctl.objects.observable import Observable
98

9+
# TODO (#259): Map our observable types to more than user/system
1010
# TODO (#247): centralize this mapping w/ usage of SES_OBSERVABLE_TYPE_MAPPING (see
1111
# observable.py) and the ad hoc mapping made in detection_abstract.py (see the risk property func)
1212
TYPE_MAP: dict[str, list[str]] = {
@@ -55,7 +55,7 @@ class RiskEvent(BaseModel):
5555
search_name: str
5656

5757
# The subject of the risk event (e.g. a username, process name, system name, account ID, etc.)
58-
risk_object: Union[int, str]
58+
risk_object: int | str
5959

6060
# The type of the risk object (e.g. user, system, or other)
6161
risk_object_type: str
@@ -83,7 +83,7 @@ class RiskEvent(BaseModel):
8383
contributing_events_search: str
8484

8585
# Private attribute caching the observable this RiskEvent is mapped to
86-
_matched_observable: Optional[Observable] = PrivateAttr(default=None)
86+
_matched_observable: Observable | None = PrivateAttr(default=None)
8787

8888
class Config:
8989
# Allowing fields that aren't explicitly defined to be passed since some of the risk event's
@@ -92,7 +92,7 @@ class Config:
9292

9393
@field_validator("annotations_mitre_attack", "analyticstories", mode="before")
9494
@classmethod
95-
def _convert_str_value_to_singleton(cls, v: Union[str, list[str]]) -> list[str]:
95+
def _convert_str_value_to_singleton(cls, v: str | list[str]) -> list[str]:
9696
"""
9797
Given a value, determine if its a list or a single str value; if a single value, return as a
9898
singleton. Do nothing if anything else.
@@ -272,17 +272,13 @@ def ignore_observable(observable: Observable) -> bool:
272272
:param observable: the Observable object we are checking the roles of
273273
:returns: a bool indicating whether this observable should be ignored or not
274274
"""
275-
# TODO (cmcginley): could there be a case where an observable has both an Attacker and
276-
# Victim (or equivalent) role? If so, how should we handle ignoring it?
277275
ignore = False
278276
for role in observable.role:
279277
if role in IGNORE_ROLES:
280278
ignore = True
281279
break
282280
return ignore
283281

284-
# TODO: pull field to match against from `contributing_events_search` -> the field they are
285-
# keying off of is the field related to the observable
286282
def get_matched_observable(self, observables: list[Observable]) -> Observable:
287283
"""
288284
Given a list of observables, return the one this risk event matches
@@ -295,7 +291,7 @@ def get_matched_observable(self, observables: list[Observable]) -> Observable:
295291
if self._matched_observable is not None:
296292
return self._matched_observable
297293

298-
matched_observable: Optional[Observable] = None
294+
matched_observable: Observable | None = None
299295

300296
# Iterate over the obervables and check for a match
301297
for observable in observables:

0 commit comments

Comments
 (0)