-
Notifications
You must be signed in to change notification settings - Fork 0
Harden PowerShell execution, package source policy, and privileged file handling #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
7ce2bd1
5bd9285
c6ef82f
eeb716e
5ea80fc
efbb5d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| # Wrapper script for choco-pack-install | ||
| powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "src\Choco\choco-pack-install.ps1") @args | ||
| & (Join-Path $PSScriptRoot "src\Choco\choco-pack-install.ps1") @args | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| # Wrapper script for choco-package-explorer | ||
| powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "src\Choco\choco-package-explorer.ps1") @args | ||
| & (Join-Path $PSScriptRoot "src\Choco\choco-package-explorer.ps1") @args |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,2 +1,2 @@ | ||||||||||||||
| # Wrapper script for choco-sync | ||||||||||||||
| powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "src\Choco\choco-sync.ps1") @args | ||||||||||||||
| & (Join-Path $PSScriptRoot "src\Choco\choco-sync.ps1") @args | ||||||||||||||
|
||||||||||||||
| & (Join-Path $PSScriptRoot "src\Choco\choco-sync.ps1") @args | |
| $scriptPath = Join-Path $PSScriptRoot "src\Choco\choco-sync.ps1" | |
| $powerShellPath = (Get-Process -Id $PID).Path | |
| $argumentList = @('-NoProfile', '-File', $scriptPath) + $args | |
| $process = Start-Process -FilePath $powerShellPath -ArgumentList $argumentList -Wait -PassThru | |
| [Environment]::ExitCode = $process.ExitCode |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,2 +1,2 @@ | ||||||||||||||||||||
| # Wrapper script for choco-upgrade-interactive | ||||||||||||||||||||
| powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "src\Choco\choco-upgrade-interactive.ps1") @args | ||||||||||||||||||||
| & (Join-Path $PSScriptRoot "src\Choco\choco-upgrade-interactive.ps1") @args | ||||||||||||||||||||
|
||||||||||||||||||||
| & (Join-Path $PSScriptRoot "src\Choco\choco-upgrade-interactive.ps1") @args | |
| $targetScript = Join-Path $PSScriptRoot "src\Choco\choco-upgrade-interactive.ps1" | |
| $powerShellExe = if ($PSVersionTable.PSEdition -eq 'Core') { | |
| Join-Path $PSHOME 'pwsh.exe' | |
| } else { | |
| Join-Path $PSHOME 'powershell.exe' | |
| } | |
| & $powerShellExe -NoProfile -File $targetScript @args |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,2 +1,2 @@ | ||||||||||
| # Wrapper script for choco-utils | ||||||||||
| powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "src\Choco\choco-utils.ps1") @args | ||||||||||
| & (Join-Path $PSScriptRoot "src\Choco\choco-utils.ps1") @args | ||||||||||
|
||||||||||
| & (Join-Path $PSScriptRoot "src\Choco\choco-utils.ps1") @args | |
| $targetScript = Join-Path $PSScriptRoot "src\Choco\choco-utils.ps1" | |
| $powerShellExe = if ($PSVersionTable.PSEdition -eq 'Core') { 'pwsh' } else { 'powershell' } | |
| & $powerShellExe -NoProfile -File $targetScript @args |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,2 +1,2 @@ | ||||||||||
| # Wrapper script for list-choco-apps | ||||||||||
| powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "src\Choco\list-choco-apps.ps1") @args | ||||||||||
| & (Join-Path $PSScriptRoot "src\Choco\list-choco-apps.ps1") @args | ||||||||||
|
||||||||||
| & (Join-Path $PSScriptRoot "src\Choco\list-choco-apps.ps1") @args | |
| $targetScript = Join-Path $PSScriptRoot "src\Choco\list-choco-apps.ps1" | |
| $powerShellCommand = if (Get-Command pwsh -ErrorAction SilentlyContinue) { "pwsh" } else { "powershell" } | |
| & $powerShellCommand -NoProfile -File $targetScript @args |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wrapper now calls
src/Choco/choco-pack-install.ps1in-process. That script contains severalexitstatements (e.g., after elevation relaunch/cancel), which will terminate the caller’s entire PowerShell session if this wrapper is run from an interactive prompt. Prefer spawning a separate PowerShell process (without forcingExecutionPolicy Bypass) or refactoring the target script to usereturn/exceptions.