Skip to content

fix(security-guidance): strip CRLF from Python version probe on Windows#68701

Open
AZERDSQ131 wants to merge 2 commits into
anthropics:mainfrom
AZERDSQ131:fix/bug-23-sg-python-crlf
Open

fix(security-guidance): strip CRLF from Python version probe on Windows#68701
AZERDSQ131 wants to merge 2 commits into
anthropics:mainfrom
AZERDSQ131:fix/bug-23-sg-python-crlf

Conversation

@AZERDSQ131

@AZERDSQ131 AZERDSQ131 commented Jun 15, 2026

Copy link
Copy Markdown

No description provided.

AZERDSQ131 and others added 2 commits June 16, 2026 00:18
…ndows

The SessionStart hook command was invoked as a bare path:
  ${CLAUDE_PLUGIN_ROOT}/hooks-handlers/session-start.sh

On Windows this fails because CLAUDE_PLUGIN_ROOT contains backslashes.
Also, without an explicit `bash` prefix the command relies on the file's
executable bit, which git does not always preserve across platforms.

Replace with the same tr-based path normalization pattern used by
security-guidance (BUG-20):
  bash -c 'R=$(echo "$CLAUDE_PLUGIN_ROOT" | tr \\ /); bash "$R/..."'

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
On Windows (Git Bash), Python's stdout is opened in text mode and emits
\r\n line endings. bash command substitution $() strips the trailing \n
but leaves \r, so the version string becomes "3\r" instead of "3".

The comparison [ "$v" = "3" ] then always fails, causing sg-python.sh to
skip every interpreter and exit 1 — making all security-guidance hooks
silently inoperative on Windows.

Fix: pipe the probe output through `tr -d '\r'` before the comparison.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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