-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Cloud Security] posture_type
Backward compatibility changes
#151647
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7c99597
removing easier cases
JordanSh 43e7c3a
fixed filters
JordanSh 68d4b95
added negate filter and test
JordanSh a4e5433
type fix
JordanSh 99e98dd
Merge branch 'main' of https://github.com/elastic/kibana into posture…
JordanSh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
34 changes: 34 additions & 0 deletions
34
...s/cloud_security_posture/common/runtime_mappings/get_safe_posture_type_runtime_mapping.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,34 @@ | ||
/* | ||
* 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 { MappingRuntimeFields } from '@elastic/elasticsearch/lib/api/types'; | ||
|
||
/** | ||
* Creates the `safe_posture_type` runtime field with the value of either | ||
* `kspm` or `cspm` based on the value of `rule.benchmark.posture_type` | ||
*/ | ||
export const getSafePostureTypeRuntimeMapping = (): MappingRuntimeFields => ({ | ||
safe_posture_type: { | ||
type: 'keyword', | ||
script: { | ||
source: ` | ||
if (!doc.containsKey('rule.benchmark.posture_type')) | ||
{ | ||
def safe_posture_type = 'kspm'; | ||
emit(safe_posture_type); | ||
return | ||
} | ||
else | ||
{ | ||
def safe_posture_type = doc["rule.benchmark.posture_type"].value; | ||
emit(safe_posture_type); | ||
return | ||
} | ||
`, | ||
}, | ||
}, | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
import React, { useMemo } from 'react'; | ||
import { EuiFlexGroup, EuiFlexItem, EuiFlexItemProps } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { css } from '@emotion/react'; | ||
import { statusColors } from '../../../common/constants'; | ||
import { DASHBOARD_COUNTER_CARDS } from '../test_subjects'; | ||
import { CspCounterCard, CspCounterCardProps } from '../../../components/csp_counter_card'; | ||
|
@@ -21,6 +22,7 @@ import type { | |
} from '../../../../common/types'; | ||
import { RisksTable } from '../compliance_charts/risks_table'; | ||
import { | ||
NavFilter, | ||
useNavigateFindings, | ||
useNavigateFindingsByResource, | ||
} from '../../../common/hooks/use_navigate_findings'; | ||
|
@@ -36,12 +38,12 @@ export const dashboardColumnsGrow: Record<string, EuiFlexItemProps['grow']> = { | |
third: 8, | ||
}; | ||
|
||
export const getPolicyTemplateQuery = (policyTemplate: PosturePolicyTemplate) => { | ||
if (policyTemplate === CSPM_POLICY_TEMPLATE) | ||
export const getPolicyTemplateQuery = (policyTemplate: PosturePolicyTemplate): NavFilter => { | ||
if (policyTemplate === CSPM_POLICY_TEMPLATE) { | ||
return { 'rule.benchmark.posture_type': CSPM_POLICY_TEMPLATE }; | ||
if (policyTemplate === KSPM_POLICY_TEMPLATE) | ||
return { 'rule.benchmark.posture_type': KSPM_POLICY_TEMPLATE }; | ||
return {}; | ||
} | ||
|
||
return { 'rule.benchmark.posture_type': { value: CSPM_POLICY_TEMPLATE, negate: true } }; | ||
}; | ||
|
||
export const SummarySection = ({ | ||
|
@@ -124,7 +126,13 @@ export const SummarySection = ({ | |
); | ||
|
||
return ( | ||
<EuiFlexGroup gutterSize="l"> | ||
<EuiFlexGroup | ||
gutterSize="l" | ||
css={css` | ||
// height for compliance by cis section with max rows | ||
height: 310px; | ||
`} | ||
> | ||
Comment on lines
+136
to
+142
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unrelated but this fixes problems of unmatching summary sizes between dashboard tabs when there are not enough items in the compliance by score table |
||
<EuiFlexItem grow={dashboardColumnsGrow.first}> | ||
<EuiFlexGroup direction="column"> | ||
{counters.map((counter) => ( | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, usually I'm against runtime mappings, but since it's on the
latest
index, performance won't be an issue, great BC solution