Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

chore(ec2): add name from image information to status_extended #5758

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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