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

[7.x] [SIEM][Detection Engine] Adds a tags service and optimizes alert_id lookups (#52838) #52952

Merged
merged 1 commit into from
Dec 12, 2019

Conversation

FrankHassanabad
Copy link
Contributor

Backports the following commits to 7.x:

…ookups

## Summary

* Adds a tags services for use by UI's that want to get a list of all the unique tags that are on all of the rules just like an aggregation
* Removes the horribly inefficient `alert_id` look up that was a full alert scan and instead uses an internal structure that it augments to the tags for fast `alert_id` look ups.
* Adds unit tests for the tags and internal structure tags
* Updates other unit tests

Usage for the UI:

```sh
GET /api/detection_engine/tags
```

or shell script:
```sh
./get_tags.sh
```

Returns:

```sh
[
  "tag_1",
  "tag_2"
]
```

Testing:
Ensure that the internal structure does not leak when doing any of these script/API calls
  * ./get_tags.sh
  * ./post_rule.sh ./rules/queries/query_with_tags.json
  * ./update_rule.sh ./rules/queries/query_with_tags.json
  * ./delete_rule.sh
  * ./find_rules.sh
  * ./find_rule_by_filter.sh "alert.attributes.enabled:%20true"
  * ./find_rule_by_filter.sh "alert.attributes.tags:tag_1"

Caveat:

You can do filter searches against tags that have the double underscore such as:

```sh
./find_rule_by_filter.sh "alert.attributes.tags:%20__*"
```

But that shouldn't be a big problem and more than likely no one will be naming something with double underscores.

### Checklist

Use ~~strikethroughs~~ to remove checklist items you don't feel are applicable to this PR.

~~- [ ] This was checked for cross-browser compatibility, [including a check against IE11](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility)~~

~~- [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md)~~

~~- [ ] [Documentation](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#writing-documentation) was added for features that require explanation or tutorials~~

- [x] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios

~~- [ ] This was checked for [keyboard-only and screenreader accessibility](https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Accessibility#Accessibility_testing_checklist)~~

### For maintainers

~~- [ ] This was checked for breaking API changes and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)~~

- [x] This includes a feature addition or change that requires a release note and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@FrankHassanabad FrankHassanabad merged commit da06a9d into elastic:7.x Dec 12, 2019
@FrankHassanabad FrankHassanabad deleted the backport/7.x/pr-52838 branch December 12, 2019 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants