fix: pass paths to PowerShell via environment instead of -Command args - #189
Merged
Conversation
powershell.exe -Command treats everything after the script string as command text, not $args, so the Authenticode verifier received an empty -LiteralPath and the installer path leaked into ConvertTo-Json. This broke every Windows desktop-app install (ChatGPT, WorkBuddy, ZCode) and silently dropped WorkBuddy version detection. All PowerShell parameters now travel through environment variables, which also removes the display-name string interpolation in the StartApps query. Scripts set UTF-8 output encoding so errors stay readable on CJK Windows. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
powershell.exe -Command <script> <path>会把脚本字符串之后的所有 token 拼进命令文本,而不是变成$args。这导致两个连锁错误(见 Windows 端安装日志):Get-AuthenticodeSignature -LiteralPath $args[0]收到$null→ParameterArgumentValidationErrorNullNotAllowedConvertTo-Json -Compress之后 →InputObjectNotBound影响面
verifyWindowsInstallerPublisher是 ChatGPT Desktop、WorkBuddy(国内/国际版)、ZCode 四条 Windows 安装链路共用的验签入口,验签必然报错,安装中断。workBuddyWindowsVersion用了相同的错误模式,失败返回 nil,表现为已安装的 WorkBuddy 永远显示不出版本号。workBuddyStartAppsQuery把应用显示名直接拼进 PowerShell 单引号字符串。修复
统一改为通过环境变量传参(
runWithEnvironment原生支持),彻底绕开-Command的拼接语义与路径引号转义问题:$env:BOOTAGENT_VERIFY_PATH,argv 不再携带路径$env:BOOTAGENT_VERSION_PATH$env:BOOTAGENT_APP_NAME,消除字符串拼接[Console]::OutputEncoding = [Text.Encoding]::UTF8macOS 侧(codesign/spctl/plutil/hdiutil/ditto)均为正常 argv 传参,审查后无需改动。
测试
新增 3 个测试,断言路径/名称只通过环境变量到达、不出现在 argv 或脚本文本中(验签测试使用含空格和单引号的路径):
TestVerifyWindowsInstallerPassesPathViaEnvironmentTestWorkBuddyWindowsVersionPassesPathViaEnvironmentTestWorkBuddyStartAppsQueryPassesNameViaEnvironment🤖 Generated with Claude Code