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
requested changes
Daniel2b370a675ed3
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex bff1f558bb..e09b964a56 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -2988,7 +2988,9 @@ export const SecretSyncs = {teamName:"The name of the team to sync the secrets to. This is an optional field only intended for display purposes.",targetEnvironments:- 'An array of Vercel environments to add shared environment variables to. Include the value "all-custom-environments" to apply variables to all custom environments in the team.',+ "An optional array of Vercel default environments (development, preview, production) to add shared environment variables to.",+ applyToAllCustomEnvironments:+ "Whether to apply shared environment variables to all custom environments in the team.",targetProjects: "An optional array of Vercel projects to add shared environment variables to.",sensitive:"Whether to create Vercel environment variables as Sensitive (cannot be read back). Not allowed when targeting the Development environment."diff --git a/backend/src/services/secret-sync/aws-parameter-store/aws-parameter-store-sync-fns.ts b/backend/src/services/secret-sync/aws-parameter-store/aws-parameter-store-sync-fns.tsindex 695640f52b..3cd799e5e4 100644--- a/backend/src/services/secret-sync/aws-parameter-store/aws-parameter-store-sync-fns.ts+++ b/backend/src/services/secret-sync/aws-parameter-store/aws-parameter-store-sync-fns.ts@@ -470,7 +470,7 @@ export const AwsParameterStoreSyncFns = {if (!(key in secretMap) || !secretMap[key].value) {parametersToDelete.push(parameter);- deletedSecretKeys.push(parameter.Name!);+ deletedSecretKeys.push(parameter.Name);}}diff --git a/backend/src/services/secret-sync/vercel/vercel-sync-enums.ts b/backend/src/services/secret-sync/vercel/vercel-sync-enums.tsindex 5de25d4577..de6f2f127d 100644--- a/backend/src/services/secret-sync/vercel/vercel-sync-enums.ts+++ b/backend/src/services/secret-sync/vercel/vercel-sync-enums.ts@@ -6,8 +6,7 @@ export enum VercelSyncScope {export const VercelEnvironmentType = {Development: "development",Preview: "preview",- Production: "production",- AllCustomEnvironments: "all-custom-environments"+ Production: "production"} as const;export type VercelEnvironment = (typeof VercelEnvironmentType)[keyof typeof VercelEnvironmentType];diff --git a/backend/src/services/secret-sync/vercel/vercel-sync-fns.ts b/backend/src/services/secret-sync/vercel/vercel-sync-fns.tsindex d8cee192ed..c12896f3f2 100644--- a/backend/src/services/secret-sync/vercel/vercel-sync-fns.ts+++ b/backend/src/services/secret-sync/vercel/vercel-sync-fns.ts@@ -485,20 +485,14 @@ const createTeamSharedEnvVar = async (});}- // Derive applyToAllCustomEnvironments from the sentinel value in targetEnvironments.- const applyToAllCustomEnvironments = destinationConfig.targetEnvironments?.includes(- VercelEnvironmentType.AllCustomEnvironments+ // When sensitive is enabled, the Development environment is not supported by Vercel.+ const effectiveTargetEnvironments = destinationConfig.targetEnvironments?.filter(+ (env) => !destinationConfig.sensitive || env !== VercelEnvironmentType.Development);- // Strip the sentinel and, when sensitive is enabled, the Development environment before- // sending to Vercel — neither is a valid value in the `target` array.- const effectiveTargetEnvironments = destinationConfig.targetEnvironments- ?.filter((env) => env !== VercelEnvironmentType.AllCustomEnvironments)- .filter((env) => !destinationConfig.sensitive || env !== VercelEnvironmentType.Development);-if (destinationConfig.sensitive &&- !applyToAllCustomEnvironments &&+ !destinationConfig.applyToAllCustomEnvironments &&(!effectiveTargetEnvironments || effectiveTargetEnvironments.length === 0)) {throw new SecretSyncError({@@ -520,7 +514,7 @@ const createTeamSharedEnvVar = async (type: destinationConfig.sensitive ? "sensitive" : "encrypted",...(effectiveTargetEnvironments?.length ? { target: effectiveTargetEnvironments } : {}),...(destinationConfig.targetProjects !== undefined ? { projectId: destinationConfig.targetProjects } : {}),- applyToAllCustomEnvironments: Boolean(applyToAllCustomEnvironments)+ applyToAllCustomEnvironments: Boolean(destinationConfig.applyToAllCustomEnvironments)},{headers: {@@ -569,21 +563,14 @@ const updateTeamSharedEnvVar = async (const isExistingSensitive = envVar.type === "sensitive";- // Derive applyToAllCustomEnvironments from the sentinel value in targetEnvironments.- const applyToAllCustomEnvironments = destinationConfig.targetEnvironments?.includes(- VercelEnvironmentType.AllCustomEnvironments+ // When sensitive is enabled, the Development environment is not supported by Vercel.+ const effectiveTargetEnvironments = destinationConfig.targetEnvironments?.filter(+ (env) => !(destinationConfig.sensitive || isExistingSensitive) || env !== VercelEnvironmentType.Development);- // Strip the sentinel and, when sensitive is enabled, the Development environment.- const effectiveTargetEnvironments = destinationConfig.targetEnvironments- ?.filter((env) => env !== VercelEnvironmentType.AllCustomEnvironments)- .filter(- (env) => !(destinationConfig.sensitive || isExistingSensitive) || env !== VercelEnvironmentType.Development- );-if ((destinationConfig.sensitive || isExistingSensitive) &&- !applyToAllCustomEnvironments &&+ !destinationConfig.applyToAllCustomEnvironments &&(!effectiveTargetEnvironments || effectiveTargetEnvironments.length === 0)) {throw new SecretSyncError({@@ -604,9 +591,9 @@ const updateTeamSharedEnvVar = async (updates: {[envVar.id]: {value,- ...(effectiveTargetEnvironments?.length ? { target: effectiveTargetEnvironments } : {}),+ ...(effectiveTargetEnvironments !== undefined ? { target: effectiveTargetEnvironments } : {}),...(destinationConfig.targetProjects !== undefined ? { projectId: destinationConfig.targetProjects } : {}),- applyToAllCustomEnvironments: Boolean(applyToAllCustomEnvironments)+ applyToAllCustomEnvironments: Boolean(destinationConfig.applyToAllCustomEnvironments)}}},@@ -686,10 +673,11 @@ const deleteTeamSharedEnvVar = async (export const VercelSyncFns = {syncSecrets: async (secretSync: TVercelSyncWithCredentials, secretMap: TSecretMap) => {if (secretSync.destinationConfig.scope === VercelSyncScope.Team) {- const sharedEnvVars = await getOwnedTeamSharedEnvVars(secretSync);- const sharedEnvVarsMap = new Map(sharedEnvVars.map((s) => [s.key, s]));+ const allSharedEnvVars = await getTeamSharedEnvVars(secretSync);+ const sharedEnvVarsMap = new Map(allSharedEnvVars.map((s) => [s.key, s]));- const { targetEnvironments, targetProjects, sensitive } = secretSync.destinationConfig;+ const { targetEnvironments, targetProjects, sensitive, applyToAllCustomEnvironments } =+ secretSync.destinationConfig;for await (const key of Object.keys(secretMap)) {const existingVar = sharedEnvVarsMap.get(key);@@ -714,26 +702,26 @@ export const VercelSyncFns = {const hasValueChanged = existingVar.value !== secretMap[key].value;- // Sensitive secrets cannot target Development in Vercel, and the AllCustomEnvironments- // sentinel is not a real Vercel target — strip both before comparing against the existing var.+ // Sensitive secrets cannot target Development in Vercel — strip before comparing.const isSensitive = sensitive || existingVar.type === "sensitive";- const effectiveTargets = targetEnvironments- ?.filter((env) => env !== VercelEnvironmentType.AllCustomEnvironments)- .filter((env) => !isSensitive || env !== VercelEnvironmentType.Development);+ const effectiveTargets = targetEnvironments?.filter(+ (env) => !isSensitive || env !== VercelEnvironmentType.Development+ );const existingTarget = existingVar.target ?? [];- const hasTargetChanged = effectiveTargets?.length- ? existingTarget.length !== effectiveTargets.length ||- !effectiveTargets.every((env) => existingTarget.includes(env))- : false;+ const hasTargetChanged =+ effectiveTargets !== undefined+ ? existingTarget.length !== effectiveTargets.length ||+ !effectiveTargets.every((env) => existingTarget.includes(env))+ : false;const hasProjectsChanged = targetProjects? (existingVar.projectId?.length ?? 0) !== targetProjects.length ||!targetProjects.every((pid) => existingVar.projectId?.includes(pid)): false;- const desiredAllCustom = targetEnvironments?.includes(VercelEnvironmentType.AllCustomEnvironments) ?? false;- const hasAllCustomChanged = desiredAllCustom !== (existingVar.applyToAllCustomEnvironments ?? false);+ const hasAllCustomChanged =+ Boolean(applyToAllCustomEnvironments) !== (existingVar.applyToAllCustomEnvironments ?? false);if (hasValueChanged || hasTargetChanged || hasProjectsChanged || hasAllCustomChanged) {await updateTeamSharedEnvVar(secretSync, existingVar, secretMap[key].value);@@ -742,7 +730,12 @@ export const VercelSyncFns = {if (secretSync.syncOptions.disableSecretDeletion) return;- for await (const sharedEnvVar of sharedEnvVars) {+ const teamDestinationConfig = secretSync.destinationConfig;+ const ownedEnvVars = allSharedEnvVars.filter((envVar) =>+ isTeamSharedEnvVarOwnedByThisSync(envVar, teamDestinationConfig)+ );++ for await (const sharedEnvVar of ownedEnvVars) {if (!matchesSchema(sharedEnvVar.key, secretSync.environment?.slug || "", secretSync.syncOptions.keySchema))// eslint-disable-next-line no-continuecontinue;diff --git a/backend/src/services/secret-sync/vercel/vercel-sync-schemas.ts b/backend/src/services/secret-sync/vercel/vercel-sync-schemas.tsindex dd16915534..930f56a82f 100644--- a/backend/src/services/secret-sync/vercel/vercel-sync-schemas.ts+++ b/backend/src/services/secret-sync/vercel/vercel-sync-schemas.ts@@ -30,13 +30,29 @@ const VercelSyncDestinationConfigSchema = zteamName: z.string().optional().describe(SecretSyncs.DESTINATION_CONFIG.VERCEL.teamName),targetEnvironments: z.array(z.nativeEnum(VercelEnvironmentType))- .min(1, "At least one environment is required")+ .optional()+ .default([]).describe(SecretSyncs.DESTINATION_CONFIG.VERCEL.targetEnvironments),+ applyToAllCustomEnvironments: z+ .boolean()+ .optional()+ .default(false)+ .describe(SecretSyncs.DESTINATION_CONFIG.VERCEL.applyToAllCustomEnvironments),targetProjects: z.array(z.string()).optional().describe(SecretSyncs.DESTINATION_CONFIG.VERCEL.targetProjects),sensitive: z.boolean().default(false).describe(SecretSyncs.DESTINATION_CONFIG.VERCEL.sensitive)})]).superRefine((config, ctx) => {+ if (config.scope === VercelSyncScope.Team) {+ if (!config.targetEnvironments?.length && !config.applyToAllCustomEnvironments) {+ ctx.addIssue({+ code: z.ZodIssueCode.custom,+ message: "At least one target environment or applyToAllCustomEnvironments must be set.",+ path: ["targetEnvironments"]+ });+ }+ }+if (!config.sensitive) return;if (config.scope === VercelSyncScope.Project && config.env === VercelEnvironmentType.Development) {diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/VercelSyncFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/VercelSyncFields.tsxindex 67b99a4c71..1c4ed581c8 100644--- a/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/VercelSyncFields.tsx+++ b/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/VercelSyncFields.tsx@@ -26,10 +26,7 @@ const standardVercelEnvironments = [{ name: "Production", slug: "production" }] as const;-const teamVercelEnvironments = [- ...standardVercelEnvironments,- { name: "All Custom Environments", slug: "all-custom-environments" }-] as const;+const teamVercelEnvironments = [...standardVercelEnvironments] as const;export const VercelSyncFields = () => {const { control, watch, setValue } = useFormContext<@@ -137,6 +134,7 @@ export const VercelSyncFields = () => {if (newScope === VercelSyncScope.Team) {setValue("destinationConfig.teamId", "");setValue("destinationConfig.targetEnvironments", []);+ setValue("destinationConfig.applyToAllCustomEnvironments", false);setValue("destinationConfig.targetProjects", undefined);setValue("destinationConfig.teamName", "");} else {@@ -235,6 +233,37 @@ export const VercelSyncFields = () => {</FormControl>)}/>++ <Controller+ name="destinationConfig.applyToAllCustomEnvironments"+ control={control}+ render={({ field: { value, onChange } }) => (+ <FormControl>+ <Switch+ className="bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-green/80"+ id="vercel-sync-all-custom-environments"+ thumbClassName="bg-mineshaft-800"+ isChecked={Boolean(value)}+ onCheckedChange={onChange}+ >+ <p className="w-fit">+ Apply to All Custom Environments{" "}+ <Tooltip+ className="max-w-md"+ content={+ <span>+ When enabled, shared environment variables will be applied to all custom+ environments in the Vercel team.+ </span>+ }+ >+ <FontAwesomeIcon icon={faCircleInfo} className="text-mineshaft-400" />+ </Tooltip>+ </p>+ </Switch>+ </FormControl>+ )}+ /></>)}diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/VercelSyncReviewFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/VercelSyncReviewFields.tsxindex 48d1b901ee..306ccb221a 100644--- a/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/VercelSyncReviewFields.tsx+++ b/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/VercelSyncReviewFields.tsx@@ -19,6 +19,7 @@ export const VercelSyncReviewFields = () => {const scope = watch("destinationConfig.scope");const teamId = watch("destinationConfig.teamId");const targetEnvironments = watch("destinationConfig.targetEnvironments");+ const applyToAllCustomEnvironments = watch("destinationConfig.applyToAllCustomEnvironments");const targetProjects = watch("destinationConfig.targetProjects");const sensitive = watch("destinationConfig.sensitive");const connectionId = watch("connection.id");@@ -48,13 +49,14 @@ export const VercelSyncReviewFields = () => {<GenericFieldLabel label="Scope">Team</GenericFieldLabel><GenericFieldLabel label="Vercel Team">{selectedTeam?.name}</GenericFieldLabel><GenericFieldLabel label="Target Environments">- {targetEnvironments- ?.map((env) =>- env === VercelEnvironmentType.AllCustomEnvironments- ? "All Custom Environments"- : env.charAt(0).toUpperCase() + env.slice(1)- )- .join(", ")}+ {targetEnvironments?.length+ ? targetEnvironments+ .map((env: string) => env.charAt(0).toUpperCase() + env.slice(1))+ .join(", ")+ : "None"}+ </GenericFieldLabel>+ <GenericFieldLabel label="All Custom Environments">+ {applyToAllCustomEnvironments ? "Yes" : "No"}</GenericFieldLabel><GenericFieldLabel label="Target Projects">{selectedProjects?.map((project) => project?.name).join(", ")}diff --git a/frontend/src/components/secret-syncs/forms/schemas/vercel-sync-destination-schema.ts b/frontend/src/components/secret-syncs/forms/schemas/vercel-sync-destination-schema.tsindex 48f03e260f..89028ae56a 100644--- a/frontend/src/components/secret-syncs/forms/schemas/vercel-sync-destination-schema.ts+++ b/frontend/src/components/secret-syncs/forms/schemas/vercel-sync-destination-schema.ts@@ -25,16 +25,26 @@ export const VercelSyncDestinationSchema = BaseSecretSyncSchema().merge(scope: z.literal(VercelSyncScope.Team),teamId: z.string().trim().min(1, "Team required"),teamName: z.string().trim().optional(),- targetEnvironments: z- .array(z.nativeEnum(VercelEnvironmentType), {- message: "At least one environment is required"- })- .min(1, "At least one environment is required"),+ targetEnvironments: z.array(z.nativeEnum(VercelEnvironmentType)).optional().default([]),+ applyToAllCustomEnvironments: z.boolean().optional().default(false),targetProjects: z.array(z.string()).optional(),sensitive: z.boolean().default(false)})]).superRefine((config, ctx) => {+ if (+ config.scope === VercelSyncScope.Team &&+ !config.targetEnvironments?.length &&+ !config.applyToAllCustomEnvironments+ ) {+ ctx.addIssue({+ code: z.ZodIssueCode.custom,+ message:+ "At least one target environment or Apply to All Custom Environments must be set.",+ path: ["targetEnvironments"]+ });+ }+if (!config.sensitive) return;if (diff --git a/frontend/src/hooks/api/secretSyncs/types/vercel-sync.ts b/frontend/src/hooks/api/secretSyncs/types/vercel-sync.tsindex d29081aa72..d47b181afd 100644--- a/frontend/src/hooks/api/secretSyncs/types/vercel-sync.ts+++ b/frontend/src/hooks/api/secretSyncs/types/vercel-sync.ts@@ -10,8 +10,7 @@ export enum VercelSyncScope {export const VercelEnvironmentType = {Development: "development",Preview: "preview",- Production: "production",- AllCustomEnvironments: "all-custom-environments"+ Production: "production"} as const;export type VercelEnvironment = (typeof VercelEnvironmentType)[keyof typeof VercelEnvironmentType];@@ -33,6 +32,7 @@ export type TVercelSync = TRootSecretSync & {teamId: string;teamName?: string;targetEnvironments: string[];+ applyToAllCustomEnvironments: boolean;targetProjects?: string[];sensitive: boolean;};diff --git a/frontend/src/pages/secret-manager/IntegrationsListPage/components/SecretSyncsTab/SecretSyncTable/helpers/index.ts b/frontend/src/pages/secret-manager/IntegrationsListPage/components/SecretSyncsTab/SecretSyncTable/helpers/index.tsindex a76db851f4..4a00c60696 100644--- a/frontend/src/pages/secret-manager/IntegrationsListPage/components/SecretSyncsTab/SecretSyncTable/helpers/index.ts+++ b/frontend/src/pages/secret-manager/IntegrationsListPage/components/SecretSyncsTab/SecretSyncTable/helpers/index.ts@@ -10,10 +10,7 @@ import { GitLabSyncScope } from "@app/hooks/api/secretSyncs/types/gitlab-sync";import { HumanitecSyncScope } from "@app/hooks/api/secretSyncs/types/humanitec-sync";import { OctopusDeploySyncScope } from "@app/hooks/api/secretSyncs/types/octopus-deploy-sync";import { RenderSyncScope } from "@app/hooks/api/secretSyncs/types/render-sync";-import {- VercelEnvironmentType,- VercelSyncScope-} from "@app/hooks/api/secretSyncs/types/vercel-sync";+import { VercelSyncScope } from "@app/hooks/api/secretSyncs/types/vercel-sync";// This functional ensures parity across what is displayed in the destination column// and the values used when search filtering@@ -99,13 +96,13 @@ export const getSecretSyncDestinationColValues = (secretSync: TSecretSync) => {case SecretSync.Vercel:if (destinationConfig.scope === VercelSyncScope.Team) {primaryText = destinationConfig.teamName || destinationConfig.teamId;- secondaryText = destinationConfig.targetEnvironments- .map((env) =>- env === VercelEnvironmentType.AllCustomEnvironments- ? "All Custom Environments"- : env.charAt(0).toUpperCase() + env.slice(1)- )- .join(", ");+ const envLabels = destinationConfig.targetEnvironments.map(+ (env) => env.charAt(0).toUpperCase() + env.slice(1)+ );+ if (destinationConfig.applyToAllCustomEnvironments) {+ envLabels.push("All Custom Environments");+ }+ secondaryText = envLabels.join(", ") || "All Custom Environments";} else {primaryText = destinationConfig.appName || destinationConfig.app;secondaryText = destinationConfig.env;diff --git a/frontend/src/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncDestinationSection/VercelSyncDestinationSection.tsx b/frontend/src/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncDestinationSection/VercelSyncDestinationSection.tsxindex edf5056ec2..765d02f29f 100644--- a/frontend/src/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncDestinationSection/VercelSyncDestinationSection.tsx+++ b/frontend/src/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncDestinationSection/VercelSyncDestinationSection.tsx@@ -43,13 +43,14 @@ export const VercelSyncDestinationSection = ({ secretSync }: Props) => {<GenericFieldLabel label="Scope">Team</GenericFieldLabel><GenericFieldLabel label="Vercel Team">{selectedTeam?.name}</GenericFieldLabel><GenericFieldLabel label="Target Environments">- {destinationConfig.targetEnvironments- ?.map((env) =>- env === VercelEnvironmentType.AllCustomEnvironments- ? "All Custom Environments"- : env.charAt(0).toUpperCase() + env.slice(1)- )- .join(", ")}+ {destinationConfig.targetEnvironments?.length+ ? destinationConfig.targetEnvironments+ .map((env) => env.charAt(0).toUpperCase() + env.slice(1))+ .join(", ")+ : "None"}+ </GenericFieldLabel>+ <GenericFieldLabel label="All Custom Environments">+ {destinationConfig.applyToAllCustomEnvironments ? "Yes" : "No"}</GenericFieldLabel><GenericFieldLabel label="Target Projects">{selectedProjects?.map((project) => project?.name).join(", ")}