-
Notifications
You must be signed in to change notification settings - Fork 0
Revamp #280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revamp #280
Changes from all commits
54697bb
e9181ca
c29ad38
f22dd9b
db091a0
cb76b6c
118694b
dadb501
0b427b9
fd04c92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ | |
| "hooks": [ | ||
| { | ||
| "type": "command", | ||
| "command": "cat | jq -r '\"display notification \\\"\" + .message + \"\\\" with title \\\"\" + .title + \"\\\" sound name \\\"Sonar\\\"\"' | xargs -I {} osascript -e '{}'" | ||
| "command": "jq -r '.message' | xargs -I {} osascript -e 'display notification \"{}\" with title \"Claude Code\" sound name \"Sonar\"'" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shell injection vulnerability in notification command. The current command directly interpolates the message content into the osascript command string without proper escaping. Messages containing double quotes, backticks, dollar signs, or other shell metacharacters will break the command or potentially execute arbitrary code. Example problematic inputs:
Apply this diff to fix the injection vulnerability using a safer approach: - "command": "jq -r '.message' | xargs -I {} osascript -e 'display notification \"{}\" with title \"Claude Code\" sound name \"Sonar\"'"
+ "command": "jq -r '.message' | xargs -0 -I {} osascript -e 'on run argv' -e 'display notification (item 1 of argv) with title \"Claude Code\" sound name \"Sonar\"' -e 'end run' -- {}"Alternatively, use a more robust solution that avoids shell interpolation entirely: - "command": "jq -r '.message' | xargs -I {} osascript -e 'display notification \"{}\" with title \"Claude Code\" sound name \"Sonar\"'"
+ "command": "MESSAGE=$(jq -r '.message') && osascript - <<EOF\ndisplay notification \"$MESSAGE\" with title \"Claude Code\" sound name \"Sonar\"\nEOF"Note: The same vulnerability pattern appears in line 20 for the Stop hook, though it uses jq to construct the message. Consider applying similar fixes there if the constructed message could contain untrusted input.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interpolating the message directly into the AppleScript source can break quoting and enable AppleScript injection. Pass the message as an argument to osascript (via argv) instead of embedding it in the -e string. Prompt for AI agents |
||
| } | ||
|
Comment on lines
8
to
10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new notification hook now runs Useful? React with 👍 / 👎. |
||
| ] | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -15,6 +15,16 @@ | |||||||||||||||||||||||||||||||||||||
| if [ -f "$PACKAGE_JSON" ]; then | ||||||||||||||||||||||||||||||||||||||
| echo "Installing npm global packages from package.json using bun..." | ||||||||||||||||||||||||||||||||||||||
| cd "${config.home.homeDirectory}/dotfiles" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # Trust postinstall scripts for packages listed in trustedDependencies before installing | ||||||||||||||||||||||||||||||||||||||
| TRUSTED_DEPS=$(${pkgs.jq}/bin/jq -r '.trustedDependencies[]?' "$PACKAGE_JSON" 2>/dev/null) | ||||||||||||||||||||||||||||||||||||||
| if [ -n "$TRUSTED_DEPS" ]; then | ||||||||||||||||||||||||||||||||||||||
| echo "Trusting postinstall scripts for: $TRUSTED_DEPS" | ||||||||||||||||||||||||||||||||||||||
| echo "$TRUSTED_DEPS" | while read -r dep; do | ||||||||||||||||||||||||||||||||||||||
| ${pkgs.bun}/bin/bun pm -g trust "$dep" 2>/dev/null || true | ||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+19
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider improving error visibility for the trust operation. The trust mechanism silently suppresses all errors (
While silent failure prevents the activation script from breaking, it provides no feedback when something goes wrong. Consider this refactor to log failures while still allowing the script to continue: # Trust postinstall scripts for packages listed in trustedDependencies before installing
TRUSTED_DEPS=$(${pkgs.jq}/bin/jq -r '.trustedDependencies[]?' "$PACKAGE_JSON" 2>/dev/null)
if [ -n "$TRUSTED_DEPS" ]; then
echo "Trusting postinstall scripts for: $TRUSTED_DEPS"
echo "$TRUSTED_DEPS" | while read -r dep; do
- ${pkgs.bun}/bin/bun pm -g trust "$dep" 2>/dev/null || true
+ if ! ${pkgs.bun}/bin/bun pm -g trust "$dep" 2>&1; then
+ echo "Warning: Failed to trust $dep" >&2
+ fi
done
fi📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ${pkgs.bun}/bin/bun install --global \ | ||||||||||||||||||||||||||||||||||||||
| $(${pkgs.jq}/bin/jq -r '.dependencies | keys[]' "$PACKAGE_JSON") 2>/dev/null || true | ||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,7 @@ | |
| "block-goose" | ||
| "chatgpt" | ||
| "claude" | ||
| "claude-code" | ||
| "conductor" | ||
| "copilot-money" | ||
| "cursor" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The updated command hardcodes the notification title to "Claude Code", which removes the dynamic title previously generated from the
.titlefield. While this aligns with theStophook's behavior, it could be an unintended loss of functionality for this specific notification. If retaining the dynamic title is preferred, the command can be improved for readability while keeping the feature. The suggestion below usesjq's string interpolation, which is cleaner than the original string concatenation, and it also removes the unnecessarycatcommand.