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

fix(ecs): Adjust code to the new ARN formats in the ECS service #5259

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
6 changes: 3 additions & 3 deletions prowler/providers/aws/services/ecs/ecs_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _list_task_definitions(self, regional_client):
):
self.task_definitions[task_definition] = TaskDefinition(
# we want the family name without the revision
name=sub(":.*", "", task_definition.split("/")[1]),
name=sub(":.*", "", task_definition.split("/")[-1]),
arn=task_definition,
revision=task_definition.split(":")[-1],
region=regional_client.region,
Expand Down Expand Up @@ -111,7 +111,7 @@ def _describe_services(self, cluster):
service_desc = describe_response["services"][0]
service_arn = service_desc["serviceArn"]
service_obj = Service(
name=sub(":.*", "", service_arn.split("/")[2]),
name=sub(":.*", "", service_arn.split("/")[-1]),
arn=service_arn,
region=cluster.region,
assign_public_ip=(
Expand Down Expand Up @@ -139,7 +139,7 @@ def _list_clusters(self, regional_client):
is_resource_filtered(cluster, self.audit_resources)
):
self.clusters[cluster] = Cluster(
name=sub(":.*", "", cluster.split("/")[1]),
name=sub(":.*", "", cluster.split("/")[-1]),
arn=cluster,
region=regional_client.region,
)
Expand Down
6 changes: 3 additions & 3 deletions tests/providers/aws/services/ecs/ecs_service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def mock_make_api_call(self, operation_name, kwarg):
if operation_name == "ListTaskDefinitions":
return {
"taskDefinitionArns": [
"arn:aws:ecs:eu-west-1:123456789012:task-definition/test_ecs_task:1"
"arn:aws:ecs:eu-west-1:123456789012:task-definition/test_cluster_1/test_ecs_task:1"
]
}
if operation_name == "DescribeTaskDefinition":
Expand Down Expand Up @@ -117,7 +117,7 @@ def test_list_task_definitions(self):
aws_provider = set_mocked_aws_provider()
ecs = ECS(aws_provider)

task_arn = "arn:aws:ecs:eu-west-1:123456789012:task-definition/test_ecs_task:1"
task_arn = "arn:aws:ecs:eu-west-1:123456789012:task-definition/test_cluster_1/test_ecs_task:1"

assert len(ecs.task_definitions) == 1
assert ecs.task_definitions[task_arn].name == "test_ecs_task"
Expand All @@ -131,7 +131,7 @@ def test_describe_task_definitions(self):
aws_provider = set_mocked_aws_provider()
ecs = ECS(aws_provider)

task_arn = "arn:aws:ecs:eu-west-1:123456789012:task-definition/test_ecs_task:1"
task_arn = "arn:aws:ecs:eu-west-1:123456789012:task-definition/test_cluster_1/test_ecs_task:1"

assert len(ecs.task_definitions) == 1
assert ecs.task_definitions[task_arn].name == "test_ecs_task"
Expand Down
Loading