fix(tags): handle AWS dictionary type tags (#4685)

Co-authored-by: Sergio Garcia <38561120+sergargar@users.noreply.github.com>
Co-authored-by: Sergio <sergio@prowler.com>
This commit is contained in:
github-actions[bot]
2024-08-07 16:53:39 +02:00
committed by GitHub
parent cfd2165b26
commit 11ca3b59bc
2 changed files with 21 additions and 0 deletions
+6
View File
@@ -59,8 +59,14 @@ def unroll_tags(tags: list) -> dict:
>>> tags = []
>>> unroll_tags(tags)
{}
>>> tags = {"name": "John", "age": "30"}
>>> unroll_tags(tags)
{'name': 'John', 'age': '30'}
"""
if tags and tags != [{}] and tags != [None]:
if isinstance(tags, dict):
return tags
if "key" in tags[0]:
return {item["key"]: item["value"] for item in tags}
elif "Key" in tags[0]:
+15
View File
@@ -106,6 +106,21 @@ class TestOutputs:
"terraform": "true",
}
def test_unroll_dict_tags(self):
tags_dict = {
"environment": "dev",
"name": "test",
"project": "prowler",
"terraform": "true",
}
assert unroll_tags(tags_dict) == {
"environment": "dev",
"name": "test",
"project": "prowler",
"terraform": "true",
}
def test_unroll_tags_unique(self):
unique_dict_list = [
{