Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
apply suggestions
Matheus Nogueira932effcb9370
diff --git a/backend/src/services/app-connection/hpe-ilo/hpe-ilo-connection-fns.ts b/backend/src/services/app-connection/hpe-ilo/hpe-ilo-connection-fns.tsindex 65c00f15e9..068f74f219 100644--- a/backend/src/services/app-connection/hpe-ilo/hpe-ilo-connection-fns.ts+++ b/backend/src/services/app-connection/hpe-ilo/hpe-ilo-connection-fns.ts@@ -1,4 +1,5 @@import { AxiosRequestConfig, HttpStatusCode, isAxiosError } from "axios";+import net from "net";import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";import { BadRequestError } from "@app/lib/errors";@@ -22,8 +23,11 @@ export const getHpeIloConnectionListItem = () => {};};+// IPv6 literals must be bracketed in URLs and Host headers+const toUrlHost = (hostname: string) => (net.isIPv6(hostname) ? `[${hostname}]` : hostname);+const getHpeIloBaseUrl = (credentials: THpeIloConnectionConfig["credentials"]) =>- `https://${credentials.hostname}:${credentials.port ?? HPE_ILO_DEFAULT_PORT}`;+ `https://${toUrlHost(credentials.hostname)}:${credentials.port ?? HPE_ILO_DEFAULT_PORT}`;const getHpeIloAuthHeaders = ({ username, password }: THpeIloConnectionConfig["credentials"]) => ({Authorization: `Basic ${Buffer.from(`${username}:${password}`).toString("base64")}`,@@ -70,7 +74,7 @@ export const executeHpeIloRequest = async <T>(...requestCfg,...tlsOptions,url: `https://localhost:${proxyPort}${requestCfg.url ?? ""}`,- headers: { ...headers, Host: hostname },+ headers: { ...headers, Host: toUrlHost(hostname) },// the hop is the local gateway proxy, and the iLO it reaches sits in the gateway's networkallowPrivateIps: true});diff --git a/backend/src/services/app-connection/hpe-ilo/hpe-ilo-connection-schemas.ts b/backend/src/services/app-connection/hpe-ilo/hpe-ilo-connection-schemas.tsindex f63d016df0..faf63fa89e 100644--- a/backend/src/services/app-connection/hpe-ilo/hpe-ilo-connection-schemas.ts+++ b/backend/src/services/app-connection/hpe-ilo/hpe-ilo-connection-schemas.ts@@ -1,6 +1,8 @@import z from "zod";import { AppConnections } from "@app/lib/api-docs";+import { isValidIp } from "@app/lib/ip";+import { isValidHostname } from "@app/lib/validator/validate-hostname";import { AppConnection } from "@app/services/app-connection/app-connection-enums";import {BaseAppConnectionSchema,@@ -17,13 +19,10 @@ export const HpeIloConnectionBasicAuthCredentialsSchema = z.object({.trim().min(1, "Hostname is required").max(512, "Hostname cannot exceed 512 characters")- .refine(- (val) =>- !val.includes("/") && !val.includes("@") && !val.includes("?") && !val.includes(":") && !val.includes("#"),- {- message: "Hostname must be a hostname or IP address without a scheme, port, or path"- }- )+ // IPv6 zone IDs (fe80::1%eth0) are rejected because they cannot be placed in the request URL+ .refine((val) => isValidHostname(val) || (isValidIp(val) && !val.includes("%")), {+ message: "Hostname must be a hostname or IP address without a scheme, port, brackets, or path"+ }).describe(AppConnections.CREDENTIALS.HPE_ILO.hostname),port: z.number().int().min(1).max(65535).optional().describe(AppConnections.CREDENTIALS.HPE_ILO.port),username: zdiff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/HpeIloConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/HpeIloConnectionForm.tsxindex 1e4936eee5..6df97126dd 100644--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/HpeIloConnectionForm.tsx+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/HpeIloConnectionForm.tsx@@ -33,6 +33,7 @@ import { GatewayPicker } from "@app/components/v3/platform/GatewayPicker";import { OrgPermissionSubjects } from "@app/context";import { OrgGatewayPermissionActions } from "@app/context/OrgPermissionContext/types";import { APP_CONNECTION_MAP, getAppConnectionMethodDetails } from "@app/helpers/appConnections";+import { isIPv4, isIPv6 } from "@app/helpers/ip";import { useScopeVariant } from "@app/hooks";import { HpeIloConnectionMethod, THpeIloConnection } from "@app/hooks/api/appConnections";import { AppConnection } from "@app/hooks/api/appConnections/enums";@@ -48,6 +49,12 @@ type Props = {onSubmit: (formData: FormData) => Promise<void>;};+const isValidHostname = (value: string) =>+ value.length <= 253 &&+ /^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(+ value+ );+const rootSchema = genericAppConnectionFieldsSchema.extend({app: z.literal(AppConnection.HpeIloRedFish)});@@ -61,9 +68,12 @@ const formSchema = z.discriminatedUnion("method", [.trim().min(1, "Hostname is required").max(512, "Hostname cannot exceed 512 characters")- .refine((val) => !/[/@?:#]/.test(val), {- message: "Enter a hostname or IP address without a scheme, port, or path"- }),+ .refine(+ (val) => isValidHostname(val) || isIPv4(val) || (isIPv6(val) && !val.includes("%")),+ {+ message: "Enter a hostname or IP address without a scheme, port, brackets, or path"+ }+ ),port: z.union([z.coerce.number().int().min(1).max(65535), z.literal("")]).optional()@@ -95,16 +105,24 @@ export const HpeIloConnectionForm = ({ appConnection, onSubmit }: Props) => {const form = useForm<FormData>({resolver: zodResolver(formSchema),- defaultValues: appConnection ?? {- app: AppConnection.HpeIloRedFish,- method: HpeIloConnectionMethod.BasicAuth,- gatewayId: null,- gatewayPoolId: null,- credentials: {- sslRejectUnauthorized: true,- sslCertificate: undefined- }- }+ defaultValues: appConnection+ ? {+ ...appConnection,+ credentials: {+ ...appConnection.credentials,+ sslRejectUnauthorized: appConnection.credentials.sslRejectUnauthorized ?? true+ }+ }+ : {+ app: AppConnection.HpeIloRedFish,+ method: HpeIloConnectionMethod.BasicAuth,+ gatewayId: null,+ gatewayPoolId: null,+ credentials: {+ sslRejectUnauthorized: true,+ sslCertificate: undefined+ }+ }});const { handleSubmit, control, setValue, watch } = form;@@ -285,7 +303,6 @@ export const HpeIloConnectionForm = ({ appConnection, onSubmit }: Props) => {</FieldLabel><TextAreaid="ssl-certificate"- className="h-[3.6rem] resize-none!"{...field}placeholder="-----BEGIN CERTIFICATE----- ... -----END CERTIFICATE-----"isError={Boolean(error?.message)}