Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Merge main into PKI-341, aligning the preflight check with the raised host command length limit

Carlos Monastyrskia2e589c2ffdf
diff --cc backend/src/services/pki-sync/pki-sync-host-command-fns.ts
index 3c8fb7f957,0000000000..64412eb004
mode 100644,000000..100644
--- a/backend/src/services/pki-sync/pki-sync-host-command-fns.ts
+++ b/backend/src/services/pki-sync/pki-sync-host-command-fns.ts
@@@ -1,271 -1,0 +1,284 @@@
+import RE2 from "re2";
+
+import { logger } from "@app/lib/logger";
+
+import { PkiSyncStatus } from "./pki-sync-enums";
+import { PkiSyncError } from "./pki-sync-errors";
+
+export enum HostCommandKind {
+ Preflight = "preflight check",
+ PostSync = "post-sync command"
+}
+
+export const HOST_COMMAND_TIMEOUT_MS: Record<HostCommandKind, number> = {
+ [HostCommandKind.Preflight]: 10_000,
+ [HostCommandKind.PostSync]: 30_000
+};
+
+export enum HostCommandVariable {
+ CertificatePath = "certificatePath",
+ CertificateDirectory = "certificateDirectory",
+ CertificateFiles = "certificateFiles",
+ CommonName = "commonName",
+ Pkcs12Password = "pkcs12Password"
+}
+
+const SINGLE_CERTIFICATE_HOST_COMMAND_VARIABLES: HostCommandVariable[] = [
+ HostCommandVariable.CertificatePath,
+ HostCommandVariable.CommonName
+];
+
+export type THostCommandContext = {
+ certificatePath?: string;
+ commonName?: string;
+ certificateDirectory: string;
+ certificateFiles: string[];
+ pkcs12Password?: string;
+};
+
+export type THostCommandCertificate = { paths: string[]; commonName?: string };
+
- export const HOST_COMMAND_MAX_LENGTH = 2048;
++export const HOST_COMMAND_MAX_LENGTH = 8192;
+
+const VARIABLE_PATTERN = new RE2("\\{\\{\\s*([a-zA-Z0-9_]+)\\s*\\}\\}", "g");
+
+const MAX_CAPTURED_OUTPUT_CHARS = 1000;
+
+const MAX_FAILURE_DETAIL_CHARS = 120;
+
+const REDACTED_PLACEHOLDER = "[REDACTED]";
+
+const DEADLINE_GRACE_MS = 5_000;
+
+const sentenceCase = (text: string): string => `${text.charAt(0).toUpperCase()}${text.slice(1)}`;
+
+export type THostCommandResult = {
+ status: PkiSyncStatus.Succeeded | PkiSyncStatus.Failed;
+ exitCode?: number;
+ durationMs: number;
+ output?: string;
+ failureDetail?: string;
+ error?: string;
+};
+
+export type THostCommandExecutionResult = { stdout: string; stderr: string; exitCode: number };
+
+const findHostCommandVariables = (command?: string): Set<string> => {
+ const used = new Set<string>();
+ if (!command) return used;
+
+ command.replace(VARIABLE_PATTERN, (match: string, name: string) => {
+ used.add(name);
+ return match;
+ });
+
+ return used;
+};
+
+export const toPosixShellLiteral = (value: string): string => `'${value.split("'").join(`'\\''`)}'`;
+
+export const toPowerShellLiteral = (value: string): string => `'${value.split("'").join("''")}'`;
+
+export const formatHostCommandVariables = (variables: string[]): string =>
+ variables.map((variable) => `{{${variable}}}`).join(", ");
+
+const CERTIFICATE_DEPENDENT_HOST_COMMAND_VARIABLES: HostCommandVariable[] = [
+ HostCommandVariable.CertificatePath,
+ HostCommandVariable.CertificateFiles,
+ HostCommandVariable.CommonName
+];
+
+export const commandNeedsCertificateData = (command?: string): boolean => {
+ const used = findHostCommandVariables(command);
+ return CERTIFICATE_DEPENDENT_HOST_COMMAND_VARIABLES.some((variable) => used.has(variable));
+};
+
+export const findSingleCertificateHostCommandVariables = (command?: string): HostCommandVariable[] => {
+ const used = findHostCommandVariables(command);
+ return SINGLE_CERTIFICATE_HOST_COMMAND_VARIABLES.filter((variable) => used.has(variable));
+};
+
+export const buildHostCommandContext = (args: {
+ kind: HostCommandKind;
+ command: string;
+ destinationDirectory: string;
+ certificates: THostCommandCertificate[];
+ certificateFiles?: string[];
+ pkcs12Password?: string;
+}): THostCommandContext => {
+ const { kind, command, destinationDirectory, certificates, certificateFiles, pkcs12Password } = args;
+
+ const singleCertificateVariables = findSingleCertificateHostCommandVariables(command);
+ if (certificates.length > 1 && singleCertificateVariables.length > 0) {
+ const delivered = kind === HostCommandKind.Preflight ? "would deliver" : "delivered";
+ throw new PkiSyncError({
+ message: `${sentenceCase(kind)} uses ${formatHostCommandVariables(
+ singleCertificateVariables
+ )}. A variable that names one certificate cannot be resolved for a run that ${delivered} ${
+ certificates.length
+ } certificates. Unlink all but one certificate, or use {{certificateFiles}} instead.`,
+ shouldRetry: false
+ });
+ }
+
+ const onlyCertificate = certificates.length === 1 ? certificates[0] : undefined;
+
+ return {
+ certificatePath: onlyCertificate?.paths[0],
+ commonName: onlyCertificate?.commonName,
+ certificateDirectory: destinationDirectory,
+ certificateFiles: certificateFiles ?? certificates.flatMap((certificate) => certificate.paths),
+ pkcs12Password
+ };
+};
+
+const renderHostCommand = (
+ command: string,
+ values: Map<string, string | undefined>,
+ toShellLiteral: (value: string) => string
+): string =>
+ command.replace(VARIABLE_PATTERN, (match: string, name: string) =>
+ values.has(name) ? toShellLiteral(values.get(name) ?? "") : match
+ );
+
+export const renderHostCommandContext = (
+ command: string,
+ context: THostCommandContext,
+ toShellLiteral: (value: string) => string
+): string =>
+ renderHostCommand(
+ command,
+ new Map<string, string | undefined>([
+ [HostCommandVariable.CertificatePath, context.certificatePath],
+ [HostCommandVariable.CertificateDirectory, context.certificateDirectory],
+ [HostCommandVariable.CertificateFiles, context.certificateFiles.join("\n")],
+ [HostCommandVariable.CommonName, context.commonName],
+ [HostCommandVariable.Pkcs12Password, context.pkcs12Password]
+ ]),
+ toShellLiteral
+ );
+
+export const normalizeNewHostCommandOption = (
+ syncOptions: Record<string, unknown>,
+ optionKey: string
+): Record<string, unknown> => {
+ if (syncOptions[optionKey]) return syncOptions;
+
+ const normalized = { ...syncOptions };
+ delete normalized[optionKey];
+ return normalized;
+};
+
+export const applyHostCommandOptionUpdate = (
+ resolvedSyncOptions: Record<string, unknown>,
+ optionKey: string,
+ storedCommand: unknown
+): Record<string, unknown> => {
+ const requested = resolvedSyncOptions[optionKey];
+ const next = { ...resolvedSyncOptions };
+
+ const keep = requested === undefined ? storedCommand : requested;
+ if (typeof keep === "string" && keep) {
+ next[optionKey] = keep;
+ } else {
+ delete next[optionKey];
+ }
+
+ return next;
+};
+
+const redactSecrets = (text: string, secrets: Array<string | undefined>): string =>
+ secrets.reduce<string>((acc, secret) => (secret ? acc.split(secret).join(REDACTED_PLACEHOLDER) : acc), text);
+
++const TRUNCATION_SUFFIX = "... (truncated)";
++
++// A cut between the halves of a surrogate pair leaves a lone surrogate, which is not valid UTF-8.
++const sliceWholeCharacters = (text: string, end: number): string => {
++ const cut = text.slice(0, end);
++ const last = cut.charCodeAt(cut.length - 1);
++ return last >= 0xd800 && last <= 0xdbff ? cut.slice(0, -1) : cut;
++};
++
++// The suffix counts against maxLength, so the cap bounds what actually gets stored.
+const truncate = (text: string, maxLength: number): string =>
- text.length > maxLength ? `${text.slice(0, maxLength)}... (truncated)` : text;
++ text.length > maxLength
++ ? `${sliceWholeCharacters(text, Math.max(0, maxLength - TRUNCATION_SUFFIX.length))}${TRUNCATION_SUFFIX}`
++ : text;
+
+const firstNonEmptyLine = (text?: string): string | undefined =>
+ text
+ ?.split("\n")
+ .map((line) => line.trim())
+ .find(Boolean);
+
+const captureOutput = (stdout: string, stderr: string): string | undefined => {
+ const combined = [stdout.trim(), stderr.trim()].filter(Boolean).join("\n");
+ return combined ? truncate(combined, MAX_CAPTURED_OUTPUT_CHARS) : undefined;
+};
+
+const withHostCommandDeadline = <T>(execute: () => Promise<T>, timeoutMs: number, graceMs: number): Promise<T> => {
+ let timer: NodeJS.Timeout;
+
+ return Promise.race([
+ execute(),
+ new Promise<never>((_, reject) => {
+ timer = setTimeout(() => reject(new Error(`command timed out after ${timeoutMs / 1000}s`)), timeoutMs + graceMs);
+ })
+ ]).finally(() => clearTimeout(timer));
+};
+
+export const runHostCommand = async (args: {
+ kind: HostCommandKind;
+ syncId: string;
+ execute: () => Promise<THostCommandExecutionResult>;
+ secretsToRedact?: Array<string | undefined>;
+}): Promise<THostCommandResult> => {
+ const { kind, syncId, execute, secretsToRedact = [] } = args;
+ const timeoutMs = HOST_COMMAND_TIMEOUT_MS[kind];
+ const startedAt = Date.now();
+ const redact = (text: string) => redactSecrets(text, secretsToRedact);
+
+ try {
+ const { stdout, stderr, exitCode } = await withHostCommandDeadline(execute, timeoutMs, DEADLINE_GRACE_MS);
+ const durationMs = Date.now() - startedAt;
+ const output = captureOutput(redact(stdout), redact(stderr));
+
+ if (exitCode === 0) {
+ logger.info(`PKI sync ${kind} succeeded [syncId=${syncId}] [durationMs=${durationMs}]`);
+ return { status: PkiSyncStatus.Succeeded, exitCode, durationMs, output };
+ }
+
+ logger.warn(`PKI sync ${kind} failed [syncId=${syncId}] [exitCode=${exitCode}] [durationMs=${durationMs}]`);
++ const detail = firstNonEmptyLine(redact(stderr));
+ return {
+ status: PkiSyncStatus.Failed,
+ exitCode,
+ durationMs,
+ output,
- failureDetail: firstNonEmptyLine(redact(stderr))?.slice(0, MAX_FAILURE_DETAIL_CHARS),
++ failureDetail: detail ? truncate(detail, MAX_FAILURE_DETAIL_CHARS) : undefined,
+ error: `Command exited with code ${exitCode}`
+ };
+ } catch (err) {
+ const durationMs = Date.now() - startedAt;
+ const error = redact((err as Error)?.message ?? "Unknown error");
+ logger.warn(`PKI sync ${kind} could not run [syncId=${syncId}] [durationMs=${durationMs}]: ${error}`);
+ return { status: PkiSyncStatus.Failed, durationMs, error };
+ }
+};
+
+export const hostCommandMessageSubject = (kind: HostCommandKind): string => sentenceCase(kind);
+
+export const buildHostCommandFailureMessage = (
+ kind: HostCommandKind,
+ result: THostCommandResult,
+ subject: string = hostCommandMessageSubject(kind)
+): string => {
+ const detail = result.failureDetail ?? firstNonEmptyLine(result.output);
+
+ if (result.exitCode === undefined) {
+ return `${subject} could not run: the destination host could not be reached`;
+ }
+
+ const prefix = `${subject} failed (exit ${result.exitCode})`;
+ return detail ? `${prefix}: ${truncate(detail, MAX_FAILURE_DETAIL_CHARS)}` : prefix;
+};
diff --cc docs/documentation/platform/pki/applications/certificate-syncs/linux-server.mdx
index e102205ae7,248a531e5b..1c65518a50
--- a/docs/documentation/platform/pki/applications/certificate-syncs/linux-server.mdx
+++ b/docs/documentation/platform/pki/applications/certificate-syncs/linux-server.mdx
@@@ -20,9 -18,9 +20,9 @@@ Deploy certificates from Infisical to
- An [SSH Connection](/integrations/app-connections/ssh) with access to the target server
- The destination directory must already exist on the server and the connection user must be able to write to it
- The server must be reachable from Infisical, either directly or through an [Infisical Gateway](/documentation/platform/gateways/overview)
-- A Gateway is required to use a [post-sync command](#post-sync-commands), because the Gateway is what executes it. It must be running Infisical CLI v0.43.120 or later
+- A Gateway is required to use a [preflight check](#preflight-checks) or a [post-sync command](#post-sync-commands), because the Gateway is what executes them. It must be running Infisical CLI v0.43.120 or later
- ## Create a Linux Server Sync
+ ## Create a Linux Server sync
<Tabs>
<Tab title="Infisical UI">
@@@ -115,78 -111,9 +115,78 @@@ PKCS#1
When syncing certificates, Infisical opens an SSH session to the server and, for each certificate, packages it in the chosen export format and writes the resulting files to the destination directory. Files are written atomically over SFTP so a reader never sees a partially written certificate or key.
- ## Preflight Checks
++## Preflight checks
+
+A sync can only tell you the host was not ready once it has already tried. If the destination directory was renamed or the service that owns it is stopped, you find out from a failed sync, and on a renewal that is the day the certificate was going to expire anyway.
+
+A preflight check moves that discovery earlier. It is one command that runs on the target server before any certificate is written. If it exits non-zero, the sync stops there: no files are delivered, no removals happen, and no post-sync command runs. Leaving the field empty means nothing runs, so there is no separate toggle.
+
+The same check also runs on its own once a day, so a host that stops being ready between syncs is reported when it happens rather than at the next renewal.
+
+Write a check that answers a question rather than one that changes something. `test -w /etc/ssl/certs` and `systemctl is-active nginx` are good checks. Creating the directory or starting the service is work for the post-sync command.
+
+<Note>
+ Your [Infisical Gateway](/documentation/platform/gateways/overview) runs the check, never Infisical. The sync's SSH Connection must therefore use a gateway, otherwise the check is rejected when you save the sync.
+</Note>
+
+<PreflightCheckFlow />
+
- ### Setting a Check
++### Setting a check
+
+<Steps>
+ <Step title="Open the sync's Commands step">
+ Edit the sync and select **Commands**.
+ </Step>
+ <Step title="Write the check">
+ Anything that exits non-zero when the host is not ready works. The variables resolve to the files
+ this run is about to write, so a check can look at where a certificate is going:
+
+ ```bash
+ set -e
+ test -w {{certificateDirectory}}
+ test ! -e {{certificatePath}} || test -w {{certificatePath}}
+ systemctl is-active --quiet nginx
+ ```
+ </Step>
+ <Step title="Save and trigger a sync">
+ Save the sync, then trigger it. If the check fails, the sync fails without delivering, and the reason appears as the sync's last error.
+ </Step>
+</Steps>
+
- ### Available Variables
++### Available variables
+
+<PreflightCheckVariables />
+
- ### Length Limit
++### Length limit
+
- A check is limited to 2048 characters, counted after the variables are substituted. For anything longer, put the logic in a script on the server and call that script.
++A check is limited to 8192 characters, counted after the variables are substituted. For anything longer, put the logic in a script on the server and call that script.
+
- ### Preflight Check FAQ
++### Preflight check FAQ
+
+<AccordionGroup>
+ <Accordion title="When exactly does the check run?">
+ Before anything else in a sync run, including before Infisical opens the SFTP session it would write with. It also runs once a day on its own, whether or not a sync is due.
+ </Accordion>
+ <Accordion title="What happens when the check fails?">
+ The sync is marked failed and the reason appears as the sync's last error. Every certificate in the run is reported as skipped with that same reason, so it is clear nothing reached the host. Files already on the server from an earlier run are left exactly as they are, because the sync never wrote or deleted anything.
+ </Accordion>
+ <Accordion title="Where do I see the result of the daily check?">
+ A failing daily check marks the sync failed and puts the reason in its last error, the same place a failed sync run reports one, so a broken host shows up wherever you already watch your syncs. A passing check changes nothing. Either way the run is recorded in the sync's logs with the command and its full output.
+ </Accordion>
+ <Accordion title="Is there a time limit?">
+ Yes, 10 seconds, and a check that runs out of time counts as a failure. The limit is deliberately much shorter than the post-sync command's, because the check gates delivery: a host that cannot answer a readiness question in ten seconds is itself the problem worth reporting. Keep the check to a question that is cheap to answer.
+ </Accordion>
+ <Accordion title="Does a failed check get retried?">
+ Not within the run. A host that is not ready is usually not ready a few seconds later either, so retrying only delays the report. The next sync or the next daily check is the retry.
+ </Accordion>
+ <Accordion title="Can I use it to prepare the host instead of just checking it?">
+ You can, since it is a free-text command, but prefer not to. A check that also does work runs before every sync and has ten seconds to finish, and if it fails halfway you have changed the host and delivered nothing. Keep preparation in the post-sync command, or in a script the check only verifies the result of.
+ </Accordion>
+</AccordionGroup>
+
- ## Post-Sync Commands
+ ## Post-sync commands
- Delivering 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.
+ Delivering 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. 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.
@@@ -200,11 -127,11 +200,11 @@@ The field accepts a whole script, so se
<PostSyncCommandFlow />
- ### Setting a Command
+ ### Setting a command
<Steps>
- <Step title="Open the sync's Post-Sync Command step">
- Edit the sync and select **Post-Sync Command**.
+ <Step title="Open the sync's Commands step">
+ Edit the sync and select **Commands**.
</Step>
<Step title="Write the command">
Use a variable wherever you need a value from the run. Typing `{{` in the command field lists the ones available for this sync, so you can pick one instead of remembering the name:
@@@ -255,9 -182,9 +255,9 @@@ A command is limited to 8192 characters
</Accordion>
</AccordionGroup>
- ### Least Privilege
+ ### Least privilege
-The command runs as the account the SSH Connection authenticates with, so constraining that account bounds what any command can do. A service reload does not need root. Grant the connection user a `sudoers` rule for that one command instead:
+Both the preflight check and the post-sync command run as the account the SSH Connection authenticates with, so constraining that account bounds what either can do. A service reload does not need root. Grant the connection user a `sudoers` rule for that one command instead:
```text
svc-infisical ALL=(root) NOPASSWD: /usr/bin/systemctl reload nginx
diff --cc docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdx
index b01910e2d9,d823981782..a3cd9a12a6
--- a/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdx
+++ b/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdx
@@@ -123,74 -119,7 +123,76 @@@ When syncing certificates, Infisical as
When certificate removal is enabled and a certificate is removed from the sync, revoked, or expired, Infisical deletes exactly the files it delivered for that certificate.
- ## Preflight Checks
++## Preflight checks
+
+A sync can only tell you the host was not ready once it has already tried. If the destination folder was renamed or the service that owns the certificate is stopped, you find out from a failed sync, and on a renewal that is the day the certificate was going to expire anyway.
+
+A preflight check moves that discovery earlier. It is one PowerShell command that the Gateway runs on the target server before any certificate is written. If it fails, the sync stops there: no files are delivered, no removals happen, and no post-sync command runs. Leaving the field empty means nothing runs, so there is no separate toggle.
+
+The same check also runs on its own once a day, so a host that stops being ready between syncs is reported when it happens rather than at the next renewal.
+
+Write a check that answers a question rather than one that changes something. Testing that the folder exists or that a service is running is a good check. Creating the folder or starting the service is work for the post-sync command.
+
+<PreflightCheckFlow />
+
- ### Setting a Check
++### Setting a check
+
+<Steps>
+ <Step title="Open the sync's Commands step">
+ Edit the sync and select **Commands**.
+ </Step>
+ <Step title="Write the check">
+ The script runs with `$ErrorActionPreference` set to `Stop`, so a failing cmdlet is enough to mark the host not ready. Use `throw "reason"` when you want to say why:
+
+ ```powershell
+ if (-not (Test-Path {{certificateDirectory}})) { throw "destination folder is missing" }
+ if ((Get-Service W3SVC).Status -ne "Running") { throw "W3SVC is not running" }
+ ```
+ </Step>
+ <Step title="Save and trigger a sync">
+ Save the sync, then trigger it. If the check fails, the sync fails without delivering, and the reason appears as the sync's last error.
+ </Step>
+</Steps>
+
- ### Available Variables
++### Available variables
+
+<PreflightCheckVariables />
+
- ### Length Limit
++### Length limit
+
- A check is limited to 2048 characters, for the same reason a post-sync command is: Windows caps a command line at 8191 characters and the check is sent to PowerShell encoded, which expands it. For anything longer, put the logic in a script file on the server and have the check call that script.
++A check is limited to 8192 characters, counted after the variables are substituted. For anything longer, put the logic in a script file on the server and have the check call that script.
+
- ### Preflight Check FAQ
++Going past 2048 characters requires a Gateway on Infisical CLI v0.43.124 or later. See the Gateway version note above.
++
++### Preflight check FAQ
+
+<AccordionGroup>
+ <Accordion title="When exactly does the check run?">
+ Before anything else in a sync run, in its own WinRM session, before the one Infisical would deliver with. It also runs once a day on its own, whether or not a sync is due.
+ </Accordion>
+ <Accordion title="What happens when the check fails?">
+ The sync is marked failed and the reason appears as the sync's last error. Every certificate in the run is reported as skipped with that same reason, so it is clear nothing reached the host. Files already on the server from an earlier run are left exactly as they are, because the sync never wrote or deleted anything.
+ </Accordion>
+ <Accordion title="How do I make the check fail deliberately?">
+ Use `throw "reason"`, the same as in a post-sync command. Avoid `exit`: PowerShell stops the script there before it can report its result, so the check is treated as failed with a message saying the outcome could not be read rather than with your reason.
+ </Accordion>
+ <Accordion title="Where do I see the result of the daily check?">
+ A failing daily check marks the sync failed and puts the reason in its last error, the same place a failed sync run reports one, so a broken host shows up wherever you already watch your syncs. A passing check changes nothing. Either way the run is recorded in the sync's logs with the command and its full output.
+ </Accordion>
+ <Accordion title="Is there a time limit?">
+ Yes, 10 seconds, and a check that runs out of time counts as a failure. The limit is deliberately much shorter than the post-sync command's, because the check gates delivery: a host that cannot answer a readiness question in ten seconds is itself the problem worth reporting. Keep the check to a question that is cheap to answer.
+
+ On Windows the ten seconds bound how long Infisical waits, not the host. WinRM gives no way to cancel a command once it has started, so a check that hangs is reported as a timeout and the sync fails, but the command itself keeps running on the server until it finishes. This is the other reason to keep a check to a cheap question rather than real work.
+ </Accordion>
+ <Accordion title="Does a failed check get retried?">
+ Not within the run. A host that is not ready is usually not ready a few seconds later either, so retrying only delays the report. The next sync or the next daily check is the retry.
+ </Accordion>
+ <Accordion title="Can I use it to prepare the host instead of just checking it?">
+ You can, since it is a free-text command, but prefer not to. A check that also does work runs before every sync and has ten seconds to finish, and if it fails halfway you have changed the host and delivered nothing. Keep preparation in the post-sync command, or in a script the check only verifies the result of.
+ </Accordion>
+</AccordionGroup>
+
- ## Post-Sync Commands
+ ## Post-sync commands
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.
@@@ -206,11 -135,11 +208,11 @@@ Your Gateway runs the command, never In
<PostSyncCommandFlow />
- ### Setting a Command
+ ### Setting a command
<Steps>
- <Step title="Open the sync's Post-Sync Command step">
- Edit the sync and select **Post-Sync Command**.
+ <Step title="Open the sync's Commands step">
+ Edit the sync and select **Commands**.
</Step>
<Step title="Write the command">
Use a variable wherever you need a value from the run. Typing `{{` in the command field lists the ones available for this sync, so you can pick one instead of remembering the name:
@@@ -262,9 -193,9 +266,9 @@@ Going past 2048 characters requires a G
</Accordion>
</AccordionGroup>
- ### Least Privilege
+ ### Least privilege
-The command runs as the account the WinRM Connection authenticates with, so constraining that account bounds what any command can do. Restarting one service does not need an administrator. Grant the connection account start and stop rights on that single service instead of making it a local administrator.
+Both the preflight check and the post-sync command run as the account the WinRM Connection authenticates with, so constraining that account bounds what either can do. Restarting one service does not need an administrator. Grant the connection account start and stop rights on that single service instead of making it a local administrator.
Binding a certificate to an HTTPS port in IIS is the exception: HTTP.sys requires a local administrator and the right cannot be delegated. Because a local administrator can do anything on the host, handle that case with a dedicated, clearly labeled sync rather than raising the privileges of a sync that only needs to deliver files and restart a service. Infisical does not block an administrator credential on a standard sync, so this is a recommendation you enforce with how you configure the connection.