chore(node-scan): optimize scan times #81
Open
swarit-stepsecurity wants to merge 2 commits into
Open
Conversation
Signed-off-by: Swarit Pandey <swarit@stepsecurity.io>
Project and global yarn scans constructed `cd "<dir>" && <pm> ls ...` shell strings and dispatched them via `cmd /c`. Go's os/exec quotes the third arg (MSVC rules: backslash-escaped quotes), and cmd.exe applies its own quote-stripping rules to /c args. The two disagree when the arg contains both an embedded quoted path and special characters like &&, so cmd.exe emits "The filename, directory name, or volume label syntax is incorrect." and the scan returns exit code 1 with empty stdout. Confirmed on Windows Server 2025: every npm/yarn/pnpm scan failed, telemetry shipped a 92-byte error message instead of the package tree. Add Executor.RunInDir which uses os/exec's cmd.Dir on Windows (no cmd.exe at all). Unix path still uses the shell so RunAsUser/sudo delegation keeps working for root cron runs. Existing TestNodeScanner_ScanProject_Windows and ScanYarnGlobal_Windows tests only exercised the mock — they never actually invoked cmd.exe, so the bug never surfaced. Updated to mock the new dispatch path. Signed-off-by: Swarit Pandey <swarit@stepsecurity.io>
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