Skip to content
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

feat(ocsf): add OCSF format as JSON output for AWS, Azure and GCP. Hello Amazon Security Lake! #2429

Merged
merged 5 commits into from
Jun 7, 2023

Conversation

sergargar
Copy link
Member

Description

Add OCSF JSON as an output mode.
https://schema.ocsf.io/1.0.0-rc.3/classes/security_finding

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@sergargar sergargar marked this pull request as ready for review June 6, 2023 15:09
@sergargar sergargar requested a review from a team as a code owner June 6, 2023 15:09
@toniblyx toniblyx changed the title feat(oscf): add JSON OCSF output feat(oscf): add OCSF support in JSON output for AWS, Azure and GCP Jun 7, 2023
@toniblyx toniblyx changed the title feat(oscf): add OCSF support in JSON output for AWS, Azure and GCP feat(oscf): add OCSF format as JSON output for AWS, Azure and GCP. Hello Amazon Security Lake! Jun 7, 2023
@toniblyx toniblyx merged commit cdf2a13 into master Jun 7, 2023
4 checks passed
@toniblyx toniblyx deleted the ocsf-integration branch June 7, 2023 12:28
@@ -70,12 +85,147 @@ def fill_json_asff(finding_output, audit_info, finding, output_options):
return finding_output


def fill_json_ocsf(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please move this function to another file?

@@ -228,6 +229,18 @@ def unroll_dict(dict: dict):
return unrolled_items


def unroll_dict_to_list(dict: dict):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please include tests for this function? And move it to another file to be able to use from another places.

@@ -621,3 +634,115 @@ class Check_Output_JSON_ASFF(BaseModel):
Resources: List[Resource] = None
Compliance: Compliance = None
Remediation: dict = None


# JSON OCSF
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, move the OCSF specification model to another file.

version: str = "1.0.0-rc.3"


class Check_Output_JSON_OCSF(BaseModel):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why all the attributes have a default value? With that Pydantic makes no sense.

resource_uid = ""
finding_uid = ""
resource_labels = finding.resource_tags if finding.resource_tags else []
if finding.status == "PASS":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also you should split this function into several ones to fill the model, it's hard to follow it.

@@ -161,6 +163,19 @@ def report(check_findings, output_options, audit_info):
)
file_descriptors["json"].write(",")

if "json-ocsf" in file_descriptors:
finding_output = Check_Output_JSON_OCSF()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this? And why the fill doesn't return anything?

@sergargar sergargar changed the title feat(oscf): add OCSF format as JSON output for AWS, Azure and GCP. Hello Amazon Security Lake! feat(ocsf): add OCSF format as JSON output for AWS, Azure and GCP. Hello Amazon Security Lake! Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants