-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution] Add active maintenance window callout to the Rule…
…s Management page (#155386) **Addresses:** #155099 **Documentation issue:** elastic/security-docs#3181 ## Summary Adds a Maintenance Window callout to the Rules Management page. This callout is only displayed when a maintenance window is running. <img width="1260" alt="Screenshot 2023-04-21 at 13 24 11" src="https://user-images.githubusercontent.com/15949146/233624339-9c9b6e3e-9e5e-424d-9d19-9cd7d4e92259.png"> ### Checklist - [x] 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) issue created: elastic/security-docs#3181 - [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] 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)) - [x] 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)) - [x] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) ### For maintainers - [x] 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: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Georgii Gorbachev <banderror@gmail.com>
- Loading branch information
1 parent
a34dd8c
commit 675ed0e
Showing
18 changed files
with
359 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
x-pack/plugins/security_solution/cypress/e2e/detection_rules/maintenance_window.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* 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 { INTERNAL_ALERTING_API_MAINTENANCE_WINDOW_PATH } from '@kbn/alerting-plugin/common'; | ||
import type { MaintenanceWindowCreateBody } from '@kbn/alerting-plugin/common'; | ||
import type { AsApiContract } from '@kbn/alerting-plugin/server/routes/lib'; | ||
import { cleanKibana } from '../../tasks/common'; | ||
import { login, visit } from '../../tasks/login'; | ||
import { DETECTIONS_RULE_MANAGEMENT_URL } from '../../urls/navigation'; | ||
|
||
describe('Maintenance window callout on Rule Management page', () => { | ||
let maintenanceWindowId = ''; | ||
|
||
before(() => { | ||
cleanKibana(); | ||
login(); | ||
|
||
const body: AsApiContract<MaintenanceWindowCreateBody> = { | ||
title: 'My maintenance window', | ||
duration: 60000, // 1 minute | ||
r_rule: { | ||
dtstart: new Date().toISOString(), | ||
tzid: 'Europe/Amsterdam', | ||
freq: 0, | ||
count: 1, | ||
}, | ||
}; | ||
|
||
// Create a test maintenance window | ||
cy.request({ | ||
method: 'POST', | ||
url: INTERNAL_ALERTING_API_MAINTENANCE_WINDOW_PATH, | ||
headers: { 'kbn-xsrf': 'cypress-creds' }, | ||
body, | ||
}).then((response) => { | ||
maintenanceWindowId = response.body.id; | ||
}); | ||
}); | ||
|
||
after(() => { | ||
// Delete a test maintenance window | ||
cy.request({ | ||
method: 'DELETE', | ||
url: `${INTERNAL_ALERTING_API_MAINTENANCE_WINDOW_PATH}/${maintenanceWindowId}`, | ||
headers: { 'kbn-xsrf': 'cypress-creds' }, | ||
}); | ||
}); | ||
|
||
it('Displays the callout when there are running maintenance windows', () => { | ||
visit(DETECTIONS_RULE_MANAGEMENT_URL); | ||
|
||
cy.contains('A maintenance window is currently running'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
"force": true | ||
}, | ||
"@kbn/rison", | ||
"@kbn/datemath" | ||
"@kbn/datemath", | ||
"@kbn/alerting-plugin" | ||
] | ||
} |
18 changes: 18 additions & 0 deletions
18
...n/public/detection_engine/rule_management_ui/components/maintenance_window_callout/api.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* 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 type { MaintenanceWindow } from '@kbn/alerting-plugin/common/maintenance_window'; | ||
import { INTERNAL_ALERTING_API_GET_ACTIVE_MAINTENANCE_WINDOWS_PATH } from '@kbn/alerting-plugin/common'; | ||
import { KibanaServices } from '../../../../common/lib/kibana'; | ||
|
||
export const fetchActiveMaintenanceWindows = async ( | ||
signal?: AbortSignal | ||
): Promise<MaintenanceWindow[]> => | ||
KibanaServices.get().http.fetch(INTERNAL_ALERTING_API_GET_ACTIVE_MAINTENANCE_WINDOWS_PATH, { | ||
method: 'GET', | ||
signal, | ||
}); |
Oops, something went wrong.