forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Cloud Security] 3P integrations callouts (elastic#194362)
- Loading branch information
Showing
26 changed files
with
277 additions
and
100 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
42 changes: 0 additions & 42 deletions
42
x-pack/plugins/cloud_security_posture/public/common/utils/get_dataset_display_name.test.ts
This file was deleted.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
x-pack/plugins/cloud_security_posture/public/common/utils/get_vendor_name.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,71 @@ | ||
/* | ||
* 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 { CspFinding, CspVulnerabilityFinding } from '@kbn/cloud-security-posture-common'; | ||
import { getVendorName } from './get_vendor_name'; | ||
|
||
describe('getVendorName', () => { | ||
it('should return the vendor from the finding if available', () => { | ||
const finding = { | ||
observer: { vendor: 'SomeVendor' }, | ||
data_stream: { dataset: 'some.dataset' }, | ||
} as CspFinding; | ||
|
||
const result = getVendorName(finding); | ||
expect(result).toBe('SomeVendor'); | ||
}); | ||
|
||
it('should return "Wiz" for Wiz misconfiguration dataset', () => { | ||
const finding = { | ||
observer: {}, | ||
data_stream: { dataset: 'wiz.cloud_configuration_finding' }, | ||
} as CspFinding; | ||
|
||
const result = getVendorName(finding); | ||
expect(result).toBe('Wiz'); | ||
}); | ||
|
||
it('should return "Wiz" for Wiz vulnerability dataset', () => { | ||
const finding = { | ||
observer: {}, | ||
data_stream: { dataset: 'wiz.vulnerability' }, | ||
} as CspVulnerabilityFinding; | ||
|
||
const result = getVendorName(finding); | ||
expect(result).toBe('Wiz'); | ||
}); | ||
|
||
it('should return "Elastic" for Elastic misconfiguration dataset', () => { | ||
const finding = { | ||
observer: {}, | ||
data_stream: { dataset: 'cloud_security_posture.findings' }, | ||
} as CspFinding; | ||
|
||
const result = getVendorName(finding); | ||
expect(result).toBe('Elastic'); | ||
}); | ||
|
||
it('should return "Elastic" for Elastic vulnerability dataset', () => { | ||
const finding = { | ||
observer: {}, | ||
data_stream: { dataset: 'cloud_security_posture.vulnerabilities' }, | ||
} as CspVulnerabilityFinding; | ||
|
||
const result = getVendorName(finding); | ||
expect(result).toBe('Elastic'); | ||
}); | ||
|
||
it('should return undefined if no vendor or known dataset is provided', () => { | ||
const finding = { | ||
observer: {}, | ||
data_stream: { dataset: 'unknown.dataset' }, | ||
} as CspFinding; | ||
|
||
const result = getVendorName(finding); | ||
expect(result).toBeUndefined(); | ||
}); | ||
}); |
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
56 changes: 56 additions & 0 deletions
56
x-pack/plugins/cloud_security_posture/public/common/utils/is_native_csp_finding.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,56 @@ | ||
/* | ||
* 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 { CSP_MISCONFIGURATIONS_DATASET, CSP_VULN_DATASET } from './get_vendor_name'; | ||
import { isNativeCspFinding } from './is_native_csp_finding'; | ||
import { CspFinding } from '@kbn/cloud-security-posture-common'; | ||
import { CspVulnerabilityFinding } from '@kbn/cloud-security-posture-common/schema/vulnerabilities/csp_vulnerability_finding'; | ||
|
||
describe('isNativeCspFinding', () => { | ||
it("should return true when finding's dataset matches CSP_MISCONFIGURATIONS_DATASET", () => { | ||
const finding = { | ||
data_stream: { | ||
dataset: CSP_MISCONFIGURATIONS_DATASET, | ||
}, | ||
} as CspFinding; | ||
|
||
expect(isNativeCspFinding(finding)).toBe(true); | ||
}); | ||
|
||
it("should return true when finding's dataset matches CSP_VULN_DATASET", () => { | ||
const finding = { | ||
data_stream: { | ||
dataset: CSP_VULN_DATASET, | ||
}, | ||
} as CspVulnerabilityFinding; | ||
|
||
expect(isNativeCspFinding(finding)).toBe(true); | ||
}); | ||
|
||
it('should return false when finding object is missing data_stream property', () => { | ||
const finding = {} as CspFinding; | ||
|
||
expect(isNativeCspFinding(finding)).toBe(false); | ||
}); | ||
|
||
it('should return false when finding object has data_stream property but missing dataset property', () => { | ||
const finding = { | ||
data_stream: {}, | ||
} as CspFinding; | ||
|
||
expect(isNativeCspFinding(finding)).toBe(false); | ||
}); | ||
|
||
it('should return false when dataset property is null or undefined', () => { | ||
const findingWithUndefinedDataset = { | ||
data_stream: { | ||
dataset: undefined, | ||
}, | ||
} as CspFinding; | ||
|
||
expect(isNativeCspFinding(findingWithUndefinedDataset)).toBe(false); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
x-pack/plugins/cloud_security_posture/public/common/utils/is_native_csp_finding.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,14 @@ | ||
/* | ||
* 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 { CspFinding } from '@kbn/cloud-security-posture-common'; | ||
import { CspVulnerabilityFinding } from '@kbn/cloud-security-posture-common/schema/vulnerabilities/csp_vulnerability_finding'; | ||
import { CSP_MISCONFIGURATIONS_DATASET, CSP_VULN_DATASET } from './get_vendor_name'; | ||
|
||
export const isNativeCspFinding = (finding: CspFinding | CspVulnerabilityFinding) => | ||
finding.data_stream?.dataset === CSP_MISCONFIGURATIONS_DATASET || | ||
finding.data_stream?.dataset === CSP_VULN_DATASET; |
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
Oops, something went wrong.