mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-03-22 03:08:23 +00:00
feat(ingestions): allow multiple scan_ids and providers inside the ocsf (#10182)
This commit is contained in:
@@ -57,8 +57,14 @@ class OCSF(Output):
|
|||||||
if not findings:
|
if not findings:
|
||||||
return
|
return
|
||||||
|
|
||||||
scan_id = _uuid7_from_timestamp(findings[0].timestamp)
|
scan_ids_by_provider = {}
|
||||||
for finding in findings:
|
for finding in findings:
|
||||||
|
provider = finding.metadata.Provider
|
||||||
|
if provider not in scan_ids_by_provider:
|
||||||
|
scan_ids_by_provider[provider] = _uuid7_from_timestamp(
|
||||||
|
finding.timestamp
|
||||||
|
)
|
||||||
|
scan_id = scan_ids_by_provider[provider]
|
||||||
finding_activity = ActivityID.Create
|
finding_activity = ActivityID.Create
|
||||||
cloud_account_type = self.get_account_type_id_by_provider(
|
cloud_account_type = self.get_account_type_id_by_provider(
|
||||||
finding.metadata.Provider
|
finding.metadata.Provider
|
||||||
|
|||||||
@@ -123,6 +123,23 @@ class TestOCSF:
|
|||||||
1619600000, tz=timezone.utc
|
1619600000, tz=timezone.utc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_scan_id_is_unique_per_provider(self):
|
||||||
|
findings = [
|
||||||
|
generate_finding_output(provider="aws"),
|
||||||
|
generate_finding_output(provider="azure"),
|
||||||
|
generate_finding_output(provider="aws"),
|
||||||
|
]
|
||||||
|
|
||||||
|
ocsf = OCSF(findings)
|
||||||
|
|
||||||
|
scan_ids = [finding.unmapped["scan_id"] for finding in ocsf.data]
|
||||||
|
|
||||||
|
assert UUID(scan_ids[0])
|
||||||
|
assert UUID(scan_ids[1])
|
||||||
|
assert UUID(scan_ids[2])
|
||||||
|
assert scan_ids[0] == scan_ids[2]
|
||||||
|
assert scan_ids[0] != scan_ids[1]
|
||||||
|
|
||||||
def test_validate_ocsf(self):
|
def test_validate_ocsf(self):
|
||||||
mock_file = StringIO()
|
mock_file = StringIO()
|
||||||
findings = [
|
findings = [
|
||||||
|
|||||||
Reference in New Issue
Block a user