Skip to content

Commit 9d6b0e5

Browse files
committed
chore: sync hooks and skills from socket-repo-template
1 parent 318b392 commit 9d6b0e5

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

.claude/skills/security-scan/SKILL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
name: security-scan
33
description: Runs a multi-tool security scan — AgentShield for Claude config, zizmor for GitHub Actions, and optionally Socket CLI for dependency scanning. Produces an A-F graded security report.
4+
user-invocable: true
45
---
56

67
# Security Scan

.git-hooks/commit-msg

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@ ALLOWED_PUBLIC_KEY="sktsec_t_--RAN5U4ivauy4w37-6aoKyYPDt5ZbaT5JBVMqiwKo_api"
1515
ERRORS=0
1616

1717
# Get files in this commit (for security checks).
18-
COMMITTED_FILES=$(git diff --cached --name-only --diff-filter=ACM 2>/dev/null || echo "")
18+
COMMITTED_FILES=$(git diff --cached --name-only --diff-filter=ACM 2>/dev/null || printf "\n")
1919

2020
# Quick checks for critical issues in committed files.
2121
if [ -n "$COMMITTED_FILES" ]; then
2222
for file in $COMMITTED_FILES; do
2323
if [ -f "$file" ]; then
2424
# Check for Socket API keys (except allowed).
2525
if grep -E 'sktsec_[a-zA-Z0-9_-]+' "$file" 2>/dev/null | grep -v "$ALLOWED_PUBLIC_KEY" | grep -v 'your_api_key_here' | grep -v 'fake-token' | grep -v 'test-token' | grep -v '\.example' | grep -q .; then
26-
echo "${RED}✗ SECURITY: Potential API key detected in commit!${NC}"
27-
echo "File: $file"
26+
printf "${RED}✗ SECURITY: Potential API key detected in commit!${NC}\n"
27+
printf "File: %s\n" "$file"
2828
ERRORS=$((ERRORS + 1))
2929
fi
3030

3131
# Check for .env files.
3232
if echo "$file" | grep -qE '^\.env(\.local)?$'; then
33-
echo "${RED}✗ SECURITY: .env file in commit!${NC}"
33+
printf "${RED}✗ SECURITY: .env file in commit!${NC}\n"
3434
ERRORS=$((ERRORS + 1))
3535
fi
3636
fi
@@ -41,7 +41,12 @@ fi
4141
COMMIT_MSG_FILE="$1"
4242
if [ -f "$COMMIT_MSG_FILE" ]; then
4343
# Create a temporary file to store the cleaned message.
44-
TEMP_FILE=$(mktemp)
44+
TEMP_FILE=$(mktemp) || {
45+
printf "${RED}✗ Failed to create temporary file${NC}\n" >&2
46+
exit 1
47+
}
48+
# Ensure cleanup on exit
49+
trap 'rm -f "$TEMP_FILE"' EXIT
4550
REMOVED_LINES=0
4651

4752
# Read the commit message line by line and filter out AI attribution.
@@ -58,15 +63,15 @@ if [ -f "$COMMIT_MSG_FILE" ]; then
5863
# Replace the original commit message with the cleaned version.
5964
if [ $REMOVED_LINES -gt 0 ]; then
6065
mv "$TEMP_FILE" "$COMMIT_MSG_FILE"
61-
echo "${GREEN}✓ Auto-stripped${NC} $REMOVED_LINES AI attribution line(s) from commit message"
66+
printf "${GREEN}✓ Auto-stripped${NC} $REMOVED_LINES AI attribution line(s) from commit message\n"
6267
else
6368
# No lines were removed, just clean up the temp file.
6469
rm -f "$TEMP_FILE"
6570
fi
6671
fi
6772

6873
if [ $ERRORS -gt 0 ]; then
69-
echo "${RED}✗ Commit blocked by security validation${NC}"
74+
printf "${RED}✗ Commit blocked by security validation${NC}\n"
7075
exit 1
7176
fi
7277

.husky/commit-msg

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
# Run commit message validation and auto-strip AI attribution.
2-
.git-hooks/commit-msg "$1"
2+
if [ -x ".git-hooks/commit-msg" ]; then
3+
.git-hooks/commit-msg "$1"
4+
else
5+
printf "\033[0;31m✗ Error: .git-hooks/commit-msg not found or not executable\033[0m\n" >&2
6+
exit 1
7+
fi

0 commit comments

Comments
 (0)