From 6259df4f8c1990d0beceafe5cbc14bad193935b3 Mon Sep 17 00:00:00 2001 From: Chandrapal Badshah <12944530+Chan9390@users.noreply.github.com> Date: Wed, 4 Jun 2025 15:33:19 +0530 Subject: [PATCH] Add actions to fetch data from Prowler Hub --- ui/actions/lighthouse/checks.ts | 45 +++++++++++++++++++ ui/actions/lighthouse/complianceframeworks.ts | 14 ++++++ 2 files changed, 59 insertions(+) create mode 100644 ui/actions/lighthouse/checks.ts create mode 100644 ui/actions/lighthouse/complianceframeworks.ts diff --git a/ui/actions/lighthouse/checks.ts b/ui/actions/lighthouse/checks.ts new file mode 100644 index 0000000000..e933ff3567 --- /dev/null +++ b/ui/actions/lighthouse/checks.ts @@ -0,0 +1,45 @@ +export const getLighthouseProviderChecks = async ({ + providerType, + service, + severity, + compliances, +}: { + providerType: string; + service: string[]; + severity: string[]; + compliances: string[]; +}) => { + const url = new URL( + `https://hub.prowler.com/api/check?fields=id&providers=${providerType}`, + ); + if (service) { + url.searchParams.append("services", service.join(",")); + } + if (severity) { + url.searchParams.append("severities", severity.join(",")); + } + if (compliances) { + url.searchParams.append("compliances", compliances.join(",")); + } + + const response = await fetch(url.toString(), { + method: "GET", + }); + + const data = await response.json(); + const ids = data.map((item: { id: string }) => item.id); + return ids; +}; + +export const getLighthouseCheckDetails = async ({ + checkId, +}: { + checkId: string; +}) => { + const url = new URL(`https://hub.prowler.com/api/check/${checkId}`); + const response = await fetch(url.toString(), { + method: "GET", + }); + const data = await response.json(); + return data; +}; diff --git a/ui/actions/lighthouse/complianceframeworks.ts b/ui/actions/lighthouse/complianceframeworks.ts new file mode 100644 index 0000000000..e6eecd2ea7 --- /dev/null +++ b/ui/actions/lighthouse/complianceframeworks.ts @@ -0,0 +1,14 @@ +export const getLighthouseComplianceFrameworks = async ( + provider_type: string, +) => { + const url = new URL( + `https://hub.prowler.com/api/compliance?fields=id&provider=${provider_type}`, + ); + const response = await fetch(url.toString(), { + method: "GET", + }); + + const data = await response.json(); + const frameworks = data.map((item: { id: string }) => item.id); + return frameworks; +};