-
Notifications
You must be signed in to change notification settings - Fork 45
fix: resolve install binary verification, uninstall, and version prefix bugs #535
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
d3f2bf7
fix: resolve install script binary verification, uninstall, and versi…
khaliqgant 768241f
fix: remove shell-dependent 2>/dev/null from npm uninstall execCommand
khaliqgant 476a44a
fix: only remove ~/.agent-relay/bin/ not entire ~/.agent-relay directory
khaliqgant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Oops, something went wrong.
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.
Check warning
Code scanning / CodeQL
Indirect uncontrolled command line Medium
Copilot Autofix
AI about 2 months ago
In general, the safest fix is to avoid
exec/execSyncwith a single shell command string when any part of that string comes from untrusted or tainted data. Instead, useexecFile/execFileSync(orspawn/spawnSync) and pass arguments as an array of strings; this avoids shell parsing, redirection, and environment-variable expansion. For cases where you truly need shell features like redirection (2>/dev/null) or|| true, wrap that in a small, fixed shell snippet and keep all untrusted data passed as separate arguments, or emulate the behavior in JavaScript (e.g., ignore errors instead of|| true, discard stderr instead of2>/dev/null).Here, we only need to (a) run
xattr -d com.apple.quarantine <targetPath>and ignore any errors, and (b) runcodesign --force --sign - <targetPath>and ignore errors. Both can be implemented withexecFileSyncwithout any shell metacharacters, and the “ignore failure” behavior can be preserved by wrapping each call in atry/catchas already done. So the single best fix is:execFileSyncto the existing import fromnode:child_process.execSync(\xattr -d com.apple.quarantine "${targetPath}" 2>/dev/null || true`, ...)withexecFileSync('xattr', ['-d', 'com.apple.quarantine', targetPath], ...). The previous2>/dev/null || true` is unnecessary because:stdio: ['pipe','pipe','pipe']already prevents stderr from cluttering the console.try/catcharound the call already makes errors non-fatal.execSync(\codesign --force --sign - "${targetPath}"`, ...)withexecFileSync('codesign', ['--force', '--sign', '-', targetPath], ...)`.This preserves all semantics (timeout, stdio behavior, non-fatal nature of failures), removes any use of an interpolated shell command string, and thus addresses all variants of the alert at this location.