diff --git a/src/backend/api/filters.py b/src/backend/api/filters.py index 257cf368fa..756fb6276a 100644 --- a/src/backend/api/filters.py +++ b/src/backend/api/filters.py @@ -318,26 +318,6 @@ class FindingFilter(FilterSet): }, } - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - - data = self.data - if not data or ( - not data.get("scan") - and not data.get("scan__in") - and not data.get("inserted_at") - and not data.get("inserted_at.date") - and not data.get("inserted_at__gte") - and not data.get("inserted_at__lte") - ): - self.add_default_filter() - - def add_default_filter(self): - utc_now = datetime.now(timezone.utc) - start = uuid7_start(datetime_to_uuid7(utc_now)) - - self.queryset = self.queryset.filter(id__gte=start) - # Convert filter values to UUIDv7 values for use with partitioning def filter_scan_id(self, queryset, name, value): diff --git a/src/backend/api/fixtures/3_dev_scans.json b/src/backend/api/fixtures/3_dev_scans.json index f9f3b04735..e34c047b86 100644 --- a/src/backend/api/fixtures/3_dev_scans.json +++ b/src/backend/api/fixtures/3_dev_scans.json @@ -15,10 +15,10 @@ "accessanalyzer_enabled" ] }, - "inserted_at": "2024-09-01T17:24:27.050Z", - "started_at": "2024-09-01T17:24:27.050Z", - "updated_at": "2024-09-01T17:24:27.050Z", - "completed_at": "2024-09-01T17:24:37.050Z" + "inserted_at": "2024-09-01T17:25:27.050Z", + "started_at": "2024-09-01T17:25:27.050Z", + "updated_at": "2024-09-01T17:25:27.050Z", + "completed_at": "2024-09-01T17:25:32.050Z" } }, { @@ -59,10 +59,10 @@ "cloudsql_instance_automated_backups" ] }, - "inserted_at": "2024-09-02T19:24:27.050Z", - "started_at": "2024-09-02T19:24:27.050Z", - "updated_at": "2024-09-02T19:24:27.050Z", - "completed_at": "2024-09-01T17:24:37.050Z" + "inserted_at": "2024-09-02T19:26:27.050Z", + "started_at": "2024-09-02T19:26:27.050Z", + "updated_at": "2024-09-02T19:26:27.050Z", + "completed_at": "2024-09-01T17:26:37.050Z" } }, { @@ -81,10 +81,10 @@ "accessanalyzer_enabled" ] }, - "inserted_at": "2024-09-02T19:24:27.050Z", - "started_at": "2024-09-02T19:24:27.050Z", - "updated_at": "2024-09-02T19:24:27.050Z", - "completed_at": "2024-09-01T17:24:37.050Z" + "inserted_at": "2024-09-02T19:27:27.050Z", + "started_at": "2024-09-02T19:27:27.050Z", + "updated_at": "2024-09-02T19:27:27.050Z", + "completed_at": "2024-09-01T17:27:37.050Z" } }, { @@ -121,9 +121,9 @@ "cloudformation_stack_outputs_find_secrets" ] }, - "scheduled_at": "2030-08-02T19:20:27.050Z", - "inserted_at": "2024-09-02T19:24:27.050Z", - "updated_at": "2024-09-02T19:24:27.050Z" + "scheduled_at": "2030-08-02T19:31:27.050Z", + "inserted_at": "2024-09-02T19:38:27.050Z", + "updated_at": "2024-09-02T19:38:27.050Z" } }, { @@ -141,9 +141,9 @@ "iam_audit_logs_enabled" ] }, - "scheduled_at": "2030-07-02T19:20:27.050Z", - "inserted_at": "2024-09-02T19:24:27.050Z", - "updated_at": "2024-09-02T19:24:27.050Z" + "scheduled_at": "2030-07-02T19:30:27.050Z", + "inserted_at": "2024-09-02T19:29:27.050Z", + "updated_at": "2024-09-02T19:29:27.050Z" } }, { @@ -161,9 +161,9 @@ "defender_additional_email_configured_with_a_security_contact" ] }, - "scheduled_at": "2030-08-05T19:20:27.050Z", - "inserted_at": "2024-09-02T19:24:27.050Z", - "updated_at": "2024-09-02T19:24:27.050Z" + "scheduled_at": "2030-08-05T19:32:27.050Z", + "inserted_at": "2024-09-02T19:29:27.050Z", + "updated_at": "2024-09-02T19:29:27.050Z" } } ] diff --git a/src/backend/api/v1/views.py b/src/backend/api/v1/views.py index 4f692ea9a7..a05e7b42f1 100644 --- a/src/backend/api/v1/views.py +++ b/src/backend/api/v1/views.py @@ -729,9 +729,7 @@ class ResourceViewSet(BaseRLSViewSet): list=extend_schema( tags=["Finding"], summary="List all findings", - description="Retrieve a list of all findings with options for filtering by various criteria. " - "If no `scan` or `inserted_at` filter is provided, a default filter will be applied that will " - "return all findings for the current day.", + description="Retrieve a list of all findings with options for filtering by various criteria.", ), retrieve=extend_schema( tags=["Finding"], @@ -746,10 +744,7 @@ class FindingViewSet(BaseRLSViewSet): serializer_class = FindingSerializer http_method_names = ["get"] filterset_class = FindingFilter - # Default sort order will put failed findings first - # and then by severity - # and then by most recently inserted via the id field - ordering = ["status", "severity", "-id"] + ordering = ["-id"] ordering_fields = [ "id", "status",