-
Notifications
You must be signed in to change notification settings - Fork 0
kyber #408
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
kyber #408
Changes from all commits
c2366cc
14d4e3a
1f1a6c0
6a7d973
7a2b982
1f505b0
0343b17
476871f
afd3a68
ec66ff5
4363561
75688a1
8146010
6dae014
3516598
a0048b0
3b6032c
26a79e7
030c48d
221c2de
96d36ec
d19f041
3e56c76
8e1bbe2
19fd5e6
d2132c3
5b89d01
e4851ed
70814c9
1b42be5
6c3bf11
0ef2d9a
6df2499
e33cb88
12b07a7
4b82fb0
0baa002
6365552
fc5dcae
e949d4e
c5a1a12
5ec2977
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,3 +2,4 @@ | |||||||
| # Copy to home-manager/.env and provide real values. The .env file stays local. | ||||||||
| MY_SECRET=replace-me | ||||||||
| # GITHUB_TOKEN=ghp_your_token_here | ||||||||
| CLIPROXY_MANAGEMENT_PASSWORD=your-management-key-here | ||||||||
|
||||||||
| CLIPROXY_MANAGEMENT_PASSWORD=your-management-key-here | |
| # This should be a strong, randomly generated password for the CLIProxyAPI Management API | |
| CLIPROXY_MANAGEMENT_PASSWORD=a-secure-random-password |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,48 @@ | ||||||
| name: Shell | ||||||
| on: | ||||||
| push: | ||||||
| branches: | ||||||
| - main | ||||||
| pull_request: | ||||||
| branches: | ||||||
| - main | ||||||
| concurrency: | ||||||
| group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.sha }} | ||||||
| cancel-in-progress: true | ||||||
| jobs: | ||||||
| shellspec: | ||||||
| runs-on: ubuntu-latest | ||||||
| timeout-minutes: 30 | ||||||
| steps: | ||||||
| - name: Checkout | ||||||
| uses: actions/checkout@v6 | ||||||
| - name: Install Nix | ||||||
| uses: cachix/install-nix-action@v31 | ||||||
| with: | ||||||
| github_access_token: ${{ secrets.GITHUB_TOKEN }} | ||||||
| - name: Run ShellSpec Tests (Dev Shell) | ||||||
| run: make shell-test-dev | ||||||
| shellcheck: | ||||||
| runs-on: ubuntu-latest | ||||||
| timeout-minutes: 10 | ||||||
| steps: | ||||||
| - name: Checkout | ||||||
| uses: actions/checkout@v6 | ||||||
| - name: Install Nix | ||||||
| uses: cachix/install-nix-action@v31 | ||||||
| with: | ||||||
| github_access_token: ${{ secrets.GITHUB_TOKEN }} | ||||||
| - name: Run ShellCheck (Dev Shell) | ||||||
| run: make shell-check-dev | ||||||
| shell-check: | ||||||
|
||||||
| shell-check: | |
| shell-tests-status: |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| --require spec_helper | ||
| --format progress | ||
| --shell bash |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -135,10 +135,10 @@ setup: nix-setup ## Basic Nix setup (alias for nix-setup). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setup-dev: nix-setup git-submodule-sync shell-install ## Set up local development environment (Nix + submodules + shell). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .PHONY: switch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| switch: nix-switch ## Apply Nix configuration and restart launchd agents. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| switch: nix-switch launchctl ## Apply Nix configuration and restart launchd agents. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
137
to
+138
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 Useful? React with 👍 / 👎. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .PHONY: test | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| test: neovim-test | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| test: neovim-test shell-test ## Run all tests (neovim + shell). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
137
to
142
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.
This is especially problematic because -.PHONY: switch
-switch: nix-switch launchctl ## Apply Nix configuration and restart launchd agents.
+.PHONY: switch
+switch: nix-switch ## Apply Nix configuration and restart launchd agents (macOS only).
+ifeq ($(OS),Darwin)
+ @$(MAKE) launchctl
+else
+ @echo "ℹ️ launchctl skipped on $(OS)"
+endif
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .PHONY: update | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| update: nix-update shell-update neovim-update ## Update Nix flake and configurations. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -202,8 +202,8 @@ devenv-cli: ## Build the packaged devenv CLI binary. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .PHONY: nix-install | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nix-install: ## Install Nix if not already installed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @if [ "$(NIX_ENV)" = "not_found" ]; then \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "🚀 Installing Nix environment for $(NIX_CONFIG_TYPE) on $(OS) $(ARCH) for USER=$(NIX_USERNAME)"; \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| curl -L https://nixos.org/nix/install | sh; \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "🚀 Installing Determinate Nix environment for $(NIX_CONFIG_TYPE) on $(OS) $(ARCH) for USER=$(NIX_USERNAME)"; \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install; \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+205
to
207
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. 🧩 Analysis chain🌐 Web query:
💡 Result: Recommended one‑liner (from Determinate official docs): curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --determinate Sources: Determinate manual and installer repo. [1][2] References 🌐 Web query:
💡 Result: Short answer
What that means for security
Practical verification / hardening steps
If you need absolute integrity guarantees
Sources
If you want, I can: (a) check a specific release page for release artifacts/checksums/signatures, (b) show the exact curl+verify commands to pin and verify SHA256, or (c) walk you through verifying a downloaded installer on your machine. Which would you like? Add The Determinate official documentation recommends: Note: The 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @echo "✅ Nix environment installed!" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -624,3 +624,25 @@ git-submodule-sync: ## Sync and update git submodules. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @git submodule sync | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @git submodule update --init --recursive | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @echo "✅ Submodules synced and updated" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ##@ Shell | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .PHONY: shell-test | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shell-test: ## Run shell script tests using ShellSpec. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @echo "🧪 Running shell tests..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @bash -c "shellspec" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .PHONY: shell-test-dev | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shell-test-dev: ## Run shell tests inside the Nix dev shell (mirrors CI). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @echo "🧪 Running shell tests inside the Nix dev shell..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @DEVENV_ROOT=$(CURDIR) $(NIX_ALLOW_UNFREE) $(NIX_EXEC) develop $(NIX_FLAGS) .# --command $(MAKE) shell-test | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .PHONY: shell-check | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shell-check: ## Run ShellCheck on shell scripts. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @echo "🔍 Running ShellCheck..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @find . -name '*.sh' -not -path './node_modules/*' -not -path './.git/*' -not -path './result/*' | xargs shellcheck | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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. Using |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .PHONY: shell-check-dev | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shell-check-dev: ## Run ShellCheck inside the Nix dev shell (mirrors CI). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @echo "🔍 Running ShellCheck inside the Nix dev shell..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @DEVENV_ROOT=$(CURDIR) $(NIX_ALLOW_UNFREE) $(NIX_EXEC) develop $(NIX_FLAGS) .# --command $(MAKE) shell-check | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+630
to
+648
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. Make
shell-check: ## Run ShellCheck on shell scripts.
@echo "🔍 Running ShellCheck..."
- @find . -name '*.sh' -not -path './node_modules/*' -not -path './.git/*' -not -path './result/*' | xargs shellcheck
+ @find . -name '*.sh' \
+ -not -path './node_modules/*' -not -path './.git/*' -not -path './result/*' \
+ -exec shellcheck {} +Based on learnings, follow ShellCheck recommendations. 📝 Committable suggestion
Suggested change
🧰 Tools🪛 checkmake (0.2.2)[warning] 645-645: Missing required phony target "all" (minphony) [warning] 645-645: Missing required phony target "clean" (minphony) 🤖 Prompt for AI Agents
Comment on lines
+645
to
+648
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. checkmake warns missing If you want to satisfy checkmake’s +.PHONY: all
+all: help ## Default “all” target.
+
+.PHONY: clean
+clean: ## No-op clean (dotfiles repo).
+ @true
🧰 Tools🪛 checkmake (0.2.2)[warning] 645-645: Missing required phony target "all" (minphony) [warning] 645-645: Missing required phony target "clean" (minphony) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,73 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Claude Code Security Hook | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Blocks dangerous Bash commands by checking against deny patterns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Based on: https://wasabeef.jp/blog/claude-code-secure-bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # This script runs as a PreToolUse hook and returns: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # - Exit code 0: Command is allowed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # - Exit code 2: Command is blocked | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Read JSON input from stdin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| input=$(cat) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Extract tool name - only process Bash commands | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tool_name=$(echo "$input" | jq -r '.tool.name // empty' 2>/dev/null) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [[ $tool_name != "Bash" ]] && exit 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Extract the command to be executed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| command=$(echo "$input" | jq -r '.tool.input.command // empty' 2>/dev/null) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [[ -z $command ]] && exit 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Path to settings file with deny patterns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| settings="$HOME/.claude/settings.json" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [[ ! -f $settings ]] && exit 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Read deny patterns from settings | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mapfile -t deny_patterns < <(jq -r '.permissions.deny[]?' "$settings" 2>/dev/null) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mapfile -t deny_patterns < <(jq -r '.permissions.deny[]?' "$settings" 2>/dev/null) | |
| deny_patterns_jq_output=$(jq -r '.permissions.deny[]?' "$settings" 2>/dev/null) | |
| jq_status=$? | |
| if [[ $jq_status -ne 0 ]]; then | |
| echo "BLOCKED by security.sh: Failed to parse settings file '$settings' (jq error)" >&2 | |
| exit 2 | |
| fi | |
| mapfile -t deny_patterns <<< "$deny_patterns_jq_output" |
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.
Fail-open safely when jq is missing or JSON is invalid (today it may fail-closed under set -euo pipefail).
With set -euo pipefail, any jq error in tool_name=$(echo ... | jq ...) / command=... / mapfile ... < <(jq ...) can exit the hook non-zero and unintentionally block all Bash tool usage.
set -euo pipefail
+# If jq isn't available (or JSON is malformed), don't block tool execution.
+command -v jq >/dev/null 2>&1 || exit 0
+
# Read JSON input from stdin
input=$(cat)
# Extract tool name - only process Bash commands
-tool_name=$(echo "$input" | jq -r '.tool.name // empty' 2>/dev/null)
+tool_name=$(echo "$input" | jq -r '.tool.name // empty' 2>/dev/null || true)
[[ "$tool_name" != "Bash" ]] && exit 0
# Extract the command to be executed
-command=$(echo "$input" | jq -r '.tool.input.command // empty' 2>/dev/null)
+command=$(echo "$input" | jq -r '.tool.input.command // empty' 2>/dev/null || true)
[[ -z "$command" ]] && exit 0
@@
# Read deny patterns from settings
-mapfile -t deny_patterns < <(jq -r '.permissions.deny[]?' "$settings" 2>/dev/null)
+mapfile -t deny_patterns < <(jq -r '.permissions.deny[]?' "$settings" 2>/dev/null || true)As per coding guidelines (shellcheck resiliency for **/*.{sh,bash}), this also prevents “tool broke because jq glitched” failures. Based on learnings, follow ShellCheck recommendations.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| set -euo pipefail | |
| # Read JSON input from stdin | |
| input=$(cat) | |
| # Extract tool name - only process Bash commands | |
| tool_name=$(echo "$input" | jq -r '.tool.name // empty' 2>/dev/null) | |
| [[ "$tool_name" != "Bash" ]] && exit 0 | |
| # Extract the command to be executed | |
| command=$(echo "$input" | jq -r '.tool.input.command // empty' 2>/dev/null) | |
| [[ -z "$command" ]] && exit 0 | |
| # Path to settings file with deny patterns | |
| settings="$HOME/.claude/settings.json" | |
| [[ ! -f "$settings" ]] && exit 0 | |
| # Read deny patterns from settings | |
| mapfile -t deny_patterns < <(jq -r '.permissions.deny[]?' "$settings" 2>/dev/null) | |
| set -euo pipefail | |
| # If jq isn't available (or JSON is malformed), don't block tool execution. | |
| command -v jq >/dev/null 2>&1 || exit 0 | |
| # Read JSON input from stdin | |
| input=$(cat) | |
| # Extract tool name - only process Bash commands | |
| tool_name=$(echo "$input" | jq -r '.tool.name // empty' 2>/dev/null || true) | |
| [[ "$tool_name" != "Bash" ]] && exit 0 | |
| # Extract the command to be executed | |
| command=$(echo "$input" | jq -r '.tool.input.command // empty' 2>/dev/null || true) | |
| [[ -z "$command" ]] && exit 0 | |
| # Path to settings file with deny patterns | |
| settings="$HOME/.claude/settings.json" | |
| [[ ! -f "$settings" ]] && exit 0 | |
| # Read deny patterns from settings | |
| mapfile -t deny_patterns < <(jq -r '.permissions.deny[]?' "$settings" 2>/dev/null || true) | |
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.
Restore extglob even on a successful match (currently it can stay enabled until process exit).
Right now, return 0 happens before shopt -u extglob. Easy to make deterministic:
matches_pattern() {
local cmd="$1"
local pattern="$2"
@@
# Use bash glob matching (extended globbing)
- shopt -s extglob
- # shellcheck disable=SC2053
- if [[ "$cmd" == $check_pattern ]]; then
- return 0
- fi
- shopt -u extglob
+ local extglob_was_set=0 matched=1
+ shopt -q extglob && extglob_was_set=1
+ shopt -s extglob
+ # shellcheck disable=SC2053
+ [[ "$cmd" == $check_pattern ]] && matched=0
+ (( extglob_was_set == 1 )) || shopt -u extglob
+ return "$matched"
fi
return 1
}🤖 Prompt for AI Agents
In config/claude/security.sh around lines 33 to 52, extglob is enabled with
shopt -s but on a successful match the function returns before shopt -u is
called, leaving extglob enabled for the rest of the shell; fix by saving the
prior extglob state before enabling and restoring it before any return (or use a
subshell), e.g., capture the output of shopt -q extglob to a variable, enable
extglob, perform the match, then restore extglob to its original state (call
shopt -s extglob if it was on, or shopt -u extglob if it was off) before
returning.
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.
P1: Security bypass: Command substitution ($(...) and backticks) is not handled. A malicious command like echo $(rm -rf /) bypasses detection since the entire string is treated as one segment starting with echo, not rm. Consider parsing nested commands or documenting this limitation.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At config/claude/security.sh, line 57:
<comment>Security bypass: Command substitution (`$(...)` and backticks) is not handled. A malicious command like `echo $(rm -rf /)` bypasses detection since the entire string is treated as one segment starting with `echo`, not `rm`. Consider parsing nested commands or documenting this limitation.</comment>
<file context>
@@ -0,0 +1,73 @@
+# Split command at logical operators to catch hidden dangerous commands
+# This handles: cmd1 ; cmd2, cmd1 && cmd2, cmd1 || cmd2, cmd1 | cmd2
+# shellcheck disable=SC2001
+IFS=$'\n' read -r -d '' -a segments < <(echo "$command" | sed 's/[;&|]\+/\n/g' && printf '\0') || true
+
+for segment in "${segments[@]}"; do
</file context>
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.
Using echo ... | xargs to trim whitespace is a classic trick, but it's not very efficient as it involves a subshell and an external command. A more modern and efficient Bash-native approach is to use read with a here-string, which avoids creating a subshell.
| segment=$(echo "$segment" | xargs 2>/dev/null) || continue | |
| read -r segment <<< "$segment" |
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.
P2: xargs for trimming whitespace can interpret quotes and backslashes, potentially transforming the command before the security check. Consider using sed 's/^[[:space:]]*//;s/[[:space:]]*$//' or bash parameter expansion instead.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At config/claude/security.sh, line 61:
<comment>`xargs` for trimming whitespace can interpret quotes and backslashes, potentially transforming the command before the security check. Consider using `sed 's/^[[:space:]]*//;s/[[:space:]]*$//'` or bash parameter expansion instead.</comment>
<file context>
@@ -0,0 +1,73 @@
+
+for segment in "${segments[@]}"; do
+ # Trim leading/trailing whitespace
+ segment=$(echo "$segment" | xargs 2>/dev/null) || continue
+ [[ -z "$segment" ]] && continue
+
</file context>
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.
Avoid xargs for trimming: it normalizes whitespace and can change what you’re matching.
For a security hook, don’t mutate the command string more than necessary—use a trim that preserves internal spacing:
for segment in "${segments[@]}"; do
# Trim leading/trailing whitespace
- segment=$(echo "$segment" | xargs 2>/dev/null) || continue
+ segment=$(printf '%s' "$segment" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') || continue
[[ -z "$segment" ]] && continueBased on learnings, follow ShellCheck recommendations.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # Split command at logical operators to catch hidden dangerous commands | |
| # This handles: cmd1 ; cmd2, cmd1 && cmd2, cmd1 || cmd2, cmd1 | cmd2 | |
| # shellcheck disable=SC2001 | |
| IFS=$'\n' read -r -d '' -a segments < <(echo "$command" | sed 's/[;&|]\+/\n/g' && printf '\0') || true | |
| for segment in "${segments[@]}"; do | |
| # Trim leading/trailing whitespace | |
| segment=$(echo "$segment" | xargs 2>/dev/null) || continue | |
| [[ -z "$segment" ]] && continue | |
| # Split command at logical operators to catch hidden dangerous commands | |
| # This handles: cmd1 ; cmd2, cmd1 && cmd2, cmd1 || cmd2, cmd1 | cmd2 | |
| # shellcheck disable=SC2001 | |
| IFS=$'\n' read -r -d '' -a segments < <(echo "$command" | sed 's/[;&|]\+/\n/g' && printf '\0') || true | |
| for segment in "${segments[@]}"; do | |
| # Trim leading/trailing whitespace | |
| segment=$(printf '%s' "$segment" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') || continue | |
| [[ -z "$segment" ]] && continue | |
🤖 Prompt for AI Agents
In config/claude/security.sh around lines 54 to 63, the trimming uses "xargs"
which normalizes internal whitespace and can change the command being inspected;
replace the xargs-based trim with a safe leading/trailing-only trim that
preserves internal spacing (use POSIX shell parameter expansion to remove
leading and trailing whitespace, or use sed with explicit ^[[:space:]]* and
[[:space:]]*$ patterns), ensure you do not spawn unnecessary subshells or
collapse internal spaces, and keep the check that skips empty segments.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,4 +1,5 @@ | ||||||
| { | ||||||
| "cleanupPeriodDays": 99999, | ||||||
|
||||||
| "cleanupPeriodDays": 99999, | |
| "cleanupPeriodDays": 180, |
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.
Revisit cleanupPeriodDays: 99999 retention choice
That’s effectively “keep almost forever”; if the goal is privacy or disk hygiene, consider a more bounded value (or document why extremely long retention is desired).
🤖 Prompt for AI Agents
In config/claude/settings.json around lines 1 to 3, the cleanupPeriodDays is set
to an effectively permanent value (99999); change this to a sensible bounded
retention (e.g., 30, 90, or 365 days) or replace the literal with a named
constant/env var and add a short comment or documentation explaining why a long
retention is required if you must keep it long-term; update tests/config docs
accordingly.
Copilot
AI
Dec 12, 2025
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 read deny pattern includes '**/docker-compose*.yml' which could prevent legitimate reads of docker-compose files for debugging or development purposes. While protecting sensitive configuration is important, docker-compose files often don't contain secrets directly (they reference env files instead). Consider whether this pattern is too restrictive, or document that docker-compose files should be read-only through other means.
| "**/docker-compose*.yml", |
Copilot
AI
Dec 12, 2025
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.
Setting "defaultMode" to "bypassPermissions" means Claude Code will bypass permission checks by default. This effectively disables the security restrictions defined in the permissions section (allow/deny lists, read/write deny patterns) unless explicitly changed. Consider whether this is the intended security posture, as it reduces the protection provided by the carefully configured permissions.
| "defaultMode": "bypassPermissions" | |
| "defaultMode": "enforcePermissions" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,11 +4,11 @@ port: 8317 | |
| remote-management: | ||
| # Whether to allow remote (non-localhost) management access. | ||
| # When false, only localhost can access management endpoints (a key is still required). | ||
| allow-remote: true | ||
| allow-remote: false | ||
| # Management key. If a plaintext value is provided here, it will be hashed on startup. | ||
| # All management requests (even from localhost) require this key. | ||
| # Leave empty to disable the Management API entirely (404 for all /v0/management routes). | ||
| secret-key: "" | ||
| secret-key: "__CLIPROXY_MANAGEMENT_PASSWORD__" | ||
|
||
| # Disable the bundled management control panel asset download and HTTP route when true. | ||
| disable-control-panel: false | ||
|
Comment on lines
4
to
13
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. ❓ Verification inconclusive🏁 Script executed: # First, let's find the start.sh file mentioned in the comment
find . -name "start.sh" -type fRepository: shunkakinoki/dotfiles Length of output: 186 🏁 Script executed: # Search for Management API implementation and secret-key handling
rg -i "secret.?key|management.*password" --type yaml --type py --type js --type ts -A 3 -B 1Repository: shunkakinoki/dotfiles Length of output: 186 🏁 Script executed: # Check the YAML file itself for formatting compliance
cat -n config/cliproxyapi/config.yaml | head -20Repository: shunkakinoki/dotfiles Length of output: 186 🏁 Script executed: # Search for how MANAGEMENT_PASSWORD env var is used
rg "MANAGEMENT_PASSWORD|CLIPROXY_MANAGEMENT_PASSWORD" -A 3 -B 1Repository: shunkakinoki/dotfiles Length of output: 186 Prevent deploying a config with the literal placeholder as the management key. If template substitution fails, Verification needed: Confirm whether 🤖 Prompt for AI Agents |
||
| # Authentication directory (supports ~ for home directory). If you use Windows, please set the directory like this: `C:/cli-proxy-api/` | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -61,6 +61,8 @@ with pkgs; | |
| ripgrep | ||
| rustup | ||
| sccache | ||
| shellcheck | ||
| shellspec | ||
| speedtest-cli | ||
| sqlite | ||
| stern | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,3 @@ | ||
| function _kyber_function --description "SSH to Kyber server" | ||
| set -l password (security find-generic-password -s "ssh ubuntu@91.242.214.231" -w 2>/dev/null) | ||
| if test -n "$password" | ||
| sshpass -p $password ssh ubuntu@$KYBER_IP_ADDR | ||
| else | ||
| echo "Password not found in Keychain. Run: security add-generic-password -s 'ssh ubuntu@91.242.214.231' -a ubuntu -w" | ||
| ssh ubuntu@$KYBER_IP_ADDR | ||
| end | ||
| function _kyber_function --description "SSH to Kyber server via Tailscale" | ||
| tailscale ssh ubuntu@kyber | ||
| end |
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.
Optional: reorder keys if dotenv-linter is enforced in CI.
If
dotenv-linterwarnings fail the pipeline, moveCLIPROXY_MANAGEMENT_PASSWORDaboveMY_SECRET; otherwise this is fine.🧰 Tools
🪛 dotenv-linter (4.0.0)
[warning] 5-5: [UnorderedKey] The CLIPROXY_MANAGEMENT_PASSWORD key should go before the MY_SECRET key
(UnorderedKey)
🤖 Prompt for AI Agents