mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-04 19:21:51 +00:00
fix(ui): show kubeconfig exec auth warning
This commit is contained in:
@@ -1,13 +1,28 @@
|
||||
"use client";
|
||||
|
||||
import { Control } from "react-hook-form";
|
||||
import { useWatch } from "react-hook-form";
|
||||
|
||||
import { WizardTextareaField } from "@/components/providers/workflow/forms/fields";
|
||||
import { KubernetesCredentials } from "@/types";
|
||||
import {
|
||||
KUBECONFIG_EXEC_AUTHENTICATION_ERROR,
|
||||
kubeconfigContainsExecAuthentication,
|
||||
} from "@/types/formSchemas";
|
||||
|
||||
export const KubernetesCredentialsForm = ({
|
||||
control,
|
||||
}: {
|
||||
control: Control<KubernetesCredentials>;
|
||||
}) => {
|
||||
const kubeconfigContent = useWatch({
|
||||
control,
|
||||
name: "kubeconfig_content",
|
||||
});
|
||||
const hasExecAuthentication = kubeconfigContainsExecAuthentication(
|
||||
kubeconfigContent ?? "",
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex flex-col">
|
||||
@@ -28,6 +43,11 @@ export const KubernetesCredentialsForm = ({
|
||||
minRows={10}
|
||||
isRequired
|
||||
/>
|
||||
{hasExecAuthentication && (
|
||||
<p className="text-text-error-primary text-xs">
|
||||
{KUBECONFIG_EXEC_AUTHENTICATION_ERROR}
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -6,14 +6,16 @@ import { validateMutelistYaml, validateYaml } from "@/lib/yaml";
|
||||
|
||||
import { PROVIDER_TYPES, ProviderType } from "./providers";
|
||||
|
||||
const KUBECONFIG_EXEC_AUTHENTICATION_ERROR =
|
||||
export const KUBECONFIG_EXEC_AUTHENTICATION_ERROR =
|
||||
"Kubernetes kubeconfig exec authentication is not supported in Prowler Cloud for security reasons.";
|
||||
|
||||
const isRecord = (value: unknown): value is Record<string, unknown> => {
|
||||
return typeof value === "object" && value !== null && !Array.isArray(value);
|
||||
};
|
||||
|
||||
const kubeconfigContainsExecAuthentication = (value: string): boolean => {
|
||||
export const kubeconfigContainsExecAuthentication = (
|
||||
value: string,
|
||||
): boolean => {
|
||||
try {
|
||||
const parsed = yaml.load(value);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user