mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-01-25 02:08:11 +00:00
fix tests
This commit is contained in:
@@ -64,6 +64,7 @@ class TestCheckLoader:
|
||||
checks_file = None
|
||||
check_list = None
|
||||
service_list = None
|
||||
sub_service_list = None
|
||||
severities = None
|
||||
compliance_frameworks = None
|
||||
categories = None
|
||||
@@ -83,6 +84,7 @@ class TestCheckLoader:
|
||||
checks_file,
|
||||
check_list,
|
||||
service_list,
|
||||
sub_service_list,
|
||||
severities,
|
||||
compliance_frameworks,
|
||||
categories,
|
||||
@@ -97,6 +99,7 @@ class TestCheckLoader:
|
||||
checks_file = None
|
||||
check_list = [S3_BUCKET_LEVEL_PUBLIC_ACCESS_BLOCK_NAME]
|
||||
service_list = None
|
||||
sub_service_list = None
|
||||
severities = None
|
||||
compliance_frameworks = None
|
||||
categories = None
|
||||
@@ -107,6 +110,7 @@ class TestCheckLoader:
|
||||
checks_file,
|
||||
check_list,
|
||||
service_list,
|
||||
sub_service_list,
|
||||
severities,
|
||||
compliance_frameworks,
|
||||
categories,
|
||||
@@ -121,6 +125,7 @@ class TestCheckLoader:
|
||||
checks_file = None
|
||||
check_list = []
|
||||
service_list = None
|
||||
sub_service_list = None
|
||||
severities = [S3_BUCKET_LEVEL_PUBLIC_ACCESS_BLOCK_SEVERITY]
|
||||
compliance_frameworks = None
|
||||
categories = None
|
||||
@@ -131,6 +136,7 @@ class TestCheckLoader:
|
||||
checks_file,
|
||||
check_list,
|
||||
service_list,
|
||||
sub_service_list,
|
||||
severities,
|
||||
compliance_frameworks,
|
||||
categories,
|
||||
@@ -145,6 +151,7 @@ class TestCheckLoader:
|
||||
checks_file = None
|
||||
check_list = []
|
||||
service_list = [S3_BUCKET_LEVEL_PUBLIC_ACCESS_BLOCK_NAME_SERVICE]
|
||||
sub_service_list = None
|
||||
severities = [S3_BUCKET_LEVEL_PUBLIC_ACCESS_BLOCK_SEVERITY]
|
||||
compliance_frameworks = None
|
||||
categories = None
|
||||
@@ -159,6 +166,7 @@ class TestCheckLoader:
|
||||
checks_file,
|
||||
check_list,
|
||||
service_list,
|
||||
sub_service_list,
|
||||
severities,
|
||||
compliance_frameworks,
|
||||
categories,
|
||||
@@ -175,6 +183,7 @@ class TestCheckLoader:
|
||||
checks_file = None
|
||||
check_list = []
|
||||
service_list = ["ec2"]
|
||||
sub_service_list = None
|
||||
severities = [S3_BUCKET_LEVEL_PUBLIC_ACCESS_BLOCK_SEVERITY]
|
||||
compliance_frameworks = None
|
||||
categories = None
|
||||
@@ -189,6 +198,7 @@ class TestCheckLoader:
|
||||
checks_file,
|
||||
check_list,
|
||||
service_list,
|
||||
sub_service_list,
|
||||
severities,
|
||||
compliance_frameworks,
|
||||
categories,
|
||||
@@ -205,6 +215,7 @@ class TestCheckLoader:
|
||||
checks_file = "path/to/test_file"
|
||||
check_list = []
|
||||
service_list = []
|
||||
sub_service_list = []
|
||||
severities = []
|
||||
compliance_frameworks = None
|
||||
categories = None
|
||||
@@ -219,6 +230,7 @@ class TestCheckLoader:
|
||||
checks_file,
|
||||
check_list,
|
||||
service_list,
|
||||
sub_service_list,
|
||||
severities,
|
||||
compliance_frameworks,
|
||||
categories,
|
||||
@@ -235,6 +247,7 @@ class TestCheckLoader:
|
||||
checks_file = None
|
||||
check_list = []
|
||||
service_list = [S3_BUCKET_LEVEL_PUBLIC_ACCESS_BLOCK_NAME_SERVICE]
|
||||
sub_service_list = []
|
||||
severities = []
|
||||
compliance_frameworks = None
|
||||
categories = None
|
||||
@@ -249,6 +262,7 @@ class TestCheckLoader:
|
||||
checks_file,
|
||||
check_list,
|
||||
service_list,
|
||||
sub_service_list,
|
||||
severities,
|
||||
compliance_frameworks,
|
||||
categories,
|
||||
@@ -265,6 +279,7 @@ class TestCheckLoader:
|
||||
checks_file = None
|
||||
check_list = []
|
||||
service_list = []
|
||||
sub_service_list = []
|
||||
severities = []
|
||||
compliance_frameworks = ["test-compliance-framework"]
|
||||
categories = None
|
||||
@@ -279,6 +294,7 @@ class TestCheckLoader:
|
||||
checks_file,
|
||||
check_list,
|
||||
service_list,
|
||||
sub_service_list,
|
||||
severities,
|
||||
compliance_frameworks,
|
||||
categories,
|
||||
@@ -295,6 +311,7 @@ class TestCheckLoader:
|
||||
checks_file = None
|
||||
check_list = []
|
||||
service_list = []
|
||||
sub_service_list = []
|
||||
severities = []
|
||||
compliance_frameworks = []
|
||||
categories = {"internet-exposed"}
|
||||
@@ -305,6 +322,7 @@ class TestCheckLoader:
|
||||
checks_file,
|
||||
check_list,
|
||||
service_list,
|
||||
sub_service_list,
|
||||
severities,
|
||||
compliance_frameworks,
|
||||
categories,
|
||||
|
||||
@@ -24,7 +24,13 @@ from prowler.lib.check.check import (
|
||||
remove_custom_checks_module,
|
||||
update_audit_metadata,
|
||||
)
|
||||
from prowler.lib.check.models import load_check_metadata
|
||||
from prowler.lib.check.models import (
|
||||
Check_Metadata_Model,
|
||||
Code,
|
||||
Recommendation,
|
||||
Remediation,
|
||||
load_check_metadata,
|
||||
)
|
||||
from prowler.providers.aws.aws_provider import AwsProvider
|
||||
from tests.providers.aws.utils import AWS_REGION_US_EAST_1
|
||||
|
||||
@@ -389,6 +395,40 @@ def mock_recover_checks_from_aws_provider(*_):
|
||||
]
|
||||
|
||||
|
||||
def mock_load_check_metadata(*_):
|
||||
return Check_Metadata_Model(
|
||||
Provider="aws",
|
||||
CheckID="ec2_securitygroup_allow_ingress_from_internet_to_any_port",
|
||||
CheckTitle="Ensure no security groups allow ingress from 0.0.0.0/0 or ::/0 to any port.",
|
||||
CheckType=["Static"],
|
||||
ServiceName="ec2",
|
||||
SubServiceName="SecurityGroup",
|
||||
ResourceIdTemplate="",
|
||||
Severity="low",
|
||||
ResourceType="SecurityGroup",
|
||||
Description="Ensure no security groups allow ingress from 0.0.0.0/0 or ::/0 to any port.",
|
||||
Risk="This check is LOW risk",
|
||||
RelatedUrl="",
|
||||
Remediation=Remediation(
|
||||
Code=Code(
|
||||
NativeIaC="",
|
||||
Terraform="",
|
||||
CLI="",
|
||||
Other="",
|
||||
),
|
||||
Recommendation=Recommendation(
|
||||
Text="",
|
||||
Url="",
|
||||
),
|
||||
),
|
||||
Categories=["secrets"],
|
||||
DependsOn=[],
|
||||
RelatedTo=[],
|
||||
Notes="",
|
||||
Compliance=None,
|
||||
)
|
||||
|
||||
|
||||
class TestCheck:
|
||||
def test_load_check_metadata(self):
|
||||
test_cases = [
|
||||
@@ -650,8 +690,9 @@ class TestCheck:
|
||||
"prowler.lib.check.check.recover_checks_from_provider",
|
||||
new=mock_recover_checks_from_aws_provider,
|
||||
)
|
||||
@patch("prowler.lib.check.check.load_check_metadata", new=mock_load_check_metadata)
|
||||
def test_recover_checks_from_subservice(self):
|
||||
subservice_list = ["securitygroup"]
|
||||
subservice_list = ["SecurityGroup"]
|
||||
provider = "aws"
|
||||
expected_checks = {
|
||||
"ec2_securitygroup_allow_ingress_from_internet_to_any_port",
|
||||
|
||||
Reference in New Issue
Block a user