Skip to content

Commit

Permalink
🎉 added component to AWSSecurityHub (#9161)
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-sommer committed Dec 22, 2023
1 parent 8f1b610 commit 8bfd358
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion dojo/tools/awssecurityhub/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ def get_item(finding: dict, test):

title_suffix = ""
for resource in finding.get("Resources", []):
if resource.get("Type") == "AwsEcrContainerImage":
component_name = resource.get("Type")
if component_name == "AwsEcrContainerImage":
details = resource.get("Details", {}).get("AwsEcrContainerImage")
arn = resource.get("Id")
if details:
Expand Down Expand Up @@ -137,6 +138,7 @@ def get_item(finding: dict, test):
is_mitigated=is_Mitigated,
static_finding=True,
dynamic_finding=False,
component_name=component_name,
)
# Add the unsaved vulnerability ids
result.unsaved_vulnerability_ids = unsaved_vulnerability_ids
Expand Down
4 changes: 4 additions & 0 deletions unittests/tools/test_awssecurityhub_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def test_many_findings(self):
parser = AwsSecurityHubParser()
findings = parser.get_findings(test_file, Test())
self.assertEqual(3, len(findings))
finding = findings[0]
self.assertEqual(finding.component_name, "AwsAccount")

def test_repeated_findings(self):
with open(get_unit_tests_path() + sample_path("config_repeated_findings.json")) as test_file:
Expand Down Expand Up @@ -70,6 +72,8 @@ def test_inspector_ec2_with_no_vulnerabilities(self):
parser = AwsSecurityHubParser()
findings = parser.get_findings(test_file, Test())
self.assertEqual(1, len(findings))
finding = findings[0]
self.assertEqual(finding.component_name, "AwsEc2Instance")

def test_inspector_ec2_ghsa(self):
with open(get_unit_tests_path() + sample_path("inspector_ec2_ghsa.json")) as test_file:
Expand Down

0 comments on commit 8bfd358

Please sign in to comment.