Skip to content

chore(node-scan): optimize scan times #81

Open
swarit-stepsecurity wants to merge 2 commits into
step-security:mainfrom
swarit-stepsecurity:swarit/chore/wt/optimize-npm-transport
Open

chore(node-scan): optimize scan times #81
swarit-stepsecurity wants to merge 2 commits into
step-security:mainfrom
swarit-stepsecurity:swarit/chore/wt/optimize-npm-transport

Conversation

@swarit-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

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

1 participant