-
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] Fix coverage overview endpoint (#164749)
## Summary This PR fixes a bug found by @jamesspi when it's Coverage Overview page doesn't show the cards but applying individual filters makes the page rendering. ## Steps to reproduce the problem - create a non security rule in your environment - navigate to the Coverage Overview page Expected behavior Coverage Overview page is loaded and displays the cards. Actual behavior Coverage Overview page does not display the cards. ## Details `rulesClient.find()` was used directly instead of `findRules()` helper function defined in Security Solution. The subtle different between these two is that `findRules()` passes filter to `enrichFilterWithRuleTypeMapping()` to make sure only security rules are fetched and processed. As `rulesClient.find()` returned all the rules there was a non security rule in the list with missing `rule.params` field causing the endpoint to fail. This has been fixed by using `findRules()`. ### Checklist - [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
- Loading branch information
Showing
6 changed files
with
113 additions
and
38 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
41 changes: 41 additions & 0 deletions
41
x-pack/test/detection_engine_api_integration/utils/create_non_security_rule.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,41 @@ | ||
/* | ||
* 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 SuperTest from 'supertest'; | ||
|
||
const SIMPLE_APM_RULE_DATA = { | ||
name: 'Test rule', | ||
rule_type_id: 'apm.anomaly', | ||
enabled: false, | ||
consumer: 'alerts', | ||
tags: [], | ||
actions: [], | ||
params: { | ||
windowSize: 30, | ||
windowUnit: 'm', | ||
anomalySeverityType: 'critical', | ||
environment: 'ENVIRONMENT_ALL', | ||
}, | ||
schedule: { | ||
interval: '10m', | ||
}, | ||
}; | ||
|
||
/** | ||
* Created a non security rule. Helpful in tests to verify functionality works with presence of non security rules. | ||
* @param supertest The supertest deps | ||
*/ | ||
export async function createNonSecurityRule( | ||
supertest: SuperTest.SuperTest<SuperTest.Test> | ||
): Promise<void> { | ||
await supertest | ||
.post('/api/alerting/rule') | ||
.set('kbn-xsrf', 'true') | ||
.set('elastic-api-version', '2023-10-31') | ||
.send(SIMPLE_APM_RULE_DATA) | ||
.expect(200); | ||
} |