Merge branch 'master' into PRWLR-7160-findings-page-scan-id-filter-improvement

# Conflicts:
#	ui/CHANGELOG.md
#	ui/app/(prowler)/compliance/page.tsx
#	ui/types/components.ts
This commit is contained in:
sumit_chaturvedi committed 2025-06-03 12:17:29 +05:30
commit d2d68ded2b
108 files changed
+5916 -1193

No files matched your search

+74 -1
View File
@@ -30,7 +30,6 @@ export const getCompliancesOverview = async ({
});
const data = await compliances.json();
const parsedData = parseStringify(data);
revalidatePath("/compliance");
return parsedData;
} catch (error) {
@@ -79,3 +78,77 @@ export const getComplianceOverviewMetadataInfo = async ({
return undefined;
}
};
export const getComplianceAttributes = async (complianceId: string) => {
const headers = await getAuthHeaders({ contentType: false });
try {
const url = new URL(`${apiBaseUrl}/compliance-overviews/attributes`);
url.searchParams.append("filter[compliance_id]", complianceId);
const response = await fetch(url.toString(), {
headers,
});
if (!response.ok) {
throw new Error(
`Failed to fetch compliance attributes: ${response.statusText}`,
);
}
const data = await response.json();
const parsedData = parseStringify(data);
return parsedData;
} catch (error) {
// eslint-disable-next-line no-console
console.error("Error fetching compliance attributes:", error);
return undefined;
}
// */
};
export const getComplianceRequirements = async ({
complianceId,
scanId,
region,
}: {
complianceId: string;
scanId: string;
region?: string | string[];
}) => {
const headers = await getAuthHeaders({ contentType: false });
try {
const url = new URL(`${apiBaseUrl}/compliance-overviews/requirements`);
url.searchParams.append("filter[compliance_id]", complianceId);
url.searchParams.append("filter[scan_id]", scanId);
if (region) {
const regionValue = Array.isArray(region) ? region.join(",") : region;
url.searchParams.append("filter[region__in]", regionValue);
//remove page param
}
url.searchParams.delete("page");
const response = await fetch(url.toString(), {
headers,
});
if (!response.ok) {
throw new Error(
`Failed to fetch compliance requirements: ${response.statusText}`,
);
}
const data = await response.json();
const parsedData = parseStringify(data);
return parsedData;
} catch (error) {
// eslint-disable-next-line no-console
console.error("Error fetching compliance requirements:", error);
return undefined;
}
// */
};
+54 -17
View File
@@ -10,7 +10,7 @@ import {
parseStringify,
wait,
} from "@/lib";
import { ProvidersApiResponse } from "@/types/providers";
import { ProvidersApiResponse, ProviderType } from "@/types/providers";
export const getProviders = async ({
page = 1,
@@ -110,7 +110,7 @@ export const updateProvider = async (formData: FormData) => {
export const addProvider = async (formData: FormData) => {
const headers = await getAuthHeaders({ contentType: true });
const providerType = formData.get("providerType") as string;
const providerType = formData.get("providerType") as ProviderType;
const providerUid = formData.get("providerUid") as string;
const providerAlias = formData.get("providerAlias") as string;
@@ -152,9 +152,10 @@ export const addCredentialsProvider = async (formData: FormData) => {
const secretName = formData.get("secretName");
const providerId = formData.get("providerId");
const providerType = formData.get("providerType");
const providerType = formData.get("providerType") as ProviderType;
const isRole = formData.get("role_arn") !== null;
const isServiceAccount = formData.get("service_account_key") !== null;
let secret = {};
let secretType = "static"; // Default to static credentials
@@ -199,19 +200,36 @@ export const addCredentialsProvider = async (formData: FormData) => {
password: formData.get("password"),
};
} else if (providerType === "gcp") {
// Static credentials configuration for GCP
secret = {
client_id: formData.get("client_id"),
client_secret: formData.get("client_secret"),
refresh_token: formData.get("refresh_token"),
};
if (isServiceAccount) {
// Service account configuration for GCP
secretType = "service_account";
const serviceAccountKeyRaw = formData.get(
"service_account_key",
) as string;
try {
const serviceAccountKey = JSON.parse(serviceAccountKeyRaw);
secret = {
service_account_key: serviceAccountKey,
};
} catch (error) {
// eslint-disable-next-line no-console
console.error("error", error);
}
} else {
// Static credentials configuration for GCP
secret = {
client_id: formData.get("client_id"),
client_secret: formData.get("client_secret"),
refresh_token: formData.get("refresh_token"),
};
}
} else if (providerType === "kubernetes") {
// Static credentials configuration for Kubernetes
secret = {
kubeconfig_content: formData.get("kubeconfig_content"),
};
}
const bodyData = {
data: {
type: "provider-secrets",
@@ -257,9 +275,10 @@ export const updateCredentialsProvider = async (
const url = new URL(`${apiBaseUrl}/providers/secrets/${credentialsId}`);
const secretName = formData.get("secretName");
const providerType = formData.get("providerType");
const providerType = formData.get("providerType") as ProviderType;
const isRole = formData.get("role_arn") !== null;
const isServiceAccount = formData.get("service_account_key") !== null;
let secret = {};
@@ -302,12 +321,30 @@ export const updateCredentialsProvider = async (
password: formData.get("password"),
};
} else if (providerType === "gcp") {
// Static credentials configuration for GCP
secret = {
client_id: formData.get("client_id"),
client_secret: formData.get("client_secret"),
refresh_token: formData.get("refresh_token"),
};
if (isServiceAccount) {
// Service account configuration for GCP
const serviceAccountKeyRaw = formData.get(
"service_account_key",
) as string;
try {
// Parse the service account key as JSON
const serviceAccountKey = JSON.parse(serviceAccountKeyRaw);
secret = {
service_account_key: serviceAccountKey,
};
} catch (error) {
// eslint-disable-next-line no-console
console.error("error", error);
}
} else {
// Static credentials configuration for GCP
secret = {
client_id: formData.get("client_id"),
client_secret: formData.get("client_secret"),
refresh_token: formData.get("refresh_token"),
};
}
} else if (providerType === "kubernetes") {
// Static credentials configuration for Kubernetes
secret = {