fix(reports): change invalid search term for tasks (#7830)

This commit is contained in:
Adrián Jesús Peña Rodríguez
2025-05-26 10:24:11 +02:00
committed by GitHub
parent 91545e409e
commit 50bcd828e9
3 changed files with 39 additions and 1 deletions
+7
View File
@@ -9,6 +9,13 @@ All notable changes to the **Prowler API** are documented in this file.
---
## [v1.8.2] (Prowler v5.7.2)
### Fixed
- Fixed task lookup to use task_kwargs instead of task_args for scan report resolution. [(#7830)](https://github.com/prowler-cloud/prowler/pull/7830)
---
## [v1.8.1] (Prowler v5.7.1)
### Fixed
+31
View File
@@ -13,6 +13,7 @@ from botocore.exceptions import ClientError, NoCredentialsError
from conftest import API_JSON_CONTENT_TYPE, TEST_PASSWORD, TEST_USER
from django.conf import settings
from django.urls import reverse
from django_celery_results.models import TaskResult
from rest_framework import status
from api.compliance import get_compliance_frameworks
@@ -2600,6 +2601,36 @@ class TestScanViewSet:
assert response.status_code == status.HTTP_404_NOT_FOUND
@patch("api.v1.views.TaskSerializer")
def test__get_task_status_finds_task_using_kwargs(
self, mock_task_serializer, authenticated_client, scans_fixture
):
scan = scans_fixture[0]
scan.state = StateChoices.COMPLETED
scan.output_location = "dummy"
scan.save()
task_result = TaskResult.objects.create(
task_name="scan-report",
task_kwargs={"scan_id": str(scan.id)},
)
task = Task.objects.create(
tenant_id=scan.tenant_id,
task_runner_task=task_result,
)
mock_task_serializer.return_value.data = {
"id": str(task.id),
"state": StateChoices.EXECUTING,
}
url = reverse("scan-report", kwargs={"pk": scan.id})
response = authenticated_client.get(url)
assert response.status_code == status.HTTP_202_ACCEPTED
assert response.data["id"] == str(task.id)
@patch("api.v1.views.get_s3_client")
@patch("api.v1.views.sentry_sdk.capture_exception")
def test_compliance_list_objects_client_error(
+1 -1
View File
@@ -1281,7 +1281,7 @@ class ScanViewSet(BaseRLSViewSet):
try:
task = Task.objects.get(
task_runner_task__task_name="scan-report",
task_runner_task__task_args__contains=str(scan_instance.id),
task_runner_task__task_kwargs__contains=str(scan_instance.id),
)
except Task.DoesNotExist:
return None