-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Security Solutions] Adds back the legacy actions and notification system in a limited fashion #112869
[Security Solutions] Adds back the legacy actions and notification system in a limited fashion #112869
Conversation
Pinging @elastic/security-detections-response (Team:Detections and Resp) |
Pinging @elastic/security-solution (Team: SecuritySolution) |
...urity_solution/server/lib/detection_engine/routes/rules/legacy_create_legacy_notification.ts
Outdated
Show resolved
Hide resolved
...y_solution/server/lib/detection_engine/notifications/legacy_rules_notification_alert_type.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/server/lib/detection_engine/rules/utils.ts
Show resolved
Hide resolved
x-pack/plugins/security_solution/server/lib/detection_engine/rules/utils.ts
Show resolved
Hide resolved
x-pack/plugins/security_solution/server/lib/detection_engine/schemas/rule_converters.ts
Show resolved
Hide resolved
x-pack/plugins/security_solution/server/lib/detection_engine/rules/utils.ts
Show resolved
Hide resolved
x-pack/plugins/security_solution/server/lib/detection_engine/rules/utils.ts
Outdated
Show resolved
Hide resolved
@@ -25,6 +26,7 @@ export type SecuritySolutionRequestHandlerContext = RequestHandlerContext & { | |||
securitySolution: AppRequestContext; | |||
licensing: LicensingApiRequestHandlerContext; | |||
alerting: AlertingApiRequestHandlerContext; | |||
actions: ActionsApiRequestHandlerContext; |
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.
NOTE: These are "extra's" and not needed for this PR but I figured since I added 'em I should keep 'em since we have them in the plugins and we might use them later on.
...ecurity_solution/server/lib/detection_engine/notifications/legacy_read_notifications.test.ts
Outdated
Show resolved
Hide resolved
...ins/security_solution/server/lib/detection_engine/notifications/legacy_read_notifications.ts
Show resolved
Hide resolved
...y_solution/server/lib/detection_engine/notifications/legacy_rules_notification_alert_type.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/utils.test.ts
Show resolved
Hide resolved
x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/utils.test.ts
Show resolved
Hide resolved
x-pack/plugins/security_solution/server/lib/detection_engine/rule_actions/legacy_types.ts
Show resolved
Hide resolved
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.
Thanks so much for working to add this back in, making it work with the new actions as well. Did a good amount of testing together over zoom, but also went ahead and tested manually later as well.
Tested actions in 7.14 to understand the legacy system and any existing oddities. Tested this PR with new actions.
Big thanks to @dhurley14 who tested the migration itself. There was one thing that Devin noted that I think is worth writing an issue to follow up with alerting on.
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.
One comment about expanding on when exactly we can remove references to the legacy
functions as a part of their @deprecated
message. Another comment about ensuring error handling is accounted for when attempting to acquire the actions as part of the find_rules_route. Other than that, thank you @FrankHassanabad for taking the time to walk me through this and helping facilitate testing this functionality. LGTM!
...ins/security_solution/server/lib/detection_engine/notifications/legacy_find_notifications.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/find_rules_route.ts
Show resolved
Hide resolved
💛 Build succeeded, but was flaky
Test FailuresKibana Pipeline / general / License plugin API Integration Tests.x-pack/test/licensing_plugin/server/updates·ts.Licensing plugin server client changes in license types provides changes in license typesStandard Out
Stack Trace
Metrics [docs]
History
To update your PR or re-run it, just comment with: |
…stem in a limited fashion (elastic#112869) ## Summary Fixes elastic/security-team#1759 Related earlier PR, elastic#109722, where these were removed to where they could no longer function. This PR adds them back to where they will function for existing users. The end goal is to have users naturally migrate as they update, enable/disable, or create new rules. What this PR does: * Adds back the legacy side car actions `siem-detection-engine-rule-actions` * Adds back the legacy hidden alert of `siem.notifications` * Adds back unit tests where they existed. Both of these systems did not have existing e2e tests. * Re-adds the find feature and functionality which should show the rules with legacy and non-legacy notifications/side car actions during a REST find operation. * Updates the logic for when to show a legacy vs. non-legacy notification/side car action. * Adds a new route called `/internal/api/detection/legacy/notifications` which is only for developer and tests for us to maintain this system for the foreseeable future. * Adds script to exercise creating old notifications `detection_engine/scripts/post_legacy_notification.sh` * Adds a data file for the script to use as an example for ad-hoc testing, `scripts/legacy_notifications/one_action.json` * Adds within `security_solution/server/types.ts` `ActionsApiRequestHandlerContext` so that if we need to directly access actions within plugins we can. I do not use it here, but it should have been existing there and is good to have it in case we need it at this point within REST routes. * When adding back the files and changes, I use the kibana-core approach of prefixing files, functions, types, etc... with the words `legacyFoo`. The files are named `legacy_foo.ts`. Everything has `@deprecation` above them as well. The intent here is all of this should hopefully make it unambiguously clear which parts of the notification system are for the new system/existing API and which ones are only for the deprecated legacy system. There exists some parts of the system that are used within _both_ and the hope is that we can keep the legacy pieces separate from the non-legacy pieces for strangling the legacy pieces. * This adds a new linter rule to prevent users from easily importing files named `legacy_foo.ts` or `foo_legacy.ts` we are using here and can also use for other similar legacy parts of the system we have. This seems to be the established pattern that kibana-core does as well looking through the linters and code base. * Removes some dead import/export code and types instead of maintaining them since they are no longer used. What this PR does not do (but are planned on follow ups): * This PR does not add migration logic in most conditions such as a user enabling/disabling a rule, editing a rule unless the user is explicitly changing the actions by turning off the notification and then re-adding the notification. * This PR does not log any information indicating to the user that they are running legacy rules or indicates they have that. * This PR does not allow the executors or any UI/UX, backend to re-add a legacy notification. Instead only the hidden REST route of `/internal/api/detection/legacy/notifications` allows us to do this for testing purposes. * This PR does not migrate the data structure of actions legacy notification system `siem-detection-engine-rule-actions` to use saved object references. * If you delete an alert this will not delete the side car if it detects one is present on it. * If you update an alert notification with a new notification this will not remove the side car on the update. **Ad-hoc testing instructions** How to do ad-hoc testing for various situations such as having a legacy notification system such as a user's or if you want to mimic a malfunction and result of a "split-brain" to where you have both notification systems running at the same time due to a bug or regression: Create a rule and activate it normally within security_solution: <img width="1046" alt="Screen Shot 2021-09-22 at 2 09 14 PM" src="https://user-images.githubusercontent.com/1151048/134416564-e4e001a7-1086-46a1-aa8d-79880f70cc35.png"> Do not add actions to the rule at this point as we will first exercise the older legacy system. However, you want at least one action configured such as a slack notification: <img width="575" alt="Screen Shot 2021-09-22 at 2 28 16 PM" src="https://user-images.githubusercontent.com/1151048/134417012-58e63709-5447-4832-8866-f82be1b9596b.png"> Within dev tools do a query for all your actions and grab one of the `_id` of them without their prefix: ```json # See all your actions GET .kibana/_search { "query": { "term": { "type": "action" } } } ``` Mine was `"_id" : "action:879e8ff0-1be1-11ec-a722-83da1c22a481",` so I will be copying the ID of `879e8ff0-1be1-11ec-a722-83da1c22a481` Go to the file `detection_engine/scripts/legacy_notifications/one_action.json` and add this id to the file. Something like this: ```json { "name": "Legacy notification with one action", "interval": "1m", <--- You can use whatever you want. Real values are "1h", "1d", "1w". I use "1m" for testing purposes. "actions": [ { "id": "879e8ff0-1be1-11ec-a722-83da1c22a481", <--- My action id "group": "default", "params": { "message": "Hourly\nRule {{context.rule.name}} generated {{state.signals_count}} alerts" }, "actionTypeId": ".slack" <--- I am a slack action id type. } ] } ``` Query for an alert you want to add manually add back a legacy notification to it. Such as: ```json # See all your siem.signals alert types and choose one GET .kibana/_search { "query": { "term": { "alert.alertTypeId": "siem.signals" } } } ``` Grab the `_id` without the `alert` prefix. For mine this was `933ca720-1be1-11ec-a722-83da1c22a481` Within the directory of `detection_engine/scripts` execute the script ```bash ./post_legacy_notification.sh 933ca720-1be1-11ec-a722-83da1c22a481 { "ok": "acknowledged" } ``` which is going to do a few things. See the file `detection_engine/routes/rules/legacy_create_legacy_notification.ts` for the definition of the route and what it does in full, but we should notice that we have now: Created a legacy side car action object of type `siem-detection-engine-rule-actions` you can see in dev tools: ```json # See the actions "side car" which are part of the legacy notification system. GET .kibana/_search { "query": { "term": { "type": { "value": "siem-detection-engine-rule-actions" } } } } ``` Note in the response: ```json "siem-detection-engine-rule-actions" : { "ruleAlertId" : "933ca720-1be1-11ec-a722-83da1c22a481", <--- NOTE, not migrated to references yet "actions" : [ { "action_type_id" : ".slack", "id" : "879e8ff0-1be1-11ec-a722-83da1c22a481", <--- NOTE, not migrated to references yet "params" : { "message" : "Hourly\nRule {{context.rule.name}} generated {{state.signals_count}} alerts" }, "group" : "default" } ], "ruleThrottle" : "1m", <--- Should be the same as the interval in "one_action.json" config "alertThrottle" : "1m" <--- Should be the same as the interval in "one_action.json" config }, "type" : "siem-detection-engine-rule-actions", "references" : [ ], ``` Created a `siem.notification` rule instance which you can see in dev tools as well: ```json # Get the alert type of "siem-notifications" which is part of the legacy system. GET .kibana/_search { "query": { "term": { "alert.alertTypeId": "siem.notifications" } } } ``` Take note from the `siem.notifications` these values which determine how/when it fires and if your actions are set up correctly: ```json "name" : "Legacy notification with one action" <--- Our name from one_action.json "schedule" : { "interval" : "1m" <--- Interval should match interval in one_action.json }, "enabled" : true, <--- We should be enabled "actions" : [ { "group" : "default", "params" : { "message" : "Hourly\nRule {{context.rule.name}} generated {{state.signals_count}} alerts" }, "actionTypeId" : ".slack", <--- Our actionID "actionRef" : "action_0" } ], ``` And that now there exists a task within task manager that will be executing this: ```json # Get the tasks of siem notifications to ensure and see it is running GET .task-manager/_search { "query": { "term": { "task.taskType": "alerting:siem.notifications" } } } ``` You can double check the interval from the result of the query to ensure it runs as the configuration test file shows it should be: ```json "schedule" : { "interval" : "1m" }, ``` Within time you should see your action execute like the legacy notification system: <img width="876" alt="Screen Shot 2021-09-22 at 2 55 28 PM" src="https://user-images.githubusercontent.com/1151048/134422639-80523abb-f43c-4f7c-abef-a60062bef139.png"> If you go to edit the rule you should notice that the rule now has the side car attached to it within the UI: <img width="1050" alt="Screen Shot 2021-09-22 at 8 08 54 PM" src="https://user-images.githubusercontent.com/1151048/134445265-fa0a330b-3238-48e2-aef3-6042c7e9aa69.png"> You can also look at your log messages in debug mode to verify the behaviors of the legacy system and the normal rules running. Compare these data structures to a 7.14.x system in cloud to ensure the data looks the same and the ad-hoc testing functions as expected. Check the scripts of `./find_rules.sh`, `./read_rules.sh` to ensure that the find REST route returns the legacy actions when they are there. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
…stem in a limited fashion (#112869) (#113202) ## Summary Fixes elastic/security-team#1759 Related earlier PR, #109722, where these were removed to where they could no longer function. This PR adds them back to where they will function for existing users. The end goal is to have users naturally migrate as they update, enable/disable, or create new rules. What this PR does: * Adds back the legacy side car actions `siem-detection-engine-rule-actions` * Adds back the legacy hidden alert of `siem.notifications` * Adds back unit tests where they existed. Both of these systems did not have existing e2e tests. * Re-adds the find feature and functionality which should show the rules with legacy and non-legacy notifications/side car actions during a REST find operation. * Updates the logic for when to show a legacy vs. non-legacy notification/side car action. * Adds a new route called `/internal/api/detection/legacy/notifications` which is only for developer and tests for us to maintain this system for the foreseeable future. * Adds script to exercise creating old notifications `detection_engine/scripts/post_legacy_notification.sh` * Adds a data file for the script to use as an example for ad-hoc testing, `scripts/legacy_notifications/one_action.json` * Adds within `security_solution/server/types.ts` `ActionsApiRequestHandlerContext` so that if we need to directly access actions within plugins we can. I do not use it here, but it should have been existing there and is good to have it in case we need it at this point within REST routes. * When adding back the files and changes, I use the kibana-core approach of prefixing files, functions, types, etc... with the words `legacyFoo`. The files are named `legacy_foo.ts`. Everything has `@deprecation` above them as well. The intent here is all of this should hopefully make it unambiguously clear which parts of the notification system are for the new system/existing API and which ones are only for the deprecated legacy system. There exists some parts of the system that are used within _both_ and the hope is that we can keep the legacy pieces separate from the non-legacy pieces for strangling the legacy pieces. * This adds a new linter rule to prevent users from easily importing files named `legacy_foo.ts` or `foo_legacy.ts` we are using here and can also use for other similar legacy parts of the system we have. This seems to be the established pattern that kibana-core does as well looking through the linters and code base. * Removes some dead import/export code and types instead of maintaining them since they are no longer used. What this PR does not do (but are planned on follow ups): * This PR does not add migration logic in most conditions such as a user enabling/disabling a rule, editing a rule unless the user is explicitly changing the actions by turning off the notification and then re-adding the notification. * This PR does not log any information indicating to the user that they are running legacy rules or indicates they have that. * This PR does not allow the executors or any UI/UX, backend to re-add a legacy notification. Instead only the hidden REST route of `/internal/api/detection/legacy/notifications` allows us to do this for testing purposes. * This PR does not migrate the data structure of actions legacy notification system `siem-detection-engine-rule-actions` to use saved object references. * If you delete an alert this will not delete the side car if it detects one is present on it. * If you update an alert notification with a new notification this will not remove the side car on the update. **Ad-hoc testing instructions** How to do ad-hoc testing for various situations such as having a legacy notification system such as a user's or if you want to mimic a malfunction and result of a "split-brain" to where you have both notification systems running at the same time due to a bug or regression: Create a rule and activate it normally within security_solution: <img width="1046" alt="Screen Shot 2021-09-22 at 2 09 14 PM" src="https://user-images.githubusercontent.com/1151048/134416564-e4e001a7-1086-46a1-aa8d-79880f70cc35.png"> Do not add actions to the rule at this point as we will first exercise the older legacy system. However, you want at least one action configured such as a slack notification: <img width="575" alt="Screen Shot 2021-09-22 at 2 28 16 PM" src="https://user-images.githubusercontent.com/1151048/134417012-58e63709-5447-4832-8866-f82be1b9596b.png"> Within dev tools do a query for all your actions and grab one of the `_id` of them without their prefix: ```json # See all your actions GET .kibana/_search { "query": { "term": { "type": "action" } } } ``` Mine was `"_id" : "action:879e8ff0-1be1-11ec-a722-83da1c22a481",` so I will be copying the ID of `879e8ff0-1be1-11ec-a722-83da1c22a481` Go to the file `detection_engine/scripts/legacy_notifications/one_action.json` and add this id to the file. Something like this: ```json { "name": "Legacy notification with one action", "interval": "1m", <--- You can use whatever you want. Real values are "1h", "1d", "1w". I use "1m" for testing purposes. "actions": [ { "id": "879e8ff0-1be1-11ec-a722-83da1c22a481", <--- My action id "group": "default", "params": { "message": "Hourly\nRule {{context.rule.name}} generated {{state.signals_count}} alerts" }, "actionTypeId": ".slack" <--- I am a slack action id type. } ] } ``` Query for an alert you want to add manually add back a legacy notification to it. Such as: ```json # See all your siem.signals alert types and choose one GET .kibana/_search { "query": { "term": { "alert.alertTypeId": "siem.signals" } } } ``` Grab the `_id` without the `alert` prefix. For mine this was `933ca720-1be1-11ec-a722-83da1c22a481` Within the directory of `detection_engine/scripts` execute the script ```bash ./post_legacy_notification.sh 933ca720-1be1-11ec-a722-83da1c22a481 { "ok": "acknowledged" } ``` which is going to do a few things. See the file `detection_engine/routes/rules/legacy_create_legacy_notification.ts` for the definition of the route and what it does in full, but we should notice that we have now: Created a legacy side car action object of type `siem-detection-engine-rule-actions` you can see in dev tools: ```json # See the actions "side car" which are part of the legacy notification system. GET .kibana/_search { "query": { "term": { "type": { "value": "siem-detection-engine-rule-actions" } } } } ``` Note in the response: ```json "siem-detection-engine-rule-actions" : { "ruleAlertId" : "933ca720-1be1-11ec-a722-83da1c22a481", <--- NOTE, not migrated to references yet "actions" : [ { "action_type_id" : ".slack", "id" : "879e8ff0-1be1-11ec-a722-83da1c22a481", <--- NOTE, not migrated to references yet "params" : { "message" : "Hourly\nRule {{context.rule.name}} generated {{state.signals_count}} alerts" }, "group" : "default" } ], "ruleThrottle" : "1m", <--- Should be the same as the interval in "one_action.json" config "alertThrottle" : "1m" <--- Should be the same as the interval in "one_action.json" config }, "type" : "siem-detection-engine-rule-actions", "references" : [ ], ``` Created a `siem.notification` rule instance which you can see in dev tools as well: ```json # Get the alert type of "siem-notifications" which is part of the legacy system. GET .kibana/_search { "query": { "term": { "alert.alertTypeId": "siem.notifications" } } } ``` Take note from the `siem.notifications` these values which determine how/when it fires and if your actions are set up correctly: ```json "name" : "Legacy notification with one action" <--- Our name from one_action.json "schedule" : { "interval" : "1m" <--- Interval should match interval in one_action.json }, "enabled" : true, <--- We should be enabled "actions" : [ { "group" : "default", "params" : { "message" : "Hourly\nRule {{context.rule.name}} generated {{state.signals_count}} alerts" }, "actionTypeId" : ".slack", <--- Our actionID "actionRef" : "action_0" } ], ``` And that now there exists a task within task manager that will be executing this: ```json # Get the tasks of siem notifications to ensure and see it is running GET .task-manager/_search { "query": { "term": { "task.taskType": "alerting:siem.notifications" } } } ``` You can double check the interval from the result of the query to ensure it runs as the configuration test file shows it should be: ```json "schedule" : { "interval" : "1m" }, ``` Within time you should see your action execute like the legacy notification system: <img width="876" alt="Screen Shot 2021-09-22 at 2 55 28 PM" src="https://user-images.githubusercontent.com/1151048/134422639-80523abb-f43c-4f7c-abef-a60062bef139.png"> If you go to edit the rule you should notice that the rule now has the side car attached to it within the UI: <img width="1050" alt="Screen Shot 2021-09-22 at 8 08 54 PM" src="https://user-images.githubusercontent.com/1151048/134445265-fa0a330b-3238-48e2-aef3-6042c7e9aa69.png"> You can also look at your log messages in debug mode to verify the behaviors of the legacy system and the normal rules running. Compare these data structures to a 7.14.x system in cloud to ensure the data looks the same and the ad-hoc testing functions as expected. Check the scripts of `./find_rules.sh`, `./read_rules.sh` to ensure that the find REST route returns the legacy actions when they are there. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios Co-authored-by: Frank Hassanabad <frank.hassanabad@elastic.co>
…ation rule types to write default alerts-as-data docs (#174553) Towards elastic/response-ops-team#164 Resolves #171795 ## Summary * Switches this rule type to use `alertsClient` from alerting framework in favor of the deprecated `alertFactory` * Defines the `default` alert config for these rule types so framework level fields will be written out into the `.alerts-default.alerts-default` index with no rule type specific fields. * Updated some terminology from `alert` to `rule` ## To Verify * Follow the instructions in [this PR](#112869) to add a legacy notification to a detection rule. * Verify the notification fires as expected * Verify an alert document is written to `.alerts-default.alerts-default` that looks like: ``` { "kibana.alert.rule.category": "Security Solution notification (Legacy)", "kibana.alert.rule.consumer": "siem", "kibana.alert.rule.execution.uuid": "cbad59ec-2a6e-4791-81c3-ae0fefd3d48a", "kibana.alert.rule.name": "Legacy notification with one action", "kibana.alert.rule.parameters": { "ruleAlertId": "9c07db42-b5fa-4ef9-8d7e-48d5688fd88e" }, "kibana.alert.rule.producer": "siem", "kibana.alert.rule.rule_type_id": "siem.notifications", "kibana.alert.rule.tags": [], "kibana.alert.rule.uuid": "1869763e-c6e7-47fd-8275-0c9568127d84", "kibana.space_ids": [ "default" ], "@timestamp": "2024-01-10T18:12:02.433Z", "event.action": "close", "event.kind": "signal", "kibana.alert.action_group": "recovered", "kibana.alert.flapping_history": [ true, true, false, false ], "kibana.alert.instance.id": "1869763e-c6e7-47fd-8275-0c9568127d84", "kibana.alert.maintenance_window_ids": [], "kibana.alert.status": "recovered", "kibana.alert.uuid": "119269e0-a767-43c9-b383-a8840b4dddd5", "kibana.alert.workflow_status": "open", "kibana.alert.start": "2024-01-10T18:08:53.373Z", "kibana.alert.time_range": { "gte": "2024-01-10T18:08:53.373Z", "lte": "2024-01-10T18:09:56.367Z" }, "kibana.version": "8.13.0", "tags": [], "kibana.alert.duration.us": 62994000, "kibana.alert.end": "2024-01-10T18:09:56.367Z", "kibana.alert.rule.revision": 0, "kibana.alert.flapping": false } ``` --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Summary
Fixes https://github.com/elastic/security-team/issues/1759
Related earlier PR, #109722, where these were removed to where they could no longer function. This PR adds them back to where they will function for existing users. The end goal is to have users naturally migrate as they update, enable/disable, or create new rules.
What this PR does:
siem-detection-engine-rule-actions
siem.notifications
/internal/api/detection/legacy/notifications
which is only for developer and tests for us to maintain this system for the foreseeable future.detection_engine/scripts/post_legacy_notification.sh
scripts/legacy_notifications/one_action.json
security_solution/server/types.ts
ActionsApiRequestHandlerContext
so that if we need to directly access actions within plugins we can. I do not use it here, but it should have been existing there and is good to have it in case we need it at this point within REST routes.legacyFoo
. The files are namedlegacy_foo.ts
. Everything has@deprecation
above them as well. The intent here is all of this should hopefully make it unambiguously clear which parts of the notification system are for the new system/existing API and which ones are only for the deprecated legacy system. There exists some parts of the system that are used within both and the hope is that we can keep the legacy pieces separate from the non-legacy pieces for strangling the legacy pieces.legacy_foo.ts
orfoo_legacy.ts
we are using here and can also use for other similar legacy parts of the system we have. This seems to be the established pattern that kibana-core does as well looking through the linters and code base.What this PR does not do (but are planned on follow ups):
/internal/api/detection/legacy/notifications
allows us to do this for testing purposes.siem-detection-engine-rule-actions
to use saved object references.Ad-hoc testing instructions
How to do ad-hoc testing for various situations such as having a legacy notification system such as a user's or if you want to mimic a malfunction and result of a "split-brain" to where you have both notification systems running at the same time due to a bug or regression:
Create a rule and activate it normally within security_solution:
Do not add actions to the rule at this point as we will first exercise the older legacy system. However, you want at least one action configured such as a slack notification:
Within dev tools do a query for all your actions and grab one of the
_id
of them without their prefix:Mine was
"_id" : "action:879e8ff0-1be1-11ec-a722-83da1c22a481",
so I will be copying the ID of879e8ff0-1be1-11ec-a722-83da1c22a481
Go to the file
detection_engine/scripts/legacy_notifications/one_action.json
and add this id to the file. Something like this:Query for an alert you want to add manually add back a legacy notification to it. Such as:
Grab the
_id
without thealert
prefix. For mine this was933ca720-1be1-11ec-a722-83da1c22a481
Within the directory of
detection_engine/scripts
execute the scriptwhich is going to do a few things. See the file
detection_engine/routes/rules/legacy_create_legacy_notification.ts
for the definition of the route and what it does in full, but we should notice that we have now:Created a legacy side car action object of type
siem-detection-engine-rule-actions
you can see in dev tools:Note in the response:
Created a
siem.notification
rule instance which you can see in dev tools as well:Take note from the
siem.notifications
these values which determine how/when it fires and if your actions are set up correctly:And that now there exists a task within task manager that will be executing this:
You can double check the interval from the result of the query to ensure it runs as the configuration test file shows it should be:
Within time you should see your action execute like the legacy notification system:
If you go to edit the rule you should notice that the rule now has the side car attached to it within the UI:
You can also look at your log messages in debug mode to verify the behaviors of the legacy system and the normal rules running.
Compare these data structures to a 7.14.x system in cloud to ensure the data looks the same and the ad-hoc testing functions as expected.
Check the scripts of
./find_rules.sh
,./read_rules.sh
to ensure that the find REST route returns the legacy actions when they are there.Checklist