Compare commits

...

1 Commits

Author SHA1 Message Date
Pepe Fagoaga
e4622a794a chore(scan): prepare for excluded_checks 2025-04-28 11:39:19 +02:00
3 changed files with 19 additions and 3 deletions

View File

@@ -1326,6 +1326,7 @@ class ScanViewSet(BaseRLSViewSet):
"provider_id": str(scan.provider_id),
# Disabled for now
# checks_to_execute=scan.scanner_args.get("checks_to_execute"),
# excluded_checks=scan.scanner_args.get("excluded_checks")
},
)

View File

@@ -100,7 +100,11 @@ def _store_resources(
def perform_prowler_scan(
tenant_id: str, scan_id: str, provider_id: str, checks_to_execute: list[str] = None
tenant_id: str,
scan_id: str,
provider_id: str,
checks_to_execute: list[str] = None,
excluded_checks: list[str] = None,
):
"""
Perform a scan using Prowler and store the findings and resources in the database.
@@ -110,6 +114,7 @@ def perform_prowler_scan(
scan_id (str): The ID of the scan instance.
provider_id (str): The ID of the provider to scan.
checks_to_execute (list[str], optional): A list of specific checks to execute. Defaults to None.
excluded_checks (list[str], optional): A list of checks to exclude from the scan. Defaults to None.
Returns:
dict: Serialized data of the completed scan instance.
@@ -146,7 +151,11 @@ def perform_prowler_scan(
)
provider_instance.save()
prowler_scan = ProwlerScan(provider=prowler_provider, checks=checks_to_execute)
prowler_scan = ProwlerScan(
provider=prowler_provider,
checks=checks_to_execute,
excluded_checks=excluded_checks,
)
resource_cache = {}
tag_cache = {}

View File

@@ -69,7 +69,11 @@ def delete_provider_task(provider_id: str, tenant_id: str):
@shared_task(base=RLSTask, name="scan-perform", queue="scans")
def perform_scan_task(
tenant_id: str, scan_id: str, provider_id: str, checks_to_execute: list[str] = None
tenant_id: str,
scan_id: str,
provider_id: str,
checks_to_execute: list[str] = None,
excluded_checks: list[str] = None,
):
"""
Task to perform a Prowler scan on a given provider.
@@ -83,6 +87,7 @@ def perform_scan_task(
scan_id (str): The ID of the scan to be performed.
provider_id (str): The primary key of the Provider instance to scan.
checks_to_execute (list[str], optional): A list of specific checks to perform during the scan. Defaults to None.
excluded_checks (list[str], optional): A list of specific checks to exclude from the scan. Defaults to None.
Returns:
dict: The result of the scan execution, typically including the status and results of the performed checks.
@@ -92,6 +97,7 @@ def perform_scan_task(
scan_id=scan_id,
provider_id=provider_id,
checks_to_execute=checks_to_execute,
excluded_checks=excluded_checks,
)
chain(