Add actions to fetch data from Prowler Hub

This commit is contained in:
Chandrapal Badshah
2025-06-04 15:33:19 +05:30
committed by Pepe Fagoaga
parent 788b092dff
commit 6259df4f8c
2 changed files with 59 additions and 0 deletions
+45
View File
@@ -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;
};
@@ -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;
};