mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-01-25 02:08:11 +00:00
fix(ui): update severity trends endpoint and reorganize types (#9460)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { AttackSurfaceOverview, AttackSurfaceOverviewResponse } from "../types";
|
||||
import { AttackSurfaceOverview, AttackSurfaceOverviewResponse } from "./types";
|
||||
|
||||
const ATTACK_SURFACE_IDS = {
|
||||
INTERNET_EXPOSED: "internet-exposed",
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { apiBaseUrl, getAuthHeaders } from "@/lib";
|
||||
import { handleApiResponse } from "@/lib/server-actions-helper";
|
||||
|
||||
import { AttackSurfaceOverviewResponse } from "../types";
|
||||
import { AttackSurfaceOverviewResponse } from "./types";
|
||||
|
||||
export const getAttackSurfaceOverview = async ({
|
||||
filters = {},
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from "./attack-surface";
|
||||
export * from "./attack-surface.adapter";
|
||||
export * from "./types";
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// Attack Surface Overview Types
|
||||
// Corresponds to the /overviews/attack-surfaces endpoint
|
||||
|
||||
import { OverviewResponseMeta } from "./common";
|
||||
interface OverviewResponseMeta {
|
||||
version: string;
|
||||
}
|
||||
|
||||
export interface AttackSurfaceOverviewAttributes {
|
||||
total_findings: number;
|
||||
1
ui/actions/overview/attack-surface/types/index.ts
Normal file
1
ui/actions/overview/attack-surface/types/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./attack-surface.types";
|
||||
@@ -5,7 +5,7 @@ import { redirect } from "next/navigation";
|
||||
import { apiBaseUrl, getAuthHeaders } from "@/lib";
|
||||
import { handleApiResponse } from "@/lib/server-actions-helper";
|
||||
|
||||
import { FindingsSeverityOverviewResponse } from "../types";
|
||||
import { FindingsSeverityOverviewResponse } from "./types";
|
||||
|
||||
export const getFindingsByStatus = async ({
|
||||
page = 1,
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
export * from "./findings";
|
||||
export * from "./types";
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// Findings Severity Overview Types
|
||||
// Corresponds to the /overviews/findings_severity endpoint
|
||||
|
||||
import { OverviewResponseMeta } from "./common";
|
||||
interface OverviewResponseMeta {
|
||||
version: string;
|
||||
}
|
||||
|
||||
export interface FindingsSeverityAttributes {
|
||||
critical: number;
|
||||
1
ui/actions/overview/findings/types/index.ts
Normal file
1
ui/actions/overview/findings/types/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./findings.types";
|
||||
@@ -6,4 +6,3 @@ export * from "./regions";
|
||||
export * from "./services";
|
||||
export * from "./severity-trends";
|
||||
export * from "./threat-score";
|
||||
export * from "./types";
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from "./providers";
|
||||
export * from "./sankey.adapter";
|
||||
export * from "./types";
|
||||
|
||||
@@ -5,7 +5,7 @@ import { redirect } from "next/navigation";
|
||||
import { apiBaseUrl, getAuthHeaders } from "@/lib";
|
||||
import { handleApiResponse } from "@/lib/server-actions-helper";
|
||||
|
||||
import { ProvidersOverviewResponse } from "../types";
|
||||
import { ProvidersOverviewResponse } from "./types";
|
||||
|
||||
export const getProvidersOverview = async ({
|
||||
page = 1,
|
||||
|
||||
1
ui/actions/overview/providers/types/index.ts
Normal file
1
ui/actions/overview/providers/types/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./providers.types";
|
||||
@@ -1,7 +1,9 @@
|
||||
// Providers Overview Types
|
||||
// Corresponds to the /overviews/providers endpoint
|
||||
|
||||
import { OverviewResponseMeta } from "./common";
|
||||
interface OverviewResponseMeta {
|
||||
version: string;
|
||||
}
|
||||
|
||||
export interface ProviderOverviewFindings {
|
||||
pass: number;
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from "./regions";
|
||||
export * from "./threat-map.adapter";
|
||||
export * from "./types";
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { apiBaseUrl, getAuthHeaders } from "@/lib";
|
||||
import { handleApiResponse } from "@/lib/server-actions-helper";
|
||||
|
||||
import { RegionsOverviewResponse } from "../types";
|
||||
import { RegionsOverviewResponse } from "./types";
|
||||
|
||||
export const getRegionsOverview = async ({
|
||||
filters = {},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { getProviderDisplayName } from "@/types/providers";
|
||||
|
||||
import { RegionsOverviewResponse } from "../types";
|
||||
import { RegionsOverviewResponse } from "./types";
|
||||
|
||||
export interface ThreatMapLocation {
|
||||
id: string;
|
||||
|
||||
1
ui/actions/overview/regions/types/index.ts
Normal file
1
ui/actions/overview/regions/types/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./regions.types";
|
||||
@@ -1,7 +1,9 @@
|
||||
// Regions Overview Types
|
||||
// Corresponds to the /overviews/regions endpoint
|
||||
|
||||
import { OverviewResponseMeta } from "./common";
|
||||
interface OverviewResponseMeta {
|
||||
version: string;
|
||||
}
|
||||
|
||||
export interface RegionOverviewAttributes {
|
||||
provider_type: string;
|
||||
@@ -1 +1,2 @@
|
||||
export * from "./services";
|
||||
export * from "./types";
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { apiBaseUrl, getAuthHeaders } from "@/lib";
|
||||
import { handleApiResponse } from "@/lib/server-actions-helper";
|
||||
|
||||
import { ServicesOverviewResponse } from "../types";
|
||||
import { ServicesOverviewResponse } from "./types";
|
||||
|
||||
export const getServicesOverview = async ({
|
||||
filters = {},
|
||||
|
||||
1
ui/actions/overview/services/types/index.ts
Normal file
1
ui/actions/overview/services/types/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./services.types";
|
||||
@@ -1,7 +1,9 @@
|
||||
// Services Overview Types
|
||||
// Corresponds to the /overviews/services endpoint
|
||||
|
||||
import { OverviewResponseMeta } from "./common";
|
||||
interface OverviewResponseMeta {
|
||||
version: string;
|
||||
}
|
||||
|
||||
export interface ServiceOverviewAttributes {
|
||||
total: number;
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from "./severity-trends";
|
||||
export * from "./severity-trends.adapter";
|
||||
export * from "./types";
|
||||
|
||||
@@ -3,7 +3,7 @@ import { LineDataPoint } from "@/components/graphs/types";
|
||||
import {
|
||||
AdaptedSeverityTrendsResponse,
|
||||
FindingsSeverityOverTimeResponse,
|
||||
} from "../types";
|
||||
} from "./types";
|
||||
|
||||
export type { AdaptedSeverityTrendsResponse, FindingsSeverityOverTimeResponse };
|
||||
|
||||
@@ -11,7 +11,7 @@ export type { AdaptedSeverityTrendsResponse, FindingsSeverityOverTimeResponse };
|
||||
* Adapts the API findings severity over time response to the format expected by LineChart.
|
||||
* Transforms API response with nested attributes into flat LineDataPoint objects.
|
||||
*
|
||||
* @param response - The raw API response from /overviews/findings_severity_over_time
|
||||
* @param response - The raw API response from /overviews/findings_severity/timeseries
|
||||
* @returns Adapted response with LineDataPoint array ready for the chart
|
||||
*/
|
||||
export function adaptSeverityTrendsResponse(
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
import { apiBaseUrl, getAuthHeaders } from "@/lib";
|
||||
import { handleApiResponse } from "@/lib/server-actions-helper";
|
||||
|
||||
import { adaptSeverityTrendsResponse } from "./severity-trends.adapter";
|
||||
import {
|
||||
AdaptedSeverityTrendsResponse,
|
||||
FindingsSeverityOverTimeResponse,
|
||||
} from "../types";
|
||||
import { adaptSeverityTrendsResponse } from "./severity-trends.adapter";
|
||||
} from "./types";
|
||||
|
||||
const TIME_RANGE_VALUES = {
|
||||
FIVE_DAYS: "5D",
|
||||
@@ -35,7 +35,7 @@ const getFindingsSeverityTrends = async ({
|
||||
} = {}): Promise<SeverityTrendsResult> => {
|
||||
const headers = await getAuthHeaders({ contentType: false });
|
||||
|
||||
const url = new URL(`${apiBaseUrl}/overviews/findings_severity_over_time`);
|
||||
const url = new URL(`${apiBaseUrl}/overviews/findings_severity/timeseries`);
|
||||
|
||||
Object.entries(filters).forEach(([key, value]) => {
|
||||
if (value !== undefined) {
|
||||
|
||||
1
ui/actions/overview/severity-trends/types/index.ts
Normal file
1
ui/actions/overview/severity-trends/types/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./severity-trends.types";
|
||||
@@ -1 +1,2 @@
|
||||
export * from "./threat-score";
|
||||
export * from "./types";
|
||||
|
||||
1
ui/actions/overview/threat-score/types/index.ts
Normal file
1
ui/actions/overview/threat-score/types/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./threat-score.types";
|
||||
@@ -1,5 +0,0 @@
|
||||
// Common types shared across overview endpoints
|
||||
|
||||
export interface OverviewResponseMeta {
|
||||
version: string;
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
export * from "./attack-surface";
|
||||
export * from "./common";
|
||||
export * from "./findings-severity";
|
||||
export * from "./providers";
|
||||
export * from "./regions";
|
||||
export * from "./services";
|
||||
export * from "./severity-trends";
|
||||
export * from "./threat-score";
|
||||
@@ -5,7 +5,7 @@ import { MessageCircleWarning, ThumbsUp } from "lucide-react";
|
||||
import type {
|
||||
CriticalRequirement,
|
||||
SectionScores,
|
||||
} from "@/actions/overview/types";
|
||||
} from "@/actions/overview/threat-score";
|
||||
import { RadialChart } from "@/components/graphs/radial-chart";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/shadcn";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user