feat: add Start-InfisicalProcess cmdlet and -Prefix support on Export-InfisicalSecrets #12
Reference in New Issue
Block a user
Delete Branch "dev"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds a new process-execution cmdlet that natively injects Infisical secrets
into a child process's environment, and adds a
-Prefixparameter toExport-InfisicalSecretsso prefixed naming is supported across every exportformat.
Brings the module's exported cmdlet count from 40 to 42.
Changes
Export-InfisicalSecrets—-Prefix <string>InfisicalSecretis shallow-clonedwith
SecretName = Prefix + SecretNamebefore being handed to the exporter,so prefixing applies uniformly to
EnvironmentVariables,JSON,DotEnv,Yaml,Csv, andPSCredentialListformats without per-exporter changes.-Prefixis null/empty (early return uses the original arrayreference; pipeline objects are never mutated).
Start-InfisicalProcess(new)ProcessStartInfo.Environment. Secret plaintext is never written to user ormachine environment scope.
InfisicalSecret[]via-Secret(aliasesSecrets,InputObject). Optional-Prefixmirrors theExport-InfisicalSecretsbehavior.
-EnvironmentVariablessupplies additional non-secret variables.-WorkingDirectory,-ArgumentList,-AcceptableExitCodeList(supports*, integer, and hex forms),-WindowStyle/-CreateNoWindowparameter sets,-Priority,-StandardInputObjectList,-NoWait,-ExecutionTimeout,-ExecutionTimeoutInterval,-ParsingExpression(regex over stdout/stderr),-SecureArgumentList,-LogOutput,-ContinueOnError, and fullShouldProcess(-WhatIf/-Confirm) support.InfisicalProcessResultwithExitCode,ExitCodeAsHex,ExitCodeAsInteger,ExitCodeAsDecimal,StandardOutput,StandardError,StandardOutputObject,StandardErrorObject,StartTime,ExitTime,Duration,DurationFriendly,ProcessId,TimedOut,Succeeded, andSecretCount.PowerShell-safe process I/O
The runner deliberately avoids TPL/
asyncconstructs that can deadlock underthe PowerShell host's
SynchronizationContext:OutputDataReceived/ErrorDataReceivedwithBeginOutputReadLine/BeginErrorReadLine. NoTask<string>, noReadToEndAsync, noGetAwaiter().GetResult().do { log; sleep } while (!HasExited)patternwith
Thread.Sleep(pollInterval), so verbose "has been running for X" and"Checking again in Y" messages fire at the configured cadence even when no
-ExecutionTimeoutis supplied (indefinite wait still logs).WaitForExit()after the polling loop confirms exit, then readsExitCode/
ExitTimesynchronously.Friendly TimeSpan formatting
Verbose log messages and the result's
DurationFriendlyproperty renderTimeSpanvalues in the same human-readable form as the legacyStart-ProcessWithOutputGetTimeSpanMessagescriptblock:30 seconds1 minute, and 30 seconds7 seconds, and 364 milliseconds1 hour, 2 minutes, 3 seconds, and 45 millisecondsN/Awhen zeroSingular units drop the trailing
s(1 secondvs.2 seconds); zerocomponents are skipped; the final component is joined with
", and ".Tests
InfisicalProcessRunnerHelpersTests) coverFormatFriendlysingular/plural, multi-unit joining, zero,sub-millisecond, and skip-zero-components behavior.
build.ps1 -RunTestsclean (build + tests + publish + help stage +manifest/import validation green; help XML contains 42 cmdlet entries).
Validated manually
Local smoke harness (
scripts/..., gitignored) confirms end-to-end:cmd /c set SMOKE_).long-running child (
pwsh -c "Start-Sleep -Seconds 7").ExecutionTimeout=5svs.Start-Sleep 30); result reportsTimedOut=$True,Succeeded=$False,ExitCode=-1.Docs
README.md— new cmdlet listed and described.docs/DesignSpec.md—§16.5(Export-Prefix) and§16.6(
Start-InfisicalProcess) updated;InfisicalProcessResultproperty listincludes
DurationFriendly.Module/PSInfisicalAPI/en-US/PSInfisicalAPI.dll-Help.xml—Export-InfisicalSecrets-Prefixexample and fullStart-InfisicalProcesshelp entry added.CHANGELOG.md— Unreleased entries for both changes.Commits in this PR
318db70feat(export): add -Prefix parameter to Export-InfisicalSecretsd3c7b83Build artifacts for318db70480207e742feat(process): add Start-InfisicalProcess with event-based capture and friendly TimeSpan logging15fadd0Build artifacts for207e7429e4318db70480d3c7b83da7- New cmdlet Start-InfisicalProcess: launches a child process with InfisicalSecret objects decrypted directly into ProcessStartInfo.Environment (optional -Prefix), additional -EnvironmentVariables, stdout/stderr capture, -AcceptableExitCodeList, -ParsingExpression regex parsing, -ExecutionTimeout / -ExecutionTimeoutInterval, -NoWait, -WindowStyle / -CreateNoWindow parameter sets, -Priority, -StandardInputObjectList, -SecureArgumentList, -LogOutput, -ContinueOnError, and ShouldProcess support. Secret plaintext is never written to user or machine scope. - Stream capture uses event-based OutputDataReceived/ErrorDataReceived with BeginOutputReadLine/BeginErrorReadLine (no Task / ReadToEndAsync / GetAwaiter().GetResult()) to avoid PowerShell SynchronizationContext deadlocks. - Restored the do { log; sleep } while (!HasExited) polling pattern using Thread.Sleep(pollInterval) so verbose "has been running for X" / "Checking again in Y" messages fire at the configured cadence even when no -ExecutionTimeout is supplied. - TimeSpan values in verbose logs and on the result now use a friendly format ("7 seconds, and 364 milliseconds", "1 minute, and 30 seconds", "N/A" when zero) matching the legacy Start-ProcessWithOutput GetTimeSpanMessage scriptblock. - Added DurationFriendly property to InfisicalProcessResult and a "The command execution took X" verbose line at completion. - build.ps1 CmdletsToExport and Test-ModuleImports expected list contain 42 cmdlets. - Added 9 xUnit tests covering FormatFriendly singular/plural, multi-unit joining, zero, sub-millisecond, and skip-zero-components behavior.207e7429e4