feat(json-ocsf): Add new fields for py-ocsf 0.1.0 (#3853)

This commit is contained in:
Pedro Martín
2024-04-25 12:47:28 +02:00
committed by GitHub
parent 469254094b
commit ee46bf3809
16 changed files with 322 additions and 295 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ def generate_finding_output(status, severity, muted, region) -> FindingOutput:
account_email="",
account_organization_uid="test-organization-id",
account_organization_name="test-organization",
account_tags="",
account_tags=["test-tag:test-value"],
finding_uid="test-unique-finding",
provider="aws",
check_id="test-check-id",
@@ -73,6 +73,9 @@ class TestOutputJSONOCSF:
assert finding_json_ocsf.status_code == finding_output.status
assert finding_json_ocsf.status_detail == finding_output.status_extended
# Risk
assert finding_json_ocsf.risk_details == finding_output.risk
# Unmapped Data
assert finding_json_ocsf.unmapped == {
"check_type": finding_output.check_type,
@@ -129,6 +132,7 @@ class TestOutputJSONOCSF:
assert cloud_account.type_id == TypeID.AWS_Account
assert cloud_account.type == TypeID.AWS_Account.name
assert cloud_account.uid == finding_output.account_uid
assert cloud_account.labels == finding_output.account_tags
cloud_organization = cloud.org
assert isinstance(cloud_organization, Organization)
+2 -2
View File
@@ -265,7 +265,7 @@ class TestAWSProvider:
assert isinstance(aws_provider.organizations_metadata, AWSOrganizationsInfo)
assert aws_provider.organizations_metadata.account_email == "master@example.com"
assert aws_provider.organizations_metadata.account_name == "master"
assert aws_provider.organizations_metadata.account_tags == "tagged:true"
assert aws_provider.organizations_metadata.account_tags == ["tagged:true"]
assert (
aws_provider.organizations_metadata.organization_account_arn
== f"arn:aws:organizations::{AWS_ACCOUNT_NUMBER}:account/{organization['Id']}/{AWS_ACCOUNT_NUMBER}"
@@ -333,7 +333,7 @@ class TestAWSProvider:
assert isinstance(aws_provider.organizations_metadata, AWSOrganizationsInfo)
assert aws_provider.organizations_metadata.account_email == "master@example.com"
assert aws_provider.organizations_metadata.account_name == "master"
assert aws_provider.organizations_metadata.account_tags == "tagged:true"
assert aws_provider.organizations_metadata.account_tags == ["tagged:true"]
assert (
aws_provider.organizations_metadata.organization_account_arn
== f"arn:aws:organizations::{AWS_ACCOUNT_NUMBER}:account/{organization['Id']}/{AWS_ACCOUNT_NUMBER}"
@@ -42,7 +42,7 @@ class Test_AWS_Organizations:
== f"arn:aws:organizations::{AWS_ACCOUNT_NUMBER}:organization/{org_id}"
)
assert org.organization_id == org_id
assert org.account_tags == "key:value"
assert org.account_tags == ["key:value"]
def test_parse_organizations_metadata(self):
tags = {"Tags": [{"Key": "test-key", "Value": "test-value"}]}
@@ -70,4 +70,4 @@ class Test_AWS_Organizations:
== f"arn:aws:organizations::{AWS_ACCOUNT_NUMBER}:account/{organization_name}/{AWS_ACCOUNT_NUMBER}"
)
assert org.organization_arn == arn
assert org.account_tags == "test-key:test-value"
assert org.account_tags == ["test-key:test-value"]
+3 -3
View File
@@ -28,7 +28,7 @@ class TestGCPProvider:
number="55555555",
id="project/55555555",
name="test-project",
labels="",
labels=["test:value"],
lifecycle_state="",
)
}
@@ -73,7 +73,7 @@ class TestGCPProvider:
number="55555555",
id="project/55555555",
name="test-project",
labels="",
labels=["test:value"],
lifecycle_state="",
)
}
@@ -140,7 +140,7 @@ class TestGCPProvider:
number="55555555",
id="project/55555555",
name="test-project",
labels="",
labels=["test:value"],
lifecycle_state="",
)
}