Skip to content

Commit 84faa5c

Browse files
[8.x] [Cloud Security] Only adding `safe_posture_type` to native csp findings (#196064) (#196200)
# Backport This will backport the following commits from `main` to `8.x`: - [[Cloud Security] Only adding &#x60;safe_posture_type&#x60; to native csp findings (#196064)](#196064) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Jordan","email":"51442161+JordanSh@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-10-14T18:44:48Z","message":"[Cloud Security] Only adding `safe_posture_type` to native csp findings (#196064)","sha":"73c9391c23f6fb52db6d1339da8cc72c602aa855","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Cloud Security","backport:prev-minor"],"title":"[Cloud Security] Only adding `safe_posture_type` to native csp findings","number":196064,"url":"https://github.com/elastic/kibana/pull/196064","mergeCommit":{"message":"[Cloud Security] Only adding `safe_posture_type` to native csp findings (#196064)","sha":"73c9391c23f6fb52db6d1339da8cc72c602aa855"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/196064","number":196064,"mergeCommit":{"message":"[Cloud Security] Only adding `safe_posture_type` to native csp findings (#196064)","sha":"73c9391c23f6fb52db6d1339da8cc72c602aa855"}}]}] BACKPORT--> Co-authored-by: Jordan <51442161+JordanSh@users.noreply.github.com>
1 parent 10f7699 commit 84faa5c

5 files changed

Lines changed: 25 additions & 7 deletions

File tree

x-pack/plugins/cloud_security_posture/common/runtime_mappings/get_safe_posture_type_runtime_mapping.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ export const getSafePostureTypeRuntimeMapping = (): MappingRuntimeFields => ({
1616
type: 'keyword',
1717
script: {
1818
source: `
19-
def postureTypeAvailable = doc.containsKey("rule.benchmark.posture_type") &&
20-
!doc["rule.benchmark.posture_type"].empty;
19+
def postureTypeAvailable = doc.containsKey("rule.benchmark.posture_type") && !doc["rule.benchmark.posture_type"].empty;
20+
boolean isNativeCsp = doc.containsKey("data_stream.dataset") && !doc["data_stream.dataset"].empty && doc["data_stream.dataset"].value == "cloud_security_posture.findings";
2121
22-
if (!postureTypeAvailable) {
23-
// Before 8.7 release
24-
emit("kspm");
25-
} else {
26-
emit(doc["rule.benchmark.posture_type"].value);
22+
if (isNativeCsp) {
23+
if (!postureTypeAvailable) {
24+
// Before 8.7 release
25+
emit("kspm");
26+
} else {
27+
emit(doc["rule.benchmark.posture_type"].value);
28+
}
2729
}
2830
`,
2931
},

x-pack/plugins/cloud_security_posture/server/lib/check_index_status.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const checkIndexStatus = async (
4949
],
5050
},
5151
};
52+
5253
try {
5354
const queryResult = await esClient.search({
5455
index,

x-pack/test/api_integration/apis/cloud_security_posture/mock_data.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export const findingsMockData = [
2828
ingested: '2023-08-19T18:20:41Z',
2929
created: '2023-08-19T18:17:15.609124281Z',
3030
},
31+
data_stream: {
32+
dataset: 'cloud_security_posture.findings',
33+
},
3134
},
3235
{
3336
resource: { id: chance.guid(), name: `Pod`, sub_type: 'Upper case sub type' },
@@ -48,6 +51,9 @@ export const findingsMockData = [
4851
ingested: '2023-08-19T18:20:41Z',
4952
created: '2023-08-19T18:17:15.609124281Z',
5053
},
54+
data_stream: {
55+
dataset: 'cloud_security_posture.findings',
56+
},
5157
},
5258
];
5359

x-pack/test/cloud_security_posture_api/routes/mocks/findings_mock.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ export const findingsMockData = [
3232
orchestrator: {
3333
cluster: { id: 'Upper case cluster id' },
3434
},
35+
data_stream: {
36+
dataset: 'cloud_security_posture.findings',
37+
},
3538
},
3639
{
3740
'@timestamp': '2023-06-29T02:08:44.993Z',
@@ -55,5 +58,8 @@ export const findingsMockData = [
5558
cloud: {
5659
account: { id: 'Another Upper case account id' },
5760
},
61+
data_stream: {
62+
dataset: 'cloud_security_posture.findings',
63+
},
5864
},
5965
];

x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/compliance_dashboard.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
3333
},
3434
},
3535
cluster_id: 'Upper case cluster id',
36+
data_stream: {
37+
dataset: 'cloud_security_posture.findings',
38+
},
3639
},
3740
];
3841

0 commit comments

Comments
 (0)