Skip to content

Commit 0c61db2

Browse files
mojwangclaude
andcommitted
fix: address critical security issues from CI review
- Set secure permissions (600) on API keys file - Remove API key from URL in Exa MCP config (use env vars instead) - Fix race condition in debug script using mktemp - Replace hardcoded user paths with dynamic $HOME Security fixes per CI recommendations: - API key file now has owner-only read/write permissions - API keys passed via environment variables, not URLs - Temporary files use mktemp for safe creation - All paths now use $HOME for portability 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 163bb57 commit 0c61db2

4 files changed

Lines changed: 25 additions & 17 deletions

File tree

lib/common.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -475,17 +475,17 @@ export -f kill_all_test_jobs
475475
# MCP server configurations - base paths
476476
declare -A MCP_SERVER_BASE_PATHS=(
477477
# Official servers
478-
["filesystem"]="/Users/mojwang/repos/mcp-servers/official/filesystem"
479-
["memory"]="/Users/mojwang/repos/mcp-servers/official/memory"
480-
["sequentialthinking"]="/Users/mojwang/repos/mcp-servers/official/sequentialthinking"
481-
["git"]="/Users/mojwang/repos/mcp-servers/official/git"
482-
["fetch"]="/Users/mojwang/repos/mcp-servers/official/fetch"
478+
["filesystem"]="$HOME/repos/mcp-servers/official/filesystem"
479+
["memory"]="$HOME/repos/mcp-servers/official/memory"
480+
["sequentialthinking"]="$HOME/repos/mcp-servers/official/sequentialthinking"
481+
["git"]="$HOME/repos/mcp-servers/official/git"
482+
["fetch"]="$HOME/repos/mcp-servers/official/fetch"
483483
# Community servers
484-
["context7"]="/Users/mojwang/repos/mcp-servers/community/context7"
485-
["playwright"]="/Users/mojwang/repos/mcp-servers/community/playwright"
486-
["figma"]="/Users/mojwang/repos/mcp-servers/community/figma"
487-
["exa"]="/Users/mojwang/repos/mcp-servers/community/exa"
488-
["semgrep"]="/Users/mojwang/repos/mcp-servers/community/semgrep"
484+
["context7"]="$HOME/repos/mcp-servers/community/context7"
485+
["playwright"]="$HOME/repos/mcp-servers/community/playwright"
486+
["figma"]="$HOME/repos/mcp-servers/community/figma"
487+
["exa"]="$HOME/repos/mcp-servers/community/exa"
488+
["semgrep"]="$HOME/repos/mcp-servers/community/semgrep"
489489
)
490490

491491
# MCP server executable patterns - used to find the actual executable
@@ -598,7 +598,7 @@ generate_mcp_server_config() {
598598
"command": "node",
599599
"args": [
600600
"$server_path",
601-
"/Users/mojwang"
601+
"$HOME"
602602
]
603603
}
604604
EOF

scripts/debug-mcp-servers.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,17 @@ test_server() {
3131
TIMEOUT_CMD="timeout 5s"
3232
else
3333
# Fallback: run in background and kill after 5 seconds
34-
("$command" "${args[@]}" 2>&1 | grep -q "Content-Type: application/vnd.mcp" && echo "OK" > /tmp/mcp_test_$$.tmp) &
34+
local tmp_file=$(mktemp /tmp/mcp_test_XXXXXX.tmp)
35+
("$command" "${args[@]}" 2>&1 | grep -q "Content-Type: application/vnd.mcp" && echo "OK" > "$tmp_file") &
3536
local pid=$!
3637
sleep 5
3738
kill -0 $pid 2>/dev/null && kill -9 $pid 2>/dev/null
38-
if [ -f /tmp/mcp_test_$$.tmp ]; then
39-
rm -f /tmp/mcp_test_$$.tmp
39+
if [ -f "$tmp_file" ] && [ -s "$tmp_file" ]; then
40+
rm -f "$tmp_file"
4041
echo "✓ Working"
4142
return 0
4243
else
44+
rm -f "$tmp_file"
4345
echo "✗ Failed"
4446
return 1
4547
fi

scripts/setup-dotfiles.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ if [[ -d "dotfiles/.config/zsh" ]]; then
7272
mkdir -p ~/.config/zsh
7373

7474
if cp -r dotfiles/.config/zsh/* ~/.config/zsh/ 2>/dev/null; then
75+
# Set secure permissions on API keys file
76+
if [[ -f ~/.config/zsh/51-api-keys.zsh ]]; then
77+
chmod 600 ~/.config/zsh/51-api-keys.zsh
78+
fi
7579
print_success "Zsh modular configuration installed"
7680
else
7781
print_warning "Failed to install Zsh modular configuration"

scripts/update-exa-mcp.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ settings['mcpServers']['exa'] = {
5252
"command": "npx",
5353
"args": [
5454
"-y",
55-
"mcp-remote",
56-
f"https://mcp.exa.ai/mcp?exaApiKey={api_key}"
57-
]
55+
"@modelcontextprotocol/server-exa"
56+
],
57+
"env": {
58+
"EXA_API_KEY": api_key
59+
}
5860
}
5961
6062
# Write updated settings

0 commit comments

Comments
 (0)