fix(scan): resolve package managers under the LaunchAgent's stripped PATH#130
Merged
ashishkurmi merged 2 commits intoJun 5, 2026
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to make package-manager detection/scanning reliable when the agent is launched by launchd with a stripped PATH (notably in LaunchAgent mode), by running package-manager commands through the logged-in user’s login shell and surfacing more diagnostic error details.
Changes:
- Extend “user-aware” execution to apply in non-root LaunchAgent mode (not just root/LaunchDaemon mode) so tools installed via shell init (nvm/fnm/homebrew) can be resolved.
- Update Unix
RunAsUserto run via the user’s login shell in both root and non-root cases, and include stderr snippets in errors for better telemetry diagnosability. - Add/expand tests covering the new wrapping/delegation behavior and PATH recovery under stripped environments.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/telemetry/telemetry.go | Updates logged-in user handling docs and uses the user-aware executor to ensure package-manager commands resolve under stripped PATH. |
| internal/executor/user_aware.go | Expands wrapping to non-root mode so commands run through the user’s login shell. |
| internal/executor/user_aware_test.go | Adds tests pinning wrapping behavior and non-root delegation routing. |
| internal/executor/executor_unix.go | Makes RunAsUser use login shell without sudo when already non-root; folds stderr snippet into errors. |
| internal/executor/executor_unix_test.go | Adds real-shell tests proving stderr is surfaced and stripped PATH is recovered via rc sourcing. |
| internal/detector/nodescan.go | Delegates node package manager operations via login shell when a user is available; improves error reporting/logging. |
| internal/detector/nodescan_test.go | Adds tests verifying new delegation decision and telemetry error surfacing in delegated runs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ashishkurmi
approved these changes
Jun 5, 2026
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.
What does this PR do?
Type of change
Testing
./stepsecurity-dev-machine-guard --verbose./stepsecurity-dev-machine-guard --json | python3 -m json.toolmake lintmake testRelated Issues