chore(severities): Use enum (#5460)

This commit is contained in:
Pepe Fagoaga
2024-10-18 11:39:48 +02:00
committed by GitHub
parent 41e585643b
commit 8411fcb5fc
4 changed files with 10 additions and 12 deletions
-2
View File
@@ -21,8 +21,6 @@ gcp_logo = "https://user-images.githubusercontent.com/38561120/235928332-eb4accd
orange_color = "\033[38;5;208m"
banner_color = "\033[1;92m"
finding_statuses = ["PASS", "FAIL", "MANUAL"]
valid_severities = ["critical", "high", "medium", "low", "informational"]
# Compliance
actual_directory = pathlib.Path(os.path.dirname(os.path.realpath(__file__)))
+2 -2
View File
@@ -1,10 +1,10 @@
from colorama import Fore, Style
from prowler.config.config import valid_severities
from prowler.lib.check.check import (
parse_checks_from_compliance_framework,
parse_checks_from_file,
)
from prowler.lib.check.models import Severity
from prowler.lib.check.utils import (
recover_checks_from_provider,
recover_checks_from_service,
@@ -29,7 +29,7 @@ def load_checks_to_execute(
# Local subsets
checks_to_execute = set()
check_aliases = {}
check_severities = {key: [] for key in valid_severities}
check_severities = {severity.value: [] for severity in Severity}
check_categories = {}
# First, loop over the bulk_checks_metadata to extract the needed subsets
+2 -2
View File
@@ -3,7 +3,7 @@ import sys
import yaml
from jsonschema import validate
from prowler.config.config import valid_severities
from prowler.lib.check.models import Severity
from prowler.lib.logger import logger
custom_checks_metadata_schema = {
@@ -17,7 +17,7 @@ custom_checks_metadata_schema = {
"properties": {
"Severity": {
"type": "string",
"enum": valid_severities,
"enum": [severity.value for severity in Severity],
},
"CheckTitle": {
"type": "string",
+6 -6
View File
@@ -10,9 +10,9 @@ from prowler.config.config import (
default_config_file_path,
default_fixer_config_file_path,
default_output_directory,
finding_statuses,
valid_severities,
)
from prowler.lib.check.models import Severity
from prowler.lib.outputs.finding import Status
from prowler.providers.common.arguments import (
init_providers_parser,
validate_provider_arguments,
@@ -138,8 +138,8 @@ Detailed documentation at https://docs.prowler.com
common_outputs_parser.add_argument(
"--status",
nargs="+",
help=f"Filter by the status of the findings {finding_statuses}",
choices=finding_statuses,
help=f"Filter by the status of the findings {[status.value for status in Status]}",
choices=[status.value for status in Status],
)
common_outputs_parser.add_argument(
"--output-formats",
@@ -257,8 +257,8 @@ Detailed documentation at https://docs.prowler.com
"--severity",
"--severities",
nargs="+",
help=f"Severities to be executed {valid_severities}",
choices=valid_severities,
help=f"Severities to be executed {[severity.value for severity in Severity]}",
choices=[severity.value for severity in Severity],
)
group.add_argument(
"--compliance",