-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: validation of detections against cms_main #303
base: main
Are you sure you want to change the base?
Conversation
…ing should be enforced
…com/splunk/contentctl into feature/validation_against_cms_main
This reverts commit b3c6948.
contentctl/actions/detection_testing/infrastructures/DetectionTestingInfrastructure.py
Show resolved
Hide resolved
contentctl/actions/detection_testing/infrastructures/DetectionTestingInfrastructure.py
Show resolved
Hide resolved
contentctl/actions/detection_testing/infrastructures/DetectionTestingInfrastructure.py
Show resolved
Hide resolved
return bool(int(entry["content"]["versioning_activated"])) | ||
except KeyError as e: | ||
raise KeyError( | ||
"Cannot retrieve versioning status, unable to versioning status using the expected " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very minor typo here. I assume it is Unable to determine versioning status
instead of unable to versioning status
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
|
||
def force_cms_parser(self) -> None: | ||
""" | ||
Force the cms_parser to being it's run being disabling and re-enabling it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The is probably a typo in here.
Can you give alittle more context about why this function exists? I think this is supposed to say something like
Force the cms_parser to run by disabling and re-enabling it. This is a hack to get the cms_parser to run on-demand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another good catch haha. not sure how that got so garbled lol
f"[{self.infrastructure.instance_name}] {offset}: Matching cms_main entry " | ||
f"'{cms_entry_name}' against detections" | ||
) | ||
ptrn = re.compile(r"^" + self.global_config.app.label + r" - (?P<stripped_cms_entry_name>.+) - Rule$") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it's better to go in reverse now that we have the following function to generate a search name:
contentctl/contentctl/objects/abstract_security_content_objects/detection_abstract.py
Line 101 in 98573b0
def get_action_dot_correlationsearch_dot_label(self, app:CustomApp, max_stanza_length:int=ES_MAX_STANZA_LENGTH)->str: |
This also means if we change the template used in the link above to generate the detection name, we don't have to change it again in this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhhhh I don't think I knew about this function, I'll take a look!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is FAIRLY new. In the future, it might be a nice idea to actually associate the app config with a detection so that we don't have to carry/pass it around, making action_dot_correlationsearch_dot_label
a cached_property instead of a function that takes an argument.
# TODO (PEX-509): validate additional fields between the cms_event and the detection | ||
|
||
cms_uuid = uuid.UUID(cms_event["detection_id"]) | ||
rule_name_from_detection = f"{self.global_config.app.label} - {detection.name} - Rule" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See a similar comment above about how we compose the name of the detection.
Context
Code change
ContentVersioningService
cms_main
and detections based on YAMLs matchcms_event
cms_event
can be matched to a detectioncms_event
is repeatedDetectionTestingInfrastructure
raise
any exceptions that crop up during setup, instead of just logging themDetectionTestingInfrastructure
to query installed ES version, so we can determine when it is appropriate to run content versioning validationAll
CorrelationSearch
(useful for debugging) tohelper.utils.Utils
so it could be re-used inContentVersioningService
Testing
savedsearches.conf
file and all seems to work wellescu-production
and all results passed (see attached truncated log)content_versioning_service.log
Caveats
cms_main
index should happen in aggregate, a test of the whole package, not individual detections. We do not have an easy way to insert testing at that level presently.TODOs