Skip to content

fix(security-guidance): use a cross-platform Python launcher - #47502

Open
Rohan5commit wants to merge 1 commit into
anthropics:mainfrom
Rohan5commit:fix/security-guidance-python-launcher
Open

fix(security-guidance): use a cross-platform Python launcher#47502
Rohan5commit wants to merge 1 commit into
anthropics:mainfrom
Rohan5commit:fix/security-guidance-python-launcher

Conversation

@Rohan5commit

Copy link
Copy Markdown

Summary

  • use a small Node launcher so the security-guidance hook can find Python on Windows and Unix-like systems
  • preserve stdin/stdout passthrough for the existing Python reminder hook
  • add focused tests for launcher selection and fallback behavior

Testing

  • node --test plugins/security-guidance/hooks/run_python_hook.test.js

Closes #46449

Copilot AI review requested due to automatic review settings April 13, 2026 16:24

Copilot AI left a comment

Copy link
Copy Markdown

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 fixes the security-guidance plugin’s Python hook invocation so it works on Windows (where python3 may not exist) by introducing a small Node-based launcher that tries multiple Python entrypoints and preserves hook I/O behavior.

Changes:

  • Add a Node launcher (run_python_hook.js) that attempts platform-appropriate Python commands and falls back when commands are missing.
  • Update hooks.json to invoke the Node launcher instead of calling python3 directly.
  • Add Node tests covering launcher selection and ENOENT fallback behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
plugins/security-guidance/hooks/run_python_hook.js New Node launcher that selects/falls back between Python launchers and proxies stdin/stdout/stderr.
plugins/security-guidance/hooks/run_python_hook.test.js Tests for launcher ordering and fallback behavior when the first launcher is missing.
plugins/security-guidance/hooks/hooks.json Switch hook command to use the Node launcher with the existing Python hook script.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

process.stderr.write(result.stderr);
}

return result.status ?? (result.error ? 1 : 0);

Copilot AI Apr 13, 2026

Copy link

Choose a reason for hiding this comment

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

spawnSync returns status: null when the child is terminated by a signal (with signal set). The current return expression treats that case as success (0) when result.error is falsy, which can silently mask real failures. Consider returning a non-zero exit code when status is null due to result.signal (or generally defaulting null status to 1 unless the error is ENOENT and you intend to fall through).

Suggested change
return result.status ?? (result.error ? 1 : 0);
return result.status ?? 1;

Copilot uses AI. Check for mistakes.
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.

[BUG] security-guidance plugin's hook uses python3 in the command, which doesn't exist on Windows

3 participants