-
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] Changes coverage overview subtechnique display to…
… base off active filters (#170988)
- Loading branch information
Showing
8 changed files
with
166 additions
and
77 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
...ublic/detection_engine/rule_management/model/coverage_overview/mitre_subtechnique.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,82 @@ | ||
/* | ||
* 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 { CoverageOverviewRuleActivity } from '../../../../../common/api/detection_engine'; | ||
import { getNumOfCoveredSubtechniques } from './mitre_subtechnique'; | ||
import type { CoverageOverviewMitreTechnique } from './mitre_technique'; | ||
import { | ||
getMockCoverageOverviewMitreSubTechnique, | ||
getMockCoverageOverviewMitreTechnique, | ||
} from './__mocks__'; | ||
|
||
describe('mitre_subtechniques', () => { | ||
describe('getNumOfCoveredSubtechniques', () => { | ||
it('returns 0 when no subtechniques are present', () => { | ||
const payload: CoverageOverviewMitreTechnique = getMockCoverageOverviewMitreTechnique(); | ||
expect(getNumOfCoveredSubtechniques(payload)).toEqual(0); | ||
}); | ||
|
||
it('returns total number of unique enabled and disabled subtechniques when no filter is passed', () => { | ||
const payload: CoverageOverviewMitreTechnique = { | ||
...getMockCoverageOverviewMitreTechnique(), | ||
subtechniques: [ | ||
getMockCoverageOverviewMitreSubTechnique(), | ||
{ ...getMockCoverageOverviewMitreSubTechnique(), id: 'test-id' }, | ||
], | ||
}; | ||
expect(getNumOfCoveredSubtechniques(payload)).toEqual(2); | ||
}); | ||
|
||
it('returns total number of unique enabled and disabled subtechniques when both filters are passed', () => { | ||
const payload: CoverageOverviewMitreTechnique = { | ||
...getMockCoverageOverviewMitreTechnique(), | ||
subtechniques: [ | ||
getMockCoverageOverviewMitreSubTechnique(), | ||
{ ...getMockCoverageOverviewMitreSubTechnique(), id: 'test-id' }, | ||
], | ||
}; | ||
expect( | ||
getNumOfCoveredSubtechniques(payload, [ | ||
CoverageOverviewRuleActivity.Enabled, | ||
CoverageOverviewRuleActivity.Disabled, | ||
]) | ||
).toEqual(2); | ||
}); | ||
|
||
it('returns total number of enabled subtechniques when enabled filter is passed', () => { | ||
const payload: CoverageOverviewMitreTechnique = { | ||
...getMockCoverageOverviewMitreTechnique(), | ||
subtechniques: [ | ||
{ | ||
...getMockCoverageOverviewMitreSubTechnique(), | ||
enabledRules: [], | ||
}, | ||
getMockCoverageOverviewMitreSubTechnique(), | ||
], | ||
}; | ||
expect(getNumOfCoveredSubtechniques(payload, [CoverageOverviewRuleActivity.Enabled])).toEqual( | ||
1 | ||
); | ||
}); | ||
|
||
it('returns total number of disabled subtechniques when disabled filter is passed', () => { | ||
const payload: CoverageOverviewMitreTechnique = { | ||
...getMockCoverageOverviewMitreTechnique(), | ||
subtechniques: [ | ||
{ | ||
...getMockCoverageOverviewMitreSubTechnique(), | ||
disabledRules: [], | ||
}, | ||
getMockCoverageOverviewMitreSubTechnique(), | ||
], | ||
}; | ||
expect( | ||
getNumOfCoveredSubtechniques(payload, [CoverageOverviewRuleActivity.Disabled]) | ||
).toEqual(1); | ||
}); | ||
}); | ||
}); |
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