Skip to content

fix(scan): resolve package managers under the LaunchAgent's stripped PATH#130

Merged
ashishkurmi merged 2 commits into
step-security:mainfrom
shubham-stepsecurity:sm/fix-npm-launchagent-path
Jun 5, 2026
Merged

fix(scan): resolve package managers under the LaunchAgent's stripped PATH#130
ashishkurmi merged 2 commits into
step-security:mainfrom
shubham-stepsecurity:sm/fix-npm-launchagent-path

Conversation

@shubham-stepsecurity
Copy link
Copy Markdown
Member

What does this PR do?

Type of change

  • Bug fix
  • Enhancement
  • Documentation

Testing

  • Tested on macOS (version: ___)
  • Binary runs without errors: ./stepsecurity-dev-machine-guard --verbose
  • JSON output is valid: ./stepsecurity-dev-machine-guard --json | python3 -m json.tool
  • No secrets or credentials included
  • Lint passes: make lint
  • Tests pass: make test

Related Issues

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 RunAsUser to 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.

Comment thread internal/executor/user_aware.go
@ashishkurmi ashishkurmi merged commit 91f943b into step-security:main Jun 5, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants