mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-10-30 15:24:22 +00:00
feat(ui): hide new overview route and filter mongo providers (#9314)
This commit is contained in:
1 parent
a63a3d3f68
commit
8e7e376e4f
33 files changed
+52
-160
No files matched your search
@@ -9,6 +9,46 @@ import {
|
||||
} from "@/lib/compliance/compliance-report-types";
|
||||
import { addScanOperation } from "@/lib/sentry-breadcrumbs";
|
||||
import { handleApiError, handleApiResponse } from "@/lib/server-actions-helper";
|
||||
import { ScansApiResponse } from "@/types";
|
||||
|
||||
const filterMongoScans = (result: ScansApiResponse | undefined) => {
|
||||
if (!result?.data) return result;
|
||||
|
||||
const included = result.included || [];
|
||||
|
||||
// Get IDs of providers containing "mongo"
|
||||
const mongoProviderIds = new Set(
|
||||
included
|
||||
.filter(
|
||||
(item) =>
|
||||
item.type === "providers" &&
|
||||
item.attributes?.provider?.toLowerCase().includes("mongo"),
|
||||
)
|
||||
.map((item) => item.id),
|
||||
);
|
||||
|
||||
// If no mongo providers found, return as-is
|
||||
if (mongoProviderIds.size === 0) return result;
|
||||
|
||||
// Filter out scans associated with mongo providers
|
||||
result.data = result.data.filter((scan) => {
|
||||
const providerId = scan.relationships?.provider?.data?.id;
|
||||
return !providerId || !mongoProviderIds.has(providerId);
|
||||
});
|
||||
|
||||
// Filter out mongo-related included items
|
||||
if (result.included) {
|
||||
result.included = included.filter(
|
||||
(item) =>
|
||||
!(
|
||||
item.type === "providers" &&
|
||||
item.attributes?.provider?.toLowerCase().includes("mongo")
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
export const getScans = async ({
|
||||
page = 1,
|
||||
@@ -44,7 +84,10 @@ export const getScans = async ({
|
||||
try {
|
||||
const response = await fetch(url.toString(), { headers });
|
||||
|
||||
return handleApiResponse(response);
|
||||
const result = await handleApiResponse(response);
|
||||
|
||||
// Filter out mongo-related scans when provider is included
|
||||
return filterMongoScans(result);
|
||||
} catch (error) {
|
||||
console.error("Error fetching scans:", error);
|
||||
return undefined;
|
||||
|
||||
Reference in new issue
Block a user