Skip to content

Commit

Permalink
[Security Solution] Add skipped rules to Bulk Edit rules API response (
Browse files Browse the repository at this point in the history
…#147345)

**Addresses:** #145093
**Related to:** #139802

## Summary

- Extends Bulk Edit API to return a new `skipped` property for rules
whose updating was skipped. See
[#145093](#145093) for details
on when a rule is skipped.
- In `x-pack/plugins/alerting/server/rules_client/methods/bulk_edit.ts`,
refactored the methods `bulkEdit` and `bulkEditOcc` to smaller methods,
following an immutable approach.
- Updated all related tests and expanded coverage. (unit, integration
and e2e)
- Update success toast message so that the user is informed if rules
were skipped.


https://user-images.githubusercontent.com/5354282/199806913-eb70e7a6-0435-486a-96f1-dd0e8abaffe2.mp4

### Checklist

Delete any items that are not applicable to this PR.

- [ ] 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/main/packages/kbn-i18n/README.md)
- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
  - elastic/security-docs#2684
- [ ] [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
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)



### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

Co-authored-by: Xavier Mouligneau <[email protected]>
  • Loading branch information
jpdjere and XavierM authored Dec 20, 2022
1 parent 374478d commit aaac011
Show file tree
Hide file tree
Showing 31 changed files with 2,313 additions and 667 deletions.
16 changes: 16 additions & 0 deletions x-pack/plugins/alerting/common/bulk_edit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { Rule } from './rule';

export type BulkEditSkipReason = 'RULE_NOT_MODIFIED';

export interface BulkActionSkipResult {
id: Rule['id'];
name?: Rule['name'];
skip_reason: BulkEditSkipReason;
}
1 change: 1 addition & 0 deletions x-pack/plugins/alerting/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export * from './rule_navigation';
export * from './alert_instance';
export * from './alert_summary';
export * from './builtin_action_groups';
export * from './bulk_edit';
export * from './disabled_action_groups';
export * from './rule_notify_when_type';
export * from './parse_duration';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('bulkEditInternalRulesRoute', () => {
},
],
};
const bulkEditResult = { rules: mockedAlerts, errors: [], total: 1 };
const bulkEditResult = { rules: mockedAlerts, errors: [], total: 1, skipped: [] };

it('bulk edits rules with tags action', async () => {
const licenseState = licenseStateMock.create();
Expand All @@ -97,6 +97,7 @@ describe('bulkEditInternalRulesRoute', () => {
body: {
total: 1,
errors: [],
skipped: [],
rules: [
expect.objectContaining({
id: '1',
Expand Down
Loading

0 comments on commit aaac011

Please sign in to comment.