Skip to content

Commit

Permalink
chore(ec2): add name from image information to status_extended (#5758)
Browse files Browse the repository at this point in the history
Co-authored-by: Rubén De la Torre Vico <[email protected]>
  • Loading branch information
prowler-bot and puchy22 authored Nov 13, 2024
1 parent 17a04a5 commit f604ab7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ def execute(self):
report.resource_arn = image.arn
report.resource_tags = image.tags
report.status = "PASS"
report.status_extended = f"EC2 AMI {image.id} is not public."
report.status_extended = (
f"EC2 AMI {image.name if image.name else image.id} is not public."
)
if image.public:
report.status = "FAIL"
report.status_extended = f"EC2 AMI {image.id} is currently public."
report.resource_id = image.id
report.status_extended = f"EC2 AMI {image.name if image.name else image.id} is currently public."

findings.append(report)

Expand Down
2 changes: 1 addition & 1 deletion prowler/providers/aws/services/ec2/ec2_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def _describe_images(self, regional_client):
Image(
id=image["ImageId"],
arn=arn,
name=image.get("Name", None),
name=image.get("Name", ""),
public=image.get("Public", False),
region=regional_client.region,
tags=image.get("Tags"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_one_private_ami(self):

assert len(result) == 1
assert result[0].status == "PASS"
assert result[0].status_extended == f"EC2 AMI {image_id} is not public."
assert result[0].status_extended == "EC2 AMI test-ami is not public."
assert result[0].resource_id == image_id
assert (
result[0].resource_arn
Expand Down Expand Up @@ -124,9 +124,7 @@ def test_one_public_ami(self):

assert len(result) == 1
assert result[0].status == "FAIL"
assert (
result[0].status_extended == f"EC2 AMI {image_id} is currently public."
)
assert result[0].status_extended == "EC2 AMI test-ami is currently public."
assert result[0].resource_id == image_id
assert (
result[0].resource_arn
Expand Down

0 comments on commit f604ab7

Please sign in to comment.