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
Address PR comments
Carlos Monastyrski7344b1326b6d
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.tsindex 50cc15f9b7..1ad3efed59 100644--- a/backend/src/ee/services/audit-log/audit-log-types.ts+++ b/backend/src/ee/services/audit-log/audit-log-types.ts@@ -4845,7 +4845,7 @@ interface PkiSyncSyncCertificatesEvent {syncMessage: string | null;jobId: string;jobRanAt: Date;- postSyncCommand?: TPostSyncCommandResult;+ postSyncCommand?: { command: string; result?: TPostSyncCommandResult };};}diff --git a/backend/src/services/pki-sync/linux-server/linux-server-pki-sync-schemas.test.ts b/backend/src/services/pki-sync/linux-server/linux-server-pki-sync-schemas.test.tsindex 5fe4ef7800..d715d6cf53 100644--- a/backend/src/services/pki-sync/linux-server/linux-server-pki-sync-schemas.test.ts+++ b/backend/src/services/pki-sync/linux-server/linux-server-pki-sync-schemas.test.ts@@ -71,9 +71,13 @@ describe("Linux Server postSyncCommand validation", () => {expect(parseCommand("test -f {{certificatePath}} && sudo systemctl reload nginx || exit 1").success).toBe(true);});- test("treats an empty or whitespace-only command as no command", () => {- expect(parseCommand("").data?.postSyncCommand).toBeUndefined();- expect(parseCommand(" ").data?.postSyncCommand).toBeUndefined();+ test("accepts the values that mean 'no command', leaving normalization to the service", () => {+ expect(parseCommand("").success).toBe(true);+ expect(parseCommand(" ").data?.postSyncCommand).toBe("");+ expect(+ LinuxServerPkiSyncOptionsSchema.safeParse({ certificateNameSchema: "server", postSyncCommand: null }).data+ ?.postSyncCommand+ ).toBeNull();});test("rejects a command beyond the length limit", () => {diff --git a/backend/src/services/pki-sync/pki-sync-post-sync-command-fns.test.ts b/backend/src/services/pki-sync/pki-sync-post-sync-command-fns.test.tsindex cbe92c2a65..5871b2080b 100644--- a/backend/src/services/pki-sync/pki-sync-post-sync-command-fns.test.ts+++ b/backend/src/services/pki-sync/pki-sync-post-sync-command-fns.test.ts@@ -2,9 +2,11 @@ import { describe, expect, test, vi } from "vitest";import { PkiSyncStatus } from "./pki-sync-enums";import {+ applyPostSyncCommandUpdate,buildPostSyncCommandFailureMessage,buildPostSyncCommandPlan,findSingleCertificatePostSyncCommandVariables,+ normalizeNewPostSyncCommand,PostSyncCommandVariable,renderPostSyncCommand,runPostSyncCommand,@@ -353,3 +355,65 @@ describe("buildPostSyncCommandFailureMessage", () => {expect(result.failureDetail?.length).toBeLessThanOrEqual(120);});});++describe("normalizeNewPostSyncCommand", () => {+ test("keeps a real command", () => {+ expect(normalizeNewPostSyncCommand({ exportFormat: "pem", postSyncCommand: "systemctl reload nginx" })).toEqual({+ exportFormat: "pem",+ postSyncCommand: "systemctl reload nginx"+ });+ });++ test.each([+ ["null", null],+ ["empty string", ""],+ ["absent", undefined]+ ])("stores no command at all when it is %s", (_label, value) => {+ const result = normalizeNewPostSyncCommand({ exportFormat: "pem", postSyncCommand: value });++ expect("postSyncCommand" in result).toBe(false);+ expect(result).toEqual({ exportFormat: "pem" });+ });+});++describe("applyPostSyncCommandUpdate", () => {+ const stored = "systemctl reload nginx";++ test("an omitted key preserves the stored command", () => {+ const result = applyPostSyncCommandUpdate({ exportFormat: "pem", includeRootCa: true }, stored);++ expect(result.postSyncCommand).toBe(stored);+ expect(result.includeRootCa).toBe(true);+ });++ test("an explicit null clears the stored command", () => {+ const result = applyPostSyncCommandUpdate({ exportFormat: "pem", postSyncCommand: null }, stored);++ expect("postSyncCommand" in result).toBe(false);+ });++ test("a blank string clears the stored command", () => {+ const result = applyPostSyncCommandUpdate({ postSyncCommand: "" }, stored);++ expect("postSyncCommand" in result).toBe(false);+ });++ test("a new command replaces the stored one", () => {+ const result = applyPostSyncCommandUpdate({ postSyncCommand: "systemctl restart haproxy" }, stored);++ expect(result.postSyncCommand).toBe("systemctl restart haproxy");+ });++ test("an omitted key on a sync that has no command leaves it absent", () => {+ const result = applyPostSyncCommandUpdate({ exportFormat: "pem" }, undefined);++ expect("postSyncCommand" in result).toBe(false);+ });++ test("does not mutate the object it was given", () => {+ const input = { exportFormat: "pem", postSyncCommand: null };+ applyPostSyncCommandUpdate(input, stored);++ expect(input.postSyncCommand).toBeNull();+ });+});diff --git a/backend/src/services/pki-sync/pki-sync-post-sync-command-fns.ts b/backend/src/services/pki-sync/pki-sync-post-sync-command-fns.tsindex 29daba1657..e48830525b 100644--- a/backend/src/services/pki-sync/pki-sync-post-sync-command-fns.ts+++ b/backend/src/services/pki-sync/pki-sync-post-sync-command-fns.ts@@ -70,6 +70,33 @@ export type TPostSyncCommandExecutionResult = { stdout: string; stderr: string;export type TPostSyncCommandPlan = { command: string; context: TPostSyncCommandContext };+const POST_SYNC_COMMAND_KEY = "postSyncCommand";++export const normalizeNewPostSyncCommand = (syncOptions: Record<string, unknown>): Record<string, unknown> => {+ if (syncOptions[POST_SYNC_COMMAND_KEY]) return syncOptions;++ const normalized = { ...syncOptions };+ delete normalized[POST_SYNC_COMMAND_KEY];+ return normalized;+};++export const applyPostSyncCommandUpdate = (+ resolvedSyncOptions: Record<string, unknown>,+ storedCommand: unknown+): Record<string, unknown> => {+ const requested = resolvedSyncOptions[POST_SYNC_COMMAND_KEY];+ const next = { ...resolvedSyncOptions };++ const keep = requested === undefined ? storedCommand : requested;+ if (typeof keep === "string" && keep) {+ next[POST_SYNC_COMMAND_KEY] = keep;+ } else {+ delete next[POST_SYNC_COMMAND_KEY];+ }++ return next;+};+/*** Assembles what a post-sync command needs, or undefined when there is no command or the run* delivered nothing to activate.diff --git a/backend/src/services/pki-sync/pki-sync-queue.ts b/backend/src/services/pki-sync/pki-sync-queue.tsindex f18d018ab1..b05c507b44 100644--- a/backend/src/services/pki-sync/pki-sync-queue.ts+++ b/backend/src/services/pki-sync/pki-sync-queue.ts@@ -438,6 +438,9 @@ export const pkiSyncQueueFactory = ({let postSyncCommandResult: TPostSyncCommandResult | undefined;let isFinalAttempt = job.attemptsStarted === job.opts.attempts;+ const configuredPostSyncCommand = (pkiSync.syncOptions as { postSyncCommand?: string } | undefined)+ ?.postSyncCommand;+try {const {connection: { id: connectionId, orgId, projectId: appConnectionProjectId }@@ -678,7 +681,9 @@ export const pkiSyncQueueFactory = ({syncMessage,jobId: job.id!,jobRanAt: ranAt,- postSyncCommand: postSyncCommandResult+ postSyncCommand: configuredPostSyncCommand+ ? { command: configuredPostSyncCommand, result: postSyncCommandResult }+ : undefined}}});diff --git a/backend/src/services/pki-sync/pki-sync-schemas.ts b/backend/src/services/pki-sync/pki-sync-schemas.tsindex b1fdf3825d..65404893c6 100644--- a/backend/src/services/pki-sync/pki-sync-schemas.ts+++ b/backend/src/services/pki-sync/pki-sync-schemas.ts@@ -9,7 +9,7 @@ export const PostSyncCommandSchema = z.string().trim().max(POST_SYNC_COMMAND_MAX_LENGTH, `Command must be at most ${POST_SYNC_COMMAND_MAX_LENGTH} characters`)- .transform((command) => command || undefined)+ .nullable().optional();// Sync options shared by every destination. Destinations extend this with their owndiff --git a/backend/src/services/pki-sync/pki-sync-service.ts b/backend/src/services/pki-sync/pki-sync-service.tsindex 9998668077..0ab0edb442 100644--- a/backend/src/services/pki-sync/pki-sync-service.ts+++ b/backend/src/services/pki-sync/pki-sync-service.ts@@ -33,8 +33,10 @@ import {} from "./pki-sync-fns";import { PKI_SYNC_CONNECTION_MAP, PKI_SYNC_NAME_MAP } from "./pki-sync-maps";import {+ applyPostSyncCommandUpdate,findSingleCertificatePostSyncCommandVariables,- formatPostSyncCommandVariables+ formatPostSyncCommandVariables,+ normalizeNewPostSyncCommand} from "./pki-sync-post-sync-command-fns";import { TPkiSyncQueueFactory } from "./pki-sync-queue";import {@@ -194,7 +196,8 @@ export const pkiSyncServiceFactory = ({subscriberName: string | undefined,actor: OrgServiceActor) => {- if (!nextCommand || nextCommand === currentCommand) return;+ if (nextCommand === currentCommand) return;+ if (!nextCommand && !currentCommand) return;await $assertSyncAction(ProjectPermissionPkiSyncActions.SetPostSyncCommand,@@ -340,10 +343,10 @@ export const pkiSyncServiceFactory = ({const connection = await appConnectionService.connectAppConnectionById(destinationApp, connectionId, actor);const providerCapabilities = getPkiSyncProviderCapabilities(destination);- const resolvedSyncOptions = {+ const resolvedSyncOptions = normalizeNewPostSyncCommand({...providerCapabilities,...syncOptions- };+ });await $assertMaySetPostSyncCommand(syncOptions?.postSyncCommand,@@ -495,10 +498,10 @@ export const pkiSyncServiceFactory = ({});}- resolvedSyncOptions = {- ...providerCapabilities,- ...syncOptions- };+ resolvedSyncOptions = applyPostSyncCommandUpdate(+ { ...providerCapabilities, ...syncOptions },+ (pkiSync.syncOptions as Record<string, unknown> | undefined)?.postSyncCommand+ );}const effectiveSyncOptions = (resolvedSyncOptions ?? pkiSync.syncOptions) as Record<string, unknown> | undefined;diff --git a/backend/src/services/pki-sync/windows-server/windows-server-pki-sync-schemas.test.ts b/backend/src/services/pki-sync/windows-server/windows-server-pki-sync-schemas.test.tsindex 893a5a568c..f12f5dd192 100644--- a/backend/src/services/pki-sync/windows-server/windows-server-pki-sync-schemas.test.ts+++ b/backend/src/services/pki-sync/windows-server/windows-server-pki-sync-schemas.test.ts@@ -68,9 +68,13 @@ describe("Windows Server postSyncCommand validation", () => {expect(parseCommand("Import-PfxCertificate -FilePath {{certificatePath}}\niisreset").success).toBe(true);});- test("treats an empty or whitespace-only command as no command", () => {- expect(parseCommand("").data?.postSyncCommand).toBeUndefined();- expect(parseCommand(" ").data?.postSyncCommand).toBeUndefined();+ test("accepts the values that mean 'no command', leaving normalization to the service", () => {+ expect(parseCommand("").success).toBe(true);+ expect(parseCommand(" ").data?.postSyncCommand).toBe("");+ expect(+ WindowsServerPkiSyncOptionsSchema.safeParse({ certificateNameSchema: "server", postSyncCommand: null }).data+ ?.postSyncCommand+ ).toBeNull();});test("rejects a command beyond the length limit", () => {diff --git a/docs/documentation/platform/pki/applications/certificate-syncs/linux-server.mdx b/docs/documentation/platform/pki/applications/certificate-syncs/linux-server.mdxindex a4e38d8a77..96360f9cd2 100644--- a/docs/documentation/platform/pki/applications/certificate-syncs/linux-server.mdx+++ b/docs/documentation/platform/pki/applications/certificate-syncs/linux-server.mdx@@ -114,7 +114,7 @@ When syncing certificates, Infisical opens an SSH session to the server and, forDelivering a certificate file does not make the service use it. Nginx keeps serving the old certificate until something reloads it. A post-sync command is that last step, run for you right after the files land.-Set one command on the sync. It runs on the target server, in that server's own shell, once per sync run that delivers at least one file. Leaving the field empty means nothing runs, so there is no separate toggle.+Set one command on the sync. It runs on the target server, in that server's own shell, once per sync run that delivers at least one file. Leaving the field empty means nothing runs, so there is no separate toggle. If a sync run does not complete, Infisical may attempt it again and the command runs with it, so prefer a command that is safe to run more than once.The field accepts a whole script, so several steps can run in one go: put each on its own line, or chain them with `&&`.@@ -172,7 +172,7 @@ A command is limited to 2048 characters, counted after the placeholders are subsAfter every file in the run has been delivered and after any removals, so the server is in its final state before the service reloads. A run that delivers nothing runs nothing. Renewals, adding a certificate, and a manual trigger all deliver files, so all three run the command. Removing a certificate from the sync does not.</Accordion><Accordion title="What happens if the command fails?">- The sync is marked failed and the reason appears as the sync's last error. The delivered files stay in place, because they were written before the command ran.+ The sync is marked failed and the reason appears as the sync's last error. The delivered files stay in place, because they were written before the command ran. A command that fails is reported, not repeated.</Accordion><Accordion title="Can I run several commands, and what happens if one of them fails?">Yes. Write one per line, or chain them with `&&`.@@ -187,7 +187,7 @@ A command is limited to 2048 characters, counted after the placeholders are subs```</Accordion><Accordion title="Can the command run twice for the same certificate?">- Yes. A sync that retries re-delivers the files and runs the command again, so prefer a command that is safe to run more than once. A service reload or restart is.+ Yes, in some cases. If a sync run does not complete, Infisical may attempt it again, and the command runs as part of that attempt. Prefer a command that is safe to run more than once. A service reload or restart is.</Accordion><Accordion title="Is there a time limit?">Yes, 30 seconds, enforced by the gateway. A command that needs longer should start the work in the background or live in a script on the server.diff --git a/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdx b/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdxindex c7df48e87b..ba043cad8c 100644--- a/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdx+++ b/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdx@@ -122,7 +122,7 @@ When certificate removal is enabled and a certificate is removed from the sync,Delivering a `.pfx` to `C:\certs` does not make IIS or a service use it. A post-sync command is that last step, run for you right after the files land.-Set one command on the sync. The Gateway runs it as PowerShell on the target server, once per sync run that delivers at least one file. Leaving the field empty means nothing runs, so there is no separate toggle.+Set one command on the sync. The Gateway runs it as PowerShell on the target server, once per sync run that delivers at least one file. Leaving the field empty means nothing runs, so there is no separate toggle. If a sync run does not complete, Infisical may attempt it again and the command runs with it, so prefer a command that is safe to run more than once.The field accepts a whole script, so several steps can run in one go: put each on its own line.@@ -178,7 +178,7 @@ A command is limited to 2048 characters. Windows caps a command line at 8191 chaAfter every file in the run has been delivered and after any removals, so the server is in its final state before the service restarts. A run that delivers nothing runs nothing. Renewals, adding a certificate, and a manual trigger all deliver files, so all three run the command. Removing a certificate from the sync does not.</Accordion><Accordion title="What happens if the command fails?">- The sync is marked failed and the reason appears as the sync's last error. The delivered files stay in place, because they were written before the command ran. A silent failure is reported as a failure: the script stops on the first error, and a native command's own non-zero exit code is passed through.+ The sync is marked failed and the reason appears as the sync's last error. The delivered files stay in place, because they were written before the command ran. A silent failure is reported as a failure: the script stops on the first error, and a native command's own non-zero exit code is passed through. A command that fails is reported, not repeated.To fail the sync deliberately, use `throw "reason"`. Avoid `exit`: PowerShell stops the script there before it can report its result, so the sync is failed with a message saying the outcome could not be read rather than with your reason.</Accordion>@@ -194,7 +194,7 @@ A command is limited to 2048 characters. Windows caps a command line at 8191 cha```</Accordion><Accordion title="Can the command run twice for the same certificate?">- Yes. A sync that retries re-delivers the files and runs the command again, so prefer a command that is safe to run more than once. A service restart is.+ Yes, in some cases. If a sync run does not complete, Infisical may attempt it again, and the command runs as part of that attempt. Prefer a command that is safe to run more than once. A service restart is.</Accordion><Accordion title="Is there a time limit?">Yes, 30 seconds, enforced by the Gateway. A command that needs longer should start the work in the background or live in a script on the server.diff --git a/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsx b/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsxindex 17509e5ea2..97415fe311 100644--- a/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsx+++ b/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsx@@ -31,6 +31,7 @@ import {PkiSync,PkiSyncExportFormat,TPkiSync,+ useCanSetPostSyncCommand,useCreatePkiSync,usePkiSyncOption} from "@app/hooks/api/pkiSyncs";@@ -173,7 +174,11 @@ export const CreatePkiSyncForm = ({const [showConfirmation, setShowConfirmation] = useState(false);const { syncOption } = usePkiSyncOption(destination);- const FORM_TABS = getFormTabs(destination, Boolean(syncOption?.canRunPostSyncCommand));+ const canSetPostSyncCommand = useCanSetPostSyncCommand(applicationId);+ const FORM_TABS = getFormTabs(+ destination,+ Boolean(syncOption?.canRunPostSyncCommand) && canSetPostSyncCommand+ );const formMethods = useForm<TPkiSyncForm>({resolver: zodResolver(PkiSyncFormSchema),@@ -370,7 +375,10 @@ export const CreatePkiSyncForm = ({)}{currentKey === "mappings" && <PkiSyncFieldMappingsFields destination={destination} />}{currentKey === "postSyncCommand" && (- <PkiSyncPostSyncCommandFields destination={destination} />+ <PkiSyncPostSyncCommandFields+ destination={destination}+ canEditCommand={canSetPostSyncCommand}+ />)}{currentKey === "details" && <PkiSyncDetailsFields />}{currentKey === "certificates" && (diff --git a/frontend/src/components/pki-syncs/forms/EditPkiSyncForm.tsx b/frontend/src/components/pki-syncs/forms/EditPkiSyncForm.tsxindex d6dc2f4769..6a2356fe69 100644--- a/frontend/src/components/pki-syncs/forms/EditPkiSyncForm.tsx+++ b/frontend/src/components/pki-syncs/forms/EditPkiSyncForm.tsx@@ -16,7 +16,13 @@ import {Switch} from "@app/components/v3";import { PKI_SYNC_MAP } from "@app/helpers/pkiSyncs";-import { PkiSync, TPkiSync, usePkiSyncOption, useUpdatePkiSync } from "@app/hooks/api/pkiSyncs";+import {+ PkiSync,+ TPkiSync,+ useCanSetPostSyncCommand,+ usePkiSyncOption,+ useUpdatePkiSync+} from "@app/hooks/api/pkiSyncs";import { TUpdatePkiSyncForm, UpdatePkiSyncFormSchema } from "./schemas/pki-sync-schema";import { PkiSyncDestinationFields } from "./PkiSyncDestinationFields";@@ -110,6 +116,7 @@ export const EditPkiSyncForm = ({ pkiSync, onComplete, onDirtyChange, onCancel }const updatePkiSync = useUpdatePkiSync();const { name: destinationName } = PKI_SYNC_MAP[pkiSync.destination];const { syncOption } = usePkiSyncOption(pkiSync.destination);+ const canSetPostSyncCommand = useCanSetPostSyncCommand(pkiSync.applicationId);const steps = getFormSteps(pkiSync.destination, Boolean(syncOption?.canRunPostSyncCommand));const [selectedStepIndex, setSelectedStepIndex] = useState(0);@@ -199,7 +206,12 @@ export const EditPkiSyncForm = ({ pkiSync, onComplete, onDirtyChange, onCancel }case "mappings":return <PkiSyncFieldMappingsFields destination={pkiSync.destination} />;case "postSyncCommand":- return <PkiSyncPostSyncCommandFields destination={pkiSync.destination} />;+ return (+ <PkiSyncPostSyncCommandFields+ destination={pkiSync.destination}+ canEditCommand={canSetPostSyncCommand}+ />+ );case "details":return <PkiSyncDetailsFields />;default:diff --git a/frontend/src/components/pki-syncs/forms/PkiSyncPostSyncCommandFields.tsx b/frontend/src/components/pki-syncs/forms/PkiSyncPostSyncCommandFields.tsxindex d113d53fbf..ae8b0cbf78 100644--- a/frontend/src/components/pki-syncs/forms/PkiSyncPostSyncCommandFields.tsx+++ b/frontend/src/components/pki-syncs/forms/PkiSyncPostSyncCommandFields.tsx@@ -32,9 +32,10 @@ const SINGLE_CERTIFICATE_VARIABLES = [type Props = {destination?: PkiSync;+ canEditCommand?: boolean;};-export const PkiSyncPostSyncCommandFields = ({ destination }: Props) => {+export const PkiSyncPostSyncCommandFields = ({ destination, canEditCommand = true }: Props) => {const { control, watch } = useFormContext<TPkiSyncForm>();const currentDestination = destination ?? watch("destination");const isPkcs12 = watch("syncOptions.exportFormat") === PkiSyncExportFormat.Pkcs12;@@ -54,7 +55,7 @@ export const PkiSyncPostSyncCommandFields = ({ destination }: Props) => {control={control}name="syncOptions.postSyncCommand"render={({ field: { value, onChange }, fieldState: { error } }) => (- <Field data-invalid={Boolean(error)}>+ <Field data-invalid={Boolean(error)} data-disabled={!canEditCommand}><FieldLabel htmlFor="post-sync-command">Command</FieldLabel><TextAreaid="post-sync-command"@@ -62,12 +63,14 @@ export const PkiSyncPostSyncCommandFields = ({ destination }: Props) => {value={value ?? ""}onChange={onChange}isError={Boolean(error)}- placeholder={COMMAND_PLACEHOLDERS[currentDestination]}+ readOnly={!canEditCommand}+ disabled={!canEditCommand}+ placeholder={canEditCommand ? COMMAND_PLACEHOLDERS[currentDestination] : undefined}/><FieldDescription>- Runs once per sync run that delivers a file, as the sync's account, so keep that- account least-privilege. If it fails, the sync is marked failed. The command is- executed by the gateway, so the sync's connection must use one.+ {canEditCommand+ ? "Runs once per sync run that delivers a file, as the sync's account, so keep that account least-privilege. If it fails, the sync is marked failed. The command is executed by the gateway, so the sync's connection must use one."+ : "You do not have permission to set a post-sync command on this sync. Ask an administrator to change it."}</FieldDescription><FieldError>{error?.message}</FieldError></Field>diff --git a/frontend/src/components/pki-syncs/forms/schemas/base-pki-sync-schema.ts b/frontend/src/components/pki-syncs/forms/schemas/base-pki-sync-schema.tsindex a27188b353..eb34d65008 100644--- a/frontend/src/components/pki-syncs/forms/schemas/base-pki-sync-schema.ts+++ b/frontend/src/components/pki-syncs/forms/schemas/base-pki-sync-schema.ts@@ -9,8 +9,8 @@ export const PostSyncCommandSchema = zPOST_SYNC_COMMAND_MAX_LENGTH,`Command must be at most ${POST_SYNC_COMMAND_MAX_LENGTH} characters`)- .transform((command) => command || undefined)- .optional();+ .nullish()+ .transform((command) => command || null);export const BasePkiSyncSchema = <T extends AnyZodObject | undefined = undefined>(additionalSyncOptions?: Tdiff --git a/frontend/src/hooks/api/pkiSyncs/types/linux-server-sync.ts b/frontend/src/hooks/api/pkiSyncs/types/linux-server-sync.tsindex 9e3d15774e..2934941332 100644--- a/frontend/src/hooks/api/pkiSyncs/types/linux-server-sync.ts+++ b/frontend/src/hooks/api/pkiSyncs/types/linux-server-sync.ts@@ -17,7 +17,7 @@ export type TLinuxServerPkiSync = TRootPkiSync & {privateKeyFileMode?: string;owner?: string;group?: string;- postSyncCommand?: string;+ postSyncCommand?: string | null;};connection: {app: AppConnection.SSH;diff --git a/frontend/src/hooks/api/pkiSyncs/types/windows-server-sync.ts b/frontend/src/hooks/api/pkiSyncs/types/windows-server-sync.tsindex 8ca87d1b84..da11d34a2d 100644--- a/frontend/src/hooks/api/pkiSyncs/types/windows-server-sync.ts+++ b/frontend/src/hooks/api/pkiSyncs/types/windows-server-sync.ts@@ -14,7 +14,7 @@ export type TWindowsServerPkiSync = TRootPkiSync & {combineCertificateChain?: boolean;includePrivateKey?: boolean;fileAccessRules?: { identity: string; access: WindowsFileAccess }[];- postSyncCommand?: string;+ postSyncCommand?: string | null;};connection: {app: AppConnection.WinRM;diff --git a/frontend/src/hooks/api/pkiSyncs/usePkiSyncPermissions.ts b/frontend/src/hooks/api/pkiSyncs/usePkiSyncPermissions.tsindex a7206bfdfe..e26ed6547e 100644--- a/frontend/src/hooks/api/pkiSyncs/usePkiSyncPermissions.ts+++ b/frontend/src/hooks/api/pkiSyncs/usePkiSyncPermissions.ts@@ -8,15 +8,28 @@ import {} from "../pkiApplications";import { TPkiSync } from "./types";+export const useCanSetPostSyncCommand = (applicationId?: string | null) => {+ const { data: appPermissionData } = useGetPkiApplicationPermissions(applicationId ?? "");++ return Boolean(+ appPermissionData?.permission?.can(+ PkiApplicationResourceActions.SetPostSyncCommand,+ PkiApplicationResourceSub.PkiSyncs+ )+ );+};+export const usePkiSyncPermissions = (pkiSync: TPkiSync) => {const { permission: projectPermission } = useProjectPermission();const { data: appPermissionData } = useGetPkiApplicationPermissions(pkiSync.applicationId ?? "");const appPermission = appPermissionData?.permission;+ const canSetPostSyncCommand = useCanSetPostSyncCommand(pkiSync.applicationId);const checkApp = (action: PkiApplicationResourceActions) =>Boolean(appPermission?.can(action, PkiApplicationResourceSub.PkiSyncs));return {+ canSetPostSyncCommand,canRead:projectPermission.can(ProjectPermissionPkiSyncActions.Read, ProjectPermissionSub.PkiSyncs) ||checkApp(PkiApplicationResourceActions.Read),