mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-10-09 21:14:22 +00:00
feat(cli): add --resource-group flag to filter checks by resource group (#10479)
Co-authored-by: Daniel Barranquero <danielbo2001@gmail.com>
This commit is contained in:
co-authored by
Daniel Barranquero
parent
7b0ce7842b
commit
269d9dfe41
@@ -81,6 +81,7 @@ class Test_Parser:
|
||||
assert not parsed.severity
|
||||
assert not parsed.compliance
|
||||
assert len(parsed.category) == 0
|
||||
assert len(parsed.resource_group) == 0
|
||||
assert not parsed.excluded_check
|
||||
assert not parsed.excluded_service
|
||||
assert not parsed.excluded_checks_file
|
||||
@@ -89,6 +90,7 @@ class Test_Parser:
|
||||
assert not parsed.list_compliance
|
||||
assert not parsed.list_compliance_requirements
|
||||
assert not parsed.list_categories
|
||||
assert not parsed.list_resource_groups
|
||||
assert not parsed.profile
|
||||
assert not parsed.role
|
||||
assert parsed.session_duration == 3600
|
||||
@@ -131,6 +133,7 @@ class Test_Parser:
|
||||
assert not parsed.severity
|
||||
assert not parsed.compliance
|
||||
assert len(parsed.category) == 0
|
||||
assert len(parsed.resource_group) == 0
|
||||
assert not parsed.excluded_check
|
||||
assert not parsed.excluded_service
|
||||
assert not parsed.excluded_checks_file
|
||||
@@ -139,6 +142,7 @@ class Test_Parser:
|
||||
assert not parsed.list_compliance
|
||||
assert not parsed.list_compliance_requirements
|
||||
assert not parsed.list_categories
|
||||
assert not parsed.list_resource_groups
|
||||
assert len(parsed.subscription_id) == 0
|
||||
assert not parsed.az_cli_auth
|
||||
assert parsed.sp_env_auth
|
||||
@@ -173,6 +177,7 @@ class Test_Parser:
|
||||
assert not parsed.severity
|
||||
assert not parsed.compliance
|
||||
assert len(parsed.category) == 0
|
||||
assert len(parsed.resource_group) == 0
|
||||
assert not parsed.excluded_check
|
||||
assert not parsed.excluded_service
|
||||
assert not parsed.excluded_checks_file
|
||||
@@ -181,6 +186,7 @@ class Test_Parser:
|
||||
assert not parsed.list_compliance
|
||||
assert not parsed.list_compliance_requirements
|
||||
assert not parsed.list_categories
|
||||
assert not parsed.list_resource_groups
|
||||
assert not parsed.credentials_file
|
||||
|
||||
def test_default_parser_no_arguments_kubernetes(self):
|
||||
@@ -210,6 +216,7 @@ class Test_Parser:
|
||||
assert not parsed.severity
|
||||
assert not parsed.compliance
|
||||
assert len(parsed.category) == 0
|
||||
assert len(parsed.resource_group) == 0
|
||||
assert not parsed.excluded_check
|
||||
assert not parsed.excluded_service
|
||||
assert not parsed.excluded_checks_file
|
||||
@@ -218,6 +225,7 @@ class Test_Parser:
|
||||
assert not parsed.list_compliance
|
||||
assert not parsed.list_compliance_requirements
|
||||
assert not parsed.list_categories
|
||||
assert not parsed.list_resource_groups
|
||||
assert parsed.kubeconfig_file == "~/.kube/config"
|
||||
assert not parsed.context
|
||||
assert not parsed.namespace
|
||||
@@ -723,6 +731,32 @@ class Test_Parser:
|
||||
assert category_1 in parsed.category
|
||||
assert category_2 in parsed.category
|
||||
|
||||
def test_checks_parser_resource_group(self):
|
||||
argument = "--resource-group"
|
||||
resource_group = "storage"
|
||||
command = [prowler_command, argument, resource_group]
|
||||
parsed = self.parser.parse(command)
|
||||
assert len(parsed.resource_group) == 1
|
||||
assert resource_group in parsed.resource_group
|
||||
|
||||
def test_checks_parser_resource_groups_alias(self):
|
||||
argument = "--resource-groups"
|
||||
resource_group = "storage"
|
||||
command = [prowler_command, argument, resource_group]
|
||||
parsed = self.parser.parse(command)
|
||||
assert len(parsed.resource_group) == 1
|
||||
assert resource_group in parsed.resource_group
|
||||
|
||||
def test_checks_parser_resource_groups_two(self):
|
||||
argument = "--resource-group"
|
||||
resource_group_1 = "storage"
|
||||
resource_group_2 = "compute"
|
||||
command = [prowler_command, argument, resource_group_1, resource_group_2]
|
||||
parsed = self.parser.parse(command)
|
||||
assert len(parsed.resource_group) == 2
|
||||
assert resource_group_1 in parsed.resource_group
|
||||
assert resource_group_2 in parsed.resource_group
|
||||
|
||||
def test_list_checks_parser_list_checks_short(self):
|
||||
argument = "-l"
|
||||
command = [prowler_command, argument]
|
||||
@@ -759,6 +793,12 @@ class Test_Parser:
|
||||
parsed = self.parser.parse(command)
|
||||
assert parsed.list_categories
|
||||
|
||||
def test_list_checks_parser_list_resource_groups(self):
|
||||
argument = "--list-resource-groups"
|
||||
command = [prowler_command, argument]
|
||||
parsed = self.parser.parse(command)
|
||||
assert parsed.list_resource_groups
|
||||
|
||||
def test_list_checks_parser_list_fixers(self):
|
||||
argument = "--list-fixers"
|
||||
command = [prowler_command, argument]
|
||||
|
||||
Reference in New Issue
Block a user