Skip to content
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 Solution] Test plan for prebuilt rule customization #204888

Merged
merged 7 commits into from
Jan 16, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,281 @@
# Prebuilt Rule Customization Workflows

This is a test plan for rule customization workflows specifically related to prebuilt rules

Status: `in progress`.

## Useful information

### Tickets

- [Test plan issue](https://github.com/elastic/kibana/issues/202068)
- [Prebuilt rule customization](https://github.com/elastic/kibana/issues/174168) epic

### Terminology
dplumlee marked this conversation as resolved.
Show resolved Hide resolved

- **Base version**: The version of the rule we ship with the rule package, can be thought of as the "original" version of the rule.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **Base version**: The version of the rule we ship with the rule package, can be thought of as the "original" version of the rule.
- **Base version**: Prebuilt rule asset we ship in the rule package corresponding to the currently installed prebuilt rules. It represents "original" version of the rule. During prebuilt rules installation prebuilt rule assets data is copied over and becomes an installed prebuilt rule.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we say that it's a prebuilt rule asset whose "version" field matches the "version" of an installed rule? WDYT?


- **Customized prebuilt rule**: A prebuilt rule that has been changed by the user from the base version of the rule. Also referred to as "Modified" in the UI.
dplumlee marked this conversation as resolved.
Show resolved Hide resolved

- **Non-customized prebuilt rule**: A prebuilt rule that has no change from the base version of the rule.
dplumlee marked this conversation as resolved.
Show resolved Hide resolved

- **Custom rules**: A rule created by the user themselves
dplumlee marked this conversation as resolved.
Show resolved Hide resolved

### Assumptions

- Rule package used will have all rule versions present (no missing base versions)
dplumlee marked this conversation as resolved.
Show resolved Hide resolved

## Scenarios

### Editing prebuilt rules

#### **Scenario: User can edit a non-customized prebuilt rule from the rule edit page**

**Automation**: 1 cypress test.

```Gherkin
Given a space with at least one prebuilt rule installed
And the rule is unmodified
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
When a user edits the rule from the rule edit page to something different than the original version
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
Then the rule is successfully updated
And the ruleSource should be "external"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have separate scenarios for ruleSource instead of checking it in every test scenario?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could put it in the assumptions section as we never use custom rules in the customization tests, wdyt

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may add such ab assumption but it looks like an overkill since the test plan concerns prebuilt rules.

My comment is rather related to unnecessary test scenario explicitness. Users won't see ruleSource in UI. They rather see Modified badge when the rule is modified. The scenario says User can edit a non-customized prebuilt rule from the rule edit page. It literally means user may open rule editing form for a prebuilt rule, change some fields values and save the rule. After that they should see changed values on the rule details page and Modified badge. Checking ruleSource on the way is test implementation details and looks optional.

And isCustomized should be true
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
And the "Modified" badge should appear on the rule's detail page
Copy link
Contributor

@maximpn maximpn Dec 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it specify all the occurrences of Modified badge? Correct me if I'm wrong but we have it in Installed Rules table as well.

Rule Update table is shown in case of updates but "Modified" is also shown there. And it's worth mention that in the test plan.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do that here, we also have tests for the rule management table and update table themselves that have this test in them. Do we want to expand the scope of these tests to include the table as well as the rule details page?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have a separate test scenario to assert Modified badge appears on Rules Update table?

```

#### **Scenario: User can edit a customized prebuilt rule from the rule edit page**

**Automation**: 1 cypress test.

```Gherkin
Given a space with at least one customized prebuilt rule installed
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
When a user edits the rule from the rule edit page to something different than the original version
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
Then the rule is successfully updated
And the ruleSource should be "external"
And isCustomized should be true
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
And the "Modified" badge should still appear on the rule's detail page
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
```

#### **Scenario: User can edit a single prebuilt rule from the rule management page**
dplumlee marked this conversation as resolved.
Show resolved Hide resolved

**Automation**: 1 cypress test.

```Gherkin
Given a space with at least one prebuilt rule installed
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
When a user clicks overflow button on this rule
Then the "edit rule settings" button should be enabled
And should bring the user to the rule edit page when clicked on
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
```

#### **Scenario: User can bulk edit prebuilt rules from rules management page**

**Automation**: 8 cypress tests and 8 integration tests.

```Gherkin
Given a space with at multiple prebuilt rule installed
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
And a user selects multiple rules in the rules table
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
When a user applies a <bulk_action_type> bulk action
And the action is successfully applied to selected rules
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
Then rules that have been changed from their base version should have a ruleSource of "external"
And isCustomized should be true
And the "Modified" badge should appear on the respective row in the rule management table
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it verify the corresponding rule details pages as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again for this one, maybe we can just have one test specifically about the "modified" badge that checks all the locations in one test but for these it seems out of immediate scope wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified badge is the only visual output here. I think it should stay.

My point is that the test may double check bulk actions affect rule details page as well. Though I gave it a second thought and it looks rather optional.


Examples:
| bulk_action_type |
| Add index patterns |
| Delete index patterns |
| Add tags |
| Delete tags |
| Add custom highlighted fields |
| Delete custom highlighted fields |
| Modify rule schedules |
| Add rule actions |
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
```

### Calculating is_customized value
dplumlee marked this conversation as resolved.
Show resolved Hide resolved

#### **Scenario: is_customized is set to true when user edits a customizable rule field**
dplumlee marked this conversation as resolved.
Show resolved Hide resolved

**Automation**: 44 integration tests.
dplumlee marked this conversation as resolved.
Show resolved Hide resolved

```Gherkin
Given a space with at least one non-customized prebuilt rule installed
When a user edits the <field_name> field to something different than the base version
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
Then the rule's isCustomized value should be true
And ruleSource should be "external"

Examples:
| field_name |
| name |
| description |
| interval |
| from |
| to |
| note |
| severity |
| tags |
| severity_mapping |
| risk_score |
| risk_score_mapping |
| references |
| false_positives |
| threat |
| note |
| setup |
| related_integrations |
| required_fields |
| max_signals |
| investigation_fields |
| rule_name_override |
| timestamp_override |
| timeline_template |
| building_block_type |
| query |
| language |
| filters |
| index |
| data_view_id |
| alert_suppression |
| event_category_override |
| timestamp_field |
| tiebreaker_field |
| threat_index |
| threat_mapping |
| threat_indicator_path |
| threat_query |
| threat_language |
| threat_filters |
| threshold |
| machine_learning_job_id |
| anomaly_threshold |
| new_terms_fields |
| history_window_start |
| type |
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
```

#### **Scenario: is_customized is not set to true when user edits rule fields that aren't used in customized calculation**
dplumlee marked this conversation as resolved.
Show resolved Hide resolved

**Automation**: 4 integration tests.

```Gherkin
Given a space with at least one non-customized prebuilt rule installed
When a user edits the <field_name> field to something different than the base version
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
Then the rule's isCustomized value should remain false
And ruleSource should be "external"

Examples:
| field_name |
| actions |
| exceptions_list |
| enabled |
| revision |
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
```

#### **Scenario: User can revert a customized prebuilt rule to its original state**

**Automation**: 1 integration test.

```Gherkin
Given a space with at least one customized prebuilt rule installed
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
When a user edits the rule back to the same rule object as the base version
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
Then the rule's isCustomized value should be false
And ruleSource should be "external"
```

### Calculating the is_customized field and the Modified badge in the UI

#### **Scenario: Modified badge should appear on the rule details page when rule is modified**
dplumlee marked this conversation as resolved.
Show resolved Hide resolved

**Automation**: 1 cypress test.

```Gherkin
Given a space with at least one customized prebuilt rule installed
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
When a user navigates to that rule's detail page
Then the rule's isCustomized value should be true
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
And ruleSource should be "external"
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
And the Modified badge should be present on the page
```

#### **Scenario: Modified badge should not appear on the rule details page when rule isn't customized**
dplumlee marked this conversation as resolved.
Show resolved Hide resolved

**Automation**: 1 cypress test.

```Gherkin
Given a space with at least one non-customized prebuilt rule installed
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
When a user navigates to that rule's detail page
Then the rule's isCustomized value should be false
And ruleSource should be "external"
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
And the Modified badge should NOT be present on the page
```

#### **Scenario: Modified badge should appear on the rule management table when rule is modified**
dplumlee marked this conversation as resolved.
Show resolved Hide resolved

**Automation**: 1 cypress test.

```Gherkin
Given a space with at least one customized prebuilt rule installed
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
When a user navigates to that rule management page
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
Then the customized rule's isCustomized value should be true
And ruleSource should be "external"
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
And the Modified badge should be present in the table row
```

#### **Scenario: Modified badge should not appear on the rule management table when rule isn't customized**
dplumlee marked this conversation as resolved.
Show resolved Hide resolved

**Automation**: 1 cypress test.

```Gherkin
Given a space with at least one non-customized prebuilt rule installed
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
When a user navigates to the rule management page
Then the non-customized rule's isCustomized value should be false
And ruleSource should be "external"
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
And the Modified badge should NOT be present in the table row
```

#### **Scenario: Modified badge should appear on the rule updates table when rule is modified**
dplumlee marked this conversation as resolved.
Show resolved Hide resolved

**Automation**: 1 cypress test.

```Gherkin
Given a space with at least one customized prebuilt rule installed
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
When a user navigates to that rule updates page
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
Then the customized rule's isCustomized value should be true
And ruleSource should be "external"
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
And the Modified badge should be present in the table row
```

#### **Scenario: Modified badge should not appear on the rule updates table when rule isn't customized**
dplumlee marked this conversation as resolved.
Show resolved Hide resolved

**Automation**: 1 cypress test.

```Gherkin
Given a space with at least one non-customized prebuilt rule installed
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
When a user navigates to the rule updates page
Then the non-customized rule's isCustomized value should be false
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
And ruleSource should be "external"
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
And the Modified badge should NOT be present in the table row
```

#### **Scenario: User should be able to filter by modified rules on the rule updates table**
dplumlee marked this conversation as resolved.
Show resolved Hide resolved

**Automation**: 1 cypress test.

```Gherkin
Given a space with at least one customized prebuilt rule installed
When a user navigates to the rule updates page
And sorts by Modified in the filter drop-down
Then the table should only display modified rules
And the table rows should have the Modified badge present
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
```

#### **Scenario: User should be able to filter by unmodified rules on the rule updates table**
dplumlee marked this conversation as resolved.
Show resolved Hide resolved

**Automation**: 1 cypress test.

```Gherkin
Given a space with at least one customized prebuilt rule installed
When a user navigates to the rule updates page
And sorts by Unmodified in the filter drop-down
Then the table should only display unmodified rules
And the table rows should NOT have the Modified badge present
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
```