fix(detection): symlinked path detection#59
Merged
ashishkurmi merged 3 commits intostep-security:mainfrom May 5, 2026
Merged
Conversation
Signed-off-by: Swarit Pandey <swarit@stepsecurity.io>
Signed-off-by: Swarit Pandey <swarit@stepsecurity.io>
There was a problem hiding this comment.
Pull request overview
This PR improves AI tool/agent detection by resolving symlinked (notably npm-installed) CLI/agent binaries to a more meaningful install_path, and by making version parsing resilient to warning/decorated --version output.
Changes:
- Add
Executor.EvalSymlinks(real + mock + user-aware wrapper) and use it to resolve symlinked binary paths. - Populate
install_pathfor AI CLI tools and general agents (including npm package-root extraction and Windows.cmdshim parsing). - Make version extraction consistent across detectors by scanning output lines for version-like tokens; adjust agent detection to avoid false positives from stale/empty config dirs and add tests.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/executor/user_aware.go | Adds EvalSymlinks passthrough so the wrapper continues to satisfy Executor. |
| internal/executor/mock.go | Adds symlink stubbing and a mock EvalSymlinks implementation for tests. |
| internal/executor/executor.go | Extends the Executor interface and implements EvalSymlinks for the real executor. |
| internal/detector/framework.go | Uses shared version extraction helper to handle decorated --version output. |
| internal/detector/framework_test.go | Adds coverage for framework version parsing when warnings precede the version line. |
| internal/detector/aicli.go | Adds install-path resolution (symlinks + npm roots + Windows shim parsing) and shared version extraction. |
| internal/detector/aicli_test.go | Adds tests for npm symlink resolution, Windows shim parsing, and decorated version output. |
| internal/detector/agent.go | Requires a resolved binary for agent detection; adds install-path resolution + config-dir selection logic. |
| internal/detector/agent_test.go | Updates/extends tests to validate binary-required detection and npm install-path behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+52
to
+53
| // EvalSymlinks resolves symbolic links in a path. Returns the resolved | ||
| // canonical path. If the path is not a symlink, returns it unchanged. |
Comment on lines
+153
to
+154
| // If a path is not registered, EvalSymlinks returns the path unchanged | ||
| // (matching the behavior of filepath.EvalSymlinks on a non-symlink). |
ashishkurmi
approved these changes
May 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