chore(resource-based scan): execute only applicable checks (#1934)

This commit is contained in:
Sergio Garcia
2023-02-23 13:30:21 +01:00
committed by GitHub
parent 4b935a40b6
commit 849b703828
3 changed files with 74 additions and 14 deletions

View File

@@ -9,6 +9,7 @@ from prowler.lib.check.check import (
exclude_checks_to_run,
exclude_services_to_run,
get_checks_from_input_arn,
get_regions_from_audit_resources,
list_modules,
list_services,
parse_checks_from_file,
@@ -288,14 +289,27 @@ class Test_Check:
def test_get_checks_from_input_arn(self):
audit_resources = ["arn:aws:lambda:us-east-1:123456789:function:test-lambda"]
provider = "aws"
expected_checks = {
"awslambda_function_url_cors_policy",
expected_checks = [
"awslambda_function_invoke_api_operations_cloudtrail_logging_enabled",
"awslambda_function_no_secrets_in_code",
}
"awslambda_function_url_cors_policy",
]
recovered_checks = get_checks_from_input_arn(audit_resources, provider)
assert recovered_checks == expected_checks
def test_get_regions_from_audit_resources(self):
audit_resources = [
"arn:aws:lambda:us-east-1:123456789:function:test-lambda",
"arn:aws:iam::106908755756:policy/test",
"arn:aws:ec2:eu-west-1:106908755756:security-group/sg-test",
]
expected_regions = [
"us-east-1",
"eu-west-1",
]
recovered_regions = get_regions_from_audit_resources(audit_resources)
assert recovered_regions == expected_regions
# def test_parse_checks_from_compliance_framework_two(self):
# test_case = {
# "input": {"compliance_frameworks": ["cis_v1.4_aws", "ens_v3_aws"]},