-
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.
Filter out non-security jobs when collecting Detections telemetry (#7…
…4456) (#74467) Our jobs summary call returns all installed jobs regardless of group; passing groups as jobIds does not perform group filtering. This adds a helper predicate function on which to filter these results, and updates tests accordingly.
- Loading branch information
Showing
5 changed files
with
65 additions
and
5 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
30 changes: 30 additions & 0 deletions
30
x-pack/plugins/security_solution/common/machine_learning/is_security_job.test.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,30 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { MlSummaryJob } from '../../../ml/common/types/anomaly_detection_jobs'; | ||
import { isSecurityJob } from './is_security_job'; | ||
|
||
describe('isSecurityJob', () => { | ||
it('counts a job with a group of "siem"', () => { | ||
const job = { groups: ['siem', 'other'] } as MlSummaryJob; | ||
expect(isSecurityJob(job)).toEqual(true); | ||
}); | ||
|
||
it('counts a job with a group of "security"', () => { | ||
const job = { groups: ['security', 'other'] } as MlSummaryJob; | ||
expect(isSecurityJob(job)).toEqual(true); | ||
}); | ||
|
||
it('counts a job in both "security" and "siem"', () => { | ||
const job = { groups: ['siem', 'security'] } as MlSummaryJob; | ||
expect(isSecurityJob(job)).toEqual(true); | ||
}); | ||
|
||
it('does not count a job in a related group', () => { | ||
const job = { groups: ['auditbeat', 'process'] } as MlSummaryJob; | ||
expect(isSecurityJob(job)).toEqual(false); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
x-pack/plugins/security_solution/common/machine_learning/is_security_job.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,11 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { MlSummaryJob } from '../../../ml/common/types/anomaly_detection_jobs'; | ||
import { ML_GROUP_IDS } from '../constants'; | ||
|
||
export const isSecurityJob = (job: MlSummaryJob): boolean => | ||
job.groups.some((group) => ML_GROUP_IDS.includes(group)); |
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