-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution][Detections] Hide building block rules in "Securit…
…y/Overview" (#105611) (#115521) * Hide building block rules in "Security/Overview" * Add Cypress tests for alerts generated by building block rules Co-authored-by: Dmitry Shevchenko <[email protected]> Co-authored-by: Georgii Gorbachev <[email protected]> Co-authored-by: Dmitry Shevchenko <[email protected]>
- Loading branch information
1 parent
44e0e53
commit 0c86129
Showing
6 changed files
with
111 additions
and
4 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
...gins/security_solution/cypress/integration/detection_alerts/building_block_alerts.spec.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,40 @@ | ||
/* | ||
* 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 { getBuildingBlockRule } from '../../objects/rule'; | ||
import { OVERVIEW_ALERTS_HISTOGRAM } from '../../screens/overview'; | ||
import { OVERVIEW } from '../../screens/security_header'; | ||
import { goToRuleDetails } from '../../tasks/alerts_detection_rules'; | ||
import { createCustomRuleActivated } from '../../tasks/api_calls/rules'; | ||
import { cleanKibana } from '../../tasks/common'; | ||
import { waitForAlertsToPopulate, waitForTheRuleToBeExecuted } from '../../tasks/create_new_rule'; | ||
import { loginAndWaitForPage } from '../../tasks/login'; | ||
import { navigateFromHeaderTo } from '../../tasks/security_header'; | ||
import { DETECTIONS_RULE_MANAGEMENT_URL } from '../../urls/navigation'; | ||
|
||
const EXPECTED_NUMBER_OF_ALERTS = 16; | ||
|
||
describe('Alerts generated by building block rules', () => { | ||
beforeEach(() => { | ||
cleanKibana(); | ||
}); | ||
|
||
it('Alerts should be visible on the Rule Detail page and not visible on the Overview page', () => { | ||
createCustomRuleActivated(getBuildingBlockRule()); | ||
loginAndWaitForPage(DETECTIONS_RULE_MANAGEMENT_URL); | ||
goToRuleDetails(); | ||
waitForTheRuleToBeExecuted(); | ||
|
||
// Check that generated events are visible on the Details page | ||
waitForAlertsToPopulate(EXPECTED_NUMBER_OF_ALERTS); | ||
|
||
navigateFromHeaderTo(OVERVIEW); | ||
|
||
// Check that generated events are hidden on the Overview page | ||
cy.get(OVERVIEW_ALERTS_HISTOGRAM).should('contain.text', 'No data to display'); | ||
}); | ||
}); |
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
37 changes: 37 additions & 0 deletions
37
...ion/public/overview/components/signals_by_category/use_filters_for_signals_by_category.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,37 @@ | ||
/* | ||
* 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 { useMemo } from 'react'; | ||
import { Filter } from '@kbn/es-query'; | ||
|
||
import { useIsExperimentalFeatureEnabled } from '../../../common/hooks/use_experimental_features'; | ||
import { | ||
buildShowBuildingBlockFilter, | ||
buildShowBuildingBlockFilterRuleRegistry, | ||
} from '../../../detections/components/alerts_table/default_config'; | ||
|
||
// On the Overview page, in the Detection Alert Trend, we never show | ||
// "building block" alerts to remove noise from the Overview UI. | ||
// https://www.elastic.co/guide/en/security/current/building-block-rule.html | ||
const SHOW_BUILDING_BLOCK_ALERTS = false; | ||
|
||
export const useFiltersForSignalsByCategory = (baseFilters: Filter[]) => { | ||
// TODO: Once we are past experimental phase this code should be removed | ||
const ruleRegistryEnabled = useIsExperimentalFeatureEnabled('ruleRegistryEnabled'); | ||
|
||
const resultingFilters = useMemo( | ||
() => [ | ||
...baseFilters, | ||
...(ruleRegistryEnabled | ||
? buildShowBuildingBlockFilterRuleRegistry(SHOW_BUILDING_BLOCK_ALERTS) // TODO: Once we are past experimental phase this code should be removed | ||
: buildShowBuildingBlockFilter(SHOW_BUILDING_BLOCK_ALERTS)), | ||
], | ||
[baseFilters, ruleRegistryEnabled] | ||
); | ||
|
||
return resultingFilters; | ||
}; |