[Security Solution] Detection rule deprecation feature#259673
Conversation
|
Pinging @elastic/security-detections-response (Team:Detections and Resp) |
|
Pinging @elastic/security-solution (Team: SecuritySolution) |
|
Pinging @elastic/security-detection-rule-management (Team:Detection Rule Management) |
|
|
||
| const ids = request.body?.ids; | ||
|
|
||
| if (ids && ids.length > 0) { |
There was a problem hiding this comment.
Not suggesting to do it now, but in the future we might consider passing rule_ids into the endpoint, since we have them anyways. That way we can avoid branching and duplication here, because both branches would be the same, like:
- Fetch deprecated rules (either all or only for passed
rule_ids) - Fetch installed rules for these
- Merge
There was a problem hiding this comment.
Yeah I don't disagree about the duplication of logic there. The main reason we're passing in id's instead of rule_id's though is to try and protect against the case where 2 rules have the same rule_id's. We've already seen that pop up in an SDH and it's an edge case our existing prebuilt rule workflow routes don't entirely handle because of sole reliance on the rule_id field. It was discussed a bit in the API design doc deciding between the two fields, I initially had it similar to what you describe.
| } | ||
|
|
||
| const ruleIdFilter = ruleIds | ||
| .map((id) => `${PREBUILT_RULE_ASSETS_SO_TYPE}.attributes.rule_id: "${id}"`) |
There was a problem hiding this comment.
Do you think we should request only the latest version of a deprecated asset here? Is it possible that TRADE folks release two versions with "deprecated: true" because they want to add / adjust deprecated_reason, for example. Seems possible.
If we return multiple results for the same rule_id here, then in UI we won't know which one is the latest.
The endpoint would return
{
"rules": [
{
"id": "33cd765b-53ea-4715-92ff-3905988ad87f",
"rule_id": "f41296b4-9975-44d6-9486-514c6f635b2d",
"name": "Potential curl CVE-2023-38545 Exploitation"
},
{
"id": "33cd765b-53ea-4715-92ff-3905988ad87f",
"rule_id": "f41296b4-9975-44d6-9486-514c6f635b2d",
"name": "Potential curl CVE-2023-38545 Exploitation",
"deprecated_reason": "Yo! I'm old." // UI will ignore this message
}
]
}
There was a problem hiding this comment.
Right now, the package building script will only include one object per deprecated rule so we should be protected against this edge case, even when deprecated reasons are added. We will begin using the version field when we integrate into the upgrade table.
| * Max number of deprecated rules returned per request. Conservative limit | ||
| * to protect against unexpected package size. | ||
| */ | ||
| export const MAX_DEPRECATED_RULES_TO_RETURN = 200; |
There was a problem hiding this comment.
Do you think we'll need to get notified if we hit 200 prebuilt rules in the package? How realistic is this? The number can only grow, right? If it's realistic, we can update our OOM package tests later to fail if this limit is hit, so we can either bump the limit or investigate what's wrong with the package.
There was a problem hiding this comment.
Unless something happens like a malformed package, we shouldn't hit this number anytime soon. Right now we have 111 deprecated rule objects in total and that's accumulated over 5+ years. So at least a few years at the current pace, at which point this will be updated and in a more permanent location
| type: BulkActionTypeEnum.delete, | ||
| ids: rules.map((rule) => rule.id), | ||
| }); | ||
| invalidateDeprecationReview(); |
There was a problem hiding this comment.
As I understand, if we call invalidateDeprecationReview() in executeBulkAction anyways, we can skip calling it here and in useDeprecatedRulesTableCallout.
| ids: [rule.id], | ||
| duplicatePayload: { | ||
| include_exceptions: | ||
| duplicateOption === DuplicateOptions.withExceptions || |
There was a problem hiding this comment.
True to its name, this logic is duplicated a few times in different components. I'll create a ticket to later extract it into something like executeDuplicateRuleBulkAction.
nikitaindik
left a comment
There was a problem hiding this comment.
Thanks for the PR, @dplumlee! I reviewed the code and tested it locally. Overall LGTM, but I left some comments for you to consider. Please take a look.
I tested by installing all rules from package v8.7.1, then installing the package version 9.4.0-beta.1. To check if the deprecation message is displayed, I updated one of the prebuilt rule assets in ES – no assets in the beta package seem to have a deprecation message.
Also, here's a few non-critical UI things I noticed (click items below to expand).
| <> | ||
| <EuiText size="s" data-test-subj="deprecated-rule-reason"> | ||
| <p> | ||
| {i18n.DEPRECATION_REASON_LABEL} {reason} |
There was a problem hiding this comment.
nit: I'd move the reason above the description, so it logically flows like:
- This rule is deprecated
- Here's why
- Here's what you can do about it
- Here are the buttons to do it
Exploratory Test ReportExploratory tests were executed and the following areas/flows were covered: Deprecation Callout & Modal
Timed Dismissal
Bulk Actions
Editing
Export/Import
Cross-Feature Integration
Multi-Space
Coexistence
No unexpected behavior or errors were observed during exploratory testing. |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Async chunks
Page load bundle
Unknown metric groupsReferences to deprecated APIs
Unreferenced deprecated APIs
History
cc @dplumlee |
## Summary **Epic**: [internal link](elastic/security-team#6344) **Implementation PR**: #259673 Adds test plan for the prebuilt rule deprecation feature in `/prebuilt_rule_deprecation.md` using the existing template. New scenarios: - [Default exclusion from existing flows] - [**Scenario: Deprecated rules are excluded from install review**] - [**Scenario: Deprecated rules are excluded from upgrade review**] - [**Scenario: Deprecated rules are excluded from bootstrap**] - [**Scenario: Deprecated rules are excluded from fetchAssetsByVersion**] - [**Scenario: Deprecated rules are excluded from fetchLatestAssets**] - [Status API: deprecated count] - [**Scenario: Status API returns correct count of installed deprecated rules**] - [**Scenario: Status API returns zero when no installed rules are deprecated**] - [Deprecation review API: no filter] - [**Scenario: Review API returns all installed deprecated rules when no ids provided**] - [**Scenario: Review API returns installed rule name, not package name**] - [Deprecation review API: with ids filter] - [**Scenario: Review API filters by installed rule SO ids**] - [**Scenario: Review API returns empty when filtered rule is not deprecated**] - [**Scenario: Review API returns empty when filtered id does not exist**] - [Deprecation review API: edge cases] - [**Scenario: Review API respects MAX\_DEPRECATED\_RULES\_TO\_RETURN limit**] - [**Scenario: Review API handles package with no deprecated rules**] - [Rule Management page: deprecation callout] - [**Scenario: Callout appears when user has installed deprecated rules**] - [**Scenario: Callout does not appear when no deprecated rules are installed**] - [Rule Management page: deprecated rules modal] - [**Scenario: Modal lists all deprecated installed rules with links**] - [**Scenario: User can delete all deprecated rules from the modal**] - [**Scenario: Delete all button is disabled for read-only users**] - [Rule Details page: deprecation callout] - [**Scenario: Callout appears on deprecated prebuilt rule details page**] - [**Scenario: Callout does not appear on non-deprecated rule details page**] - [**Scenario: Callout does not appear on custom rule details page**] - [**Scenario: Action buttons are disabled for read-only users**] - [Rule Details page: delete deprecated rule] - [**Scenario: User can delete a deprecated rule from its details page**] - [Rule Details page: duplicate and delete deprecated rule] - [**Scenario: User can duplicate and delete a deprecated rule**] - [**Scenario: Original rule is not deleted if duplication fails**]
#263662) ## Summary Adds unit tests, FTR integration tests, and cypress e2e tests for the [prebuilt rule deprecation workflow feature](#259673) in accordance to the [test plan](#259855) ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [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 - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed
…d tests (#263662) (#265134) # Backport This will backport the following commits from `main` to `9.4`: - [[Security Solution] Prebuilt rule deprecation workflow automated tests (#263662)](#263662) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Davis Plumlee","email":"56367316+dplumlee@users.noreply.github.com"},"sourceCommit":{"committedDate":"2026-04-22T18:55:44Z","message":"[Security Solution] Prebuilt rule deprecation workflow automated tests (#263662)\n\n## Summary\n\nAdds unit tests, FTR integration tests, and cypress e2e tests for the\n[prebuilt rule deprecation workflow\nfeature](#259673) in accordance to\nthe [test plan](https://github.com/elastic/kibana/pull/259855)\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [x] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed","sha":"50dec3989903fc92c789332ae72e22d93d09771b","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Detections and Resp","Team: SecuritySolution","Team:Detection Rule Management","Feature:Prebuilt Detection Rules","backport:version","v9.4.0","v9.5.0"],"title":"[Security Solution] Prebuilt rule deprecation workflow automated tests","number":263662,"url":"https://github.com/elastic/kibana/pull/263662","mergeCommit":{"message":"[Security Solution] Prebuilt rule deprecation workflow automated tests (#263662)\n\n## Summary\n\nAdds unit tests, FTR integration tests, and cypress e2e tests for the\n[prebuilt rule deprecation workflow\nfeature](#259673) in accordance to\nthe [test plan](https://github.com/elastic/kibana/pull/259855)\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [x] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed","sha":"50dec3989903fc92c789332ae72e22d93d09771b"}},"sourceBranch":"main","suggestedTargetBranches":["9.4"],"targetPullRequestStates":[{"branch":"9.4","label":"v9.4.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/263662","number":263662,"mergeCommit":{"message":"[Security Solution] Prebuilt rule deprecation workflow automated tests (#263662)\n\n## Summary\n\nAdds unit tests, FTR integration tests, and cypress e2e tests for the\n[prebuilt rule deprecation workflow\nfeature](#259673) in accordance to\nthe [test plan](https://github.com/elastic/kibana/pull/259855)\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [x] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed","sha":"50dec3989903fc92c789332ae72e22d93d09771b"}}]}] BACKPORT--> Co-authored-by: Davis Plumlee <56367316+dplumlee@users.noreply.github.com>
…es workflow (#263560) ## Summary Turns on the `prebuiltRulesDeprecationUIEnabled` feature flag implemented in this PR: #259673 Also makes some small UI fixes that were brought up during acceptance testing: - Adds different language to the duplicate and delete modal informing the user of the deletion - Adds padding to the tooltips in the duplication confirm modal - Adds link to docs in callout components ### Screenshots <img width="1051" height="468" alt="Screenshot 2026-04-16 at 12 33 29 PM" src="https://github.com/user-attachments/assets/468d970d-9009-40ef-99d9-c693e46c3e1a" /> <img width="1744" height="321" alt="Screenshot 2026-04-20 at 4 47 45 PM" src="https://github.com/user-attachments/assets/db580301-edb8-44b5-851c-197aab366c81" />
elastic#263662) ## Summary Adds unit tests, FTR integration tests, and cypress e2e tests for the [prebuilt rule deprecation workflow feature](elastic#259673) in accordance to the [test plan](elastic#259855) ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [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 - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed
…es workflow (elastic#263560) ## Summary Turns on the `prebuiltRulesDeprecationUIEnabled` feature flag implemented in this PR: elastic#259673 Also makes some small UI fixes that were brought up during acceptance testing: - Adds different language to the duplicate and delete modal informing the user of the deletion - Adds padding to the tooltips in the duplication confirm modal - Adds link to docs in callout components ### Screenshots <img width="1051" height="468" alt="Screenshot 2026-04-16 at 12 33 29 PM" src="https://github.com/user-attachments/assets/468d970d-9009-40ef-99d9-c693e46c3e1a" /> <img width="1744" height="321" alt="Screenshot 2026-04-20 at 4 47 45 PM" src="https://github.com/user-attachments/assets/db580301-edb8-44b5-851c-197aab366c81" />
elastic#263662) ## Summary Adds unit tests, FTR integration tests, and cypress e2e tests for the [prebuilt rule deprecation workflow feature](elastic#259673) in accordance to the [test plan](elastic#259855) ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [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 - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed
…es workflow (elastic#263560) ## Summary Turns on the `prebuiltRulesDeprecationUIEnabled` feature flag implemented in this PR: elastic#259673 Also makes some small UI fixes that were brought up during acceptance testing: - Adds different language to the duplicate and delete modal informing the user of the deletion - Adds padding to the tooltips in the duplication confirm modal - Adds link to docs in callout components ### Screenshots <img width="1051" height="468" alt="Screenshot 2026-04-16 at 12 33 29 PM" src="https://github.com/user-attachments/assets/468d970d-9009-40ef-99d9-c693e46c3e1a" /> <img width="1744" height="321" alt="Screenshot 2026-04-20 at 4 47 45 PM" src="https://github.com/user-attachments/assets/db580301-edb8-44b5-851c-197aab366c81" />
elastic#263662) ## Summary Adds unit tests, FTR integration tests, and cypress e2e tests for the [prebuilt rule deprecation workflow feature](elastic#259673) in accordance to the [test plan](elastic#259855) ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [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 - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed
…es workflow (elastic#263560) ## Summary Turns on the `prebuiltRulesDeprecationUIEnabled` feature flag implemented in this PR: elastic#259673 Also makes some small UI fixes that were brought up during acceptance testing: - Adds different language to the duplicate and delete modal informing the user of the deletion - Adds padding to the tooltips in the duplication confirm modal - Adds link to docs in callout components ### Screenshots <img width="1051" height="468" alt="Screenshot 2026-04-16 at 12 33 29 PM" src="https://github.com/user-attachments/assets/468d970d-9009-40ef-99d9-c693e46c3e1a" /> <img width="1744" height="321" alt="Screenshot 2026-04-20 at 4 47 45 PM" src="https://github.com/user-attachments/assets/db580301-edb8-44b5-851c-197aab366c81" />



Epic: https://github.com/elastic/security-team/issues/6344 (internal)
Resolves: https://github.com/elastic/security-team/issues/15791 (internal)
Resolves: https://github.com/elastic/security-team/issues/15793 (internal)
Resolves: #118942
Summary
Note
This feature is currently hidden behind the
prebuiltRulesDeprecationUIEnabledfeature flagAdds UI for identifying and managing deprecated prebuilt detection rules which will be present in
9.4+versions of the detection rules package.POST /internal/detection_engine/prebuilt_rules/deprecation/_reviewthat cross-references deprecated rule assets with installed rulesnum_prebuilt_rules_deprecatedadded to the prebuilt rules status responseuseTimedDismissalutility hook for dismissal that persists a custom amount of time (for when we don't want to pester users too much but just a little)Screenshots
Deprecated rules callout on detection rules table page

Deprecated rules modal

Deprecated rules callout on rule details page

Testing this PR
Quick setup
A seed script is included that creates fake prebuilt rules and their deprecated successors so the full deprecation UI can be exercised without a real 9.4+ rules package.
Script file: seed_deprecated_rules.sh
Start Kibana with the feature flag enabled in kibana.dev.yml:
Seed test data:
This will:
Navigate to Security > Rules > Detection Rules (SIEM):
Clean up when done:
The script is configurable via env vars:
Full integration setup (for testing with a real rules package)
Requires the detection-rules repo with a built package targeting 9.4+.
Add to
kibana.dev.yml: