mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-23 12:31:54 +00:00
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:
committed by
GitHub
parent
cfd2165b26
commit
11ca3b59bc
@@ -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]:
|
||||
|
||||
@@ -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 = [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user