[BUG] semgrep plugin PostToolUse hook constructs wrong path when editing files outside CWD
Open 💬 0 comments Opened Jun 19, 2026 by alexander-leitch
Bug description
The semgrep@claude-plugins-official plugin's PostToolUse hook (hook-darwin-arm64 binary) incorrectly constructs the file path to scan when an edited file lives outside the current working directory.
Steps to reproduce
- Open a Claude Code session in project directory A (e.g.
~/Code/project-a) - Edit a file in a different directory B (e.g.
~/Code/project-b/script.py) using the Edit tool - The semgrep PostToolUse hook fires and returns an error
Observed behaviour
The hook returns additionalContext with an error like:
open /Users/alice/Code/project-a/Users/alice/Code/project-b/script.py: no such file or directory
The path is constructed as $CWD + absolute_path_without_leading_slash, doubling the directory tree.
Expected behaviour
When tool_input.file_path is already an absolute path, it should be used directly — not prepended with $CWD.
Environment
- Plugin:
semgrep@claude-plugins-officialv2.0.1 - Binary:
hook-darwin-arm64 - Platform: macOS (darwin arm64)
- Claude Code version: current
Confirmed via
Running the binary directly with a cross-directory Edit payload reproduces the bad path:
echo '{"tool_name":"Edit","tool_input":{"file_path":"/Users/alice/Code/project-b/script.py"},"tool_response":{"filePath":"/Users/alice/Code/project-b/script.py"}}' \
| ~/.claude/plugins/cache/claude-plugins-official/semgrep/2.0.1/scripts/hook-darwin-arm64 claude PostToolUse
# → {"hookSpecificOutput":{"additionalContext":"open /Users/alice/Code/project-a/Users/alice/Code/project-b/script.py: no such file or directory",...}}
Workaround
Add to the project's .claude/settings.local.json:
{
"enabledPlugins": {
"semgrep@claude-plugins-official": false
}
}