mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-12 07:45:16 +00:00
feat(tags): add resource tags in A services (#1997)
This commit is contained in:
@@ -31,7 +31,7 @@ class Test_accessanalyzer_enabled:
|
||||
arn="",
|
||||
name="012345678910",
|
||||
status="NOT_AVAILABLE",
|
||||
tags="",
|
||||
tags=[],
|
||||
type="",
|
||||
region="eu-west-1",
|
||||
)
|
||||
@@ -62,7 +62,7 @@ class Test_accessanalyzer_enabled:
|
||||
arn="",
|
||||
name="012345678910",
|
||||
status="NOT_AVAILABLE",
|
||||
tags="",
|
||||
tags=[],
|
||||
type="",
|
||||
region="eu-west-1",
|
||||
),
|
||||
@@ -70,7 +70,7 @@ class Test_accessanalyzer_enabled:
|
||||
arn="",
|
||||
name="Test Analyzer",
|
||||
status="ACTIVE",
|
||||
tags="",
|
||||
tags=[],
|
||||
type="",
|
||||
region="eu-west-2",
|
||||
),
|
||||
@@ -112,7 +112,7 @@ class Test_accessanalyzer_enabled:
|
||||
arn="",
|
||||
name="Test Analyzer",
|
||||
status="ACTIVE",
|
||||
tags="",
|
||||
tags=[],
|
||||
type="",
|
||||
region="eu-west-2",
|
||||
)
|
||||
|
||||
@@ -32,7 +32,7 @@ class Test_accessanalyzer_enabled_without_findings:
|
||||
arn="",
|
||||
name="012345678910",
|
||||
status="NOT_AVAILABLE",
|
||||
tags="",
|
||||
tags=[],
|
||||
type="",
|
||||
region="eu-west-1",
|
||||
)
|
||||
@@ -63,7 +63,7 @@ class Test_accessanalyzer_enabled_without_findings:
|
||||
arn="",
|
||||
name="012345678910",
|
||||
status="NOT_AVAILABLE",
|
||||
tags="",
|
||||
tags=[],
|
||||
type="",
|
||||
region="eu-west-1",
|
||||
),
|
||||
@@ -81,7 +81,7 @@ class Test_accessanalyzer_enabled_without_findings:
|
||||
status="ARCHIVED",
|
||||
),
|
||||
],
|
||||
tags="",
|
||||
tags=[],
|
||||
type="",
|
||||
region="eu-west-2",
|
||||
),
|
||||
@@ -123,7 +123,7 @@ class Test_accessanalyzer_enabled_without_findings:
|
||||
arn="",
|
||||
name="Test Analyzer",
|
||||
status="ACTIVE",
|
||||
tags="",
|
||||
tags=[],
|
||||
type="",
|
||||
region="eu-west-2",
|
||||
)
|
||||
@@ -157,7 +157,7 @@ class Test_accessanalyzer_enabled_without_findings:
|
||||
arn="",
|
||||
name="012345678910",
|
||||
status="NOT_AVAILABLE",
|
||||
tags="",
|
||||
tags=[],
|
||||
type="",
|
||||
region="eu-west-1",
|
||||
),
|
||||
|
||||
@@ -30,7 +30,7 @@ def mock_make_api_call(self, operation_name, kwarg):
|
||||
"name": "Test Analyzer",
|
||||
"status": "ACTIVE",
|
||||
"findings": 0,
|
||||
"tags": "",
|
||||
"tags": {"test": "test"},
|
||||
"type": "ACCOUNT",
|
||||
"region": "eu-west-1",
|
||||
}
|
||||
@@ -92,7 +92,7 @@ class Test_AccessAnalyzer_Service:
|
||||
assert access_analyzer.analyzers[0].arn == "ARN"
|
||||
assert access_analyzer.analyzers[0].name == "Test Analyzer"
|
||||
assert access_analyzer.analyzers[0].status == "ACTIVE"
|
||||
assert access_analyzer.analyzers[0].tags == ""
|
||||
assert access_analyzer.analyzers[0].tags == [{"test": "test"}]
|
||||
assert access_analyzer.analyzers[0].type == "ACCOUNT"
|
||||
assert access_analyzer.analyzers[0].region == AWS_REGION
|
||||
|
||||
|
||||
@@ -67,6 +67,14 @@ def mock_make_api_call(self, operation_name, kwargs):
|
||||
"Options": {"CertificateTransparencyLoggingPreference": "DISABLED"},
|
||||
}
|
||||
}
|
||||
if operation_name == "ListTagsForCertificate":
|
||||
if kwargs["CertificateArn"] == certificate_arn:
|
||||
return {
|
||||
"Tags": [
|
||||
{"Key": "test", "Value": "test"},
|
||||
]
|
||||
}
|
||||
|
||||
return make_api_call(self, operation_name, kwargs)
|
||||
|
||||
|
||||
@@ -163,3 +171,21 @@ class Test_ACM_Service:
|
||||
assert acm.certificates[0].expiration_days == 365
|
||||
assert acm.certificates[0].transparency_logging is False
|
||||
assert acm.certificates[0].region == AWS_REGION
|
||||
|
||||
# Test ACM List Tags
|
||||
# @mock_acm
|
||||
def test__list_tags_for_certificate__(self):
|
||||
# Generate ACM Client
|
||||
# acm_client = client("acm", region_name=AWS_REGION)
|
||||
# Request ACM certificate
|
||||
# certificate = acm_client.request_certificate(
|
||||
# DomainName="test.com",
|
||||
# )
|
||||
|
||||
# ACM client for this test class
|
||||
audit_info = self.set_mocked_audit_info()
|
||||
acm = ACM(audit_info)
|
||||
assert len(acm.certificates) == 1
|
||||
assert acm.certificates[0].tags == [
|
||||
{"Key": "test", "Value": "test"},
|
||||
]
|
||||
|
||||
@@ -106,7 +106,6 @@ class Test_apigateway_client_certificate_enabled:
|
||||
|
||||
@mock_apigateway
|
||||
def test_apigateway_one_stage_with_certificate(self):
|
||||
|
||||
# Create APIGateway Mocked Resources
|
||||
apigateway_client = client("apigateway", region_name=AWS_REGION)
|
||||
# Create APIGateway Deployment Stage
|
||||
@@ -131,8 +130,8 @@ class Test_apigateway_client_certificate_enabled:
|
||||
|
||||
service_client.rest_apis[0].stages.append(
|
||||
Stage(
|
||||
"test",
|
||||
f"arn:{current_audit_info.audited_partition}:apigateway:{AWS_REGION}::/apis/test-rest-api/stages/test",
|
||||
name="test",
|
||||
arn=f"arn:{current_audit_info.audited_partition}:apigateway:{AWS_REGION}::/apis/test-rest-api/stages/test",
|
||||
logging=True,
|
||||
client_certificate=True,
|
||||
waf=True,
|
||||
|
||||
@@ -108,12 +108,15 @@ class Test_APIGateway_Service:
|
||||
apigateway_client = client("apigateway", region_name=AWS_REGION)
|
||||
# Create private APIGateway Rest API
|
||||
apigateway_client.create_rest_api(
|
||||
name="test-rest-api", endpointConfiguration={"types": ["PRIVATE"]}
|
||||
name="test-rest-api",
|
||||
endpointConfiguration={"types": ["PRIVATE"]},
|
||||
tags={"test": "test"},
|
||||
)
|
||||
# APIGateway client for this test class
|
||||
audit_info = self.set_mocked_audit_info()
|
||||
apigateway = APIGateway(audit_info)
|
||||
assert apigateway.rest_apis[0].public_endpoint is False
|
||||
assert apigateway.rest_apis[0].tags == [{"test": "test"}]
|
||||
|
||||
# Test APIGateway Get Stages
|
||||
@mock_apigateway
|
||||
|
||||
@@ -102,11 +102,14 @@ class Test_ApiGatewayV2_Service:
|
||||
# Generate ApiGatewayV2 Client
|
||||
apigatewayv2_client = client("apigatewayv2", region_name=AWS_REGION)
|
||||
# Create ApiGatewayV2 API
|
||||
apigatewayv2_client.create_api(Name="test-api", ProtocolType="HTTP")
|
||||
apigatewayv2_client.create_api(
|
||||
Name="test-api", ProtocolType="HTTP", Tags={"test": "test"}
|
||||
)
|
||||
# ApiGatewayV2 client for this test class
|
||||
audit_info = self.set_mocked_audit_info()
|
||||
apigatewayv2 = ApiGatewayV2(audit_info)
|
||||
assert len(apigatewayv2.apis) == len(apigatewayv2_client.get_apis()["Items"])
|
||||
assert apigatewayv2.apis[0].tags == [{"test": "test"}]
|
||||
|
||||
# Test ApiGatewayV2 Get Authorizers
|
||||
@mock_apigatewayv2
|
||||
|
||||
@@ -43,6 +43,8 @@ def mock_make_api_call(self, operation_name, kwarg):
|
||||
},
|
||||
]
|
||||
}
|
||||
if operation_name == "ListTagsForResource":
|
||||
return {"Tags": {"test": "test"}}
|
||||
return make_api_call(self, operation_name, kwarg)
|
||||
|
||||
|
||||
@@ -102,3 +104,13 @@ class Test_AppStream_Service:
|
||||
assert appstream.fleets[1].idle_disconnect_timeout_in_seconds == 900
|
||||
assert appstream.fleets[1].enable_default_internet_access is True
|
||||
assert appstream.fleets[1].region == AWS_REGION
|
||||
|
||||
def test__list_tags_for_resource__(self):
|
||||
# Set partition for the service
|
||||
current_audit_info.audited_partition = "aws"
|
||||
appstream = AppStream(current_audit_info)
|
||||
assert len(appstream.fleets) == 2
|
||||
|
||||
assert appstream.fleets[0].tags == [{"test": "test"}]
|
||||
|
||||
assert appstream.fleets[1].tags == [{"test": "test"}]
|
||||
|
||||
@@ -137,6 +137,7 @@ class Test_Lambda_Service:
|
||||
"SubnetIds": ["subnet-123abc"],
|
||||
},
|
||||
Environment={"Variables": {"db-password": "test-password"}},
|
||||
Tags={"test": "test"},
|
||||
)
|
||||
# Update Lambda Policy
|
||||
lambda_policy = {
|
||||
@@ -218,6 +219,8 @@ class Test_Lambda_Service:
|
||||
lambda_name
|
||||
].url_config.cors_config.allow_origins == ["*"]
|
||||
|
||||
assert awslambda.functions[lambda_name].tags == [{"test": "test"}]
|
||||
|
||||
# Pending ZipFile tests
|
||||
with tempfile.TemporaryDirectory() as tmp_dir_name:
|
||||
awslambda.functions[lambda_name].code.code_zip.extractall(tmp_dir_name)
|
||||
|
||||
Reference in New Issue
Block a user