mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-23 12:31:54 +00:00
chore(Finding): PRWLR-5059 Remove default filtering and change default ordering (#54)
This commit is contained in:
committed by
GitHub
parent
351132fb5b
commit
60c75b4814
@@ -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):
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user