mirror of
https://github.com/LerianStudio/ring
synced 2026-04-21 13:37:27 +00:00
CRITICAL: Fix learning-extract.py filename mismatch with outcome-inference.sh - now reads session-isolated outcome files correctly HIGH fixes: - Remove trailing comma in dev-team fallback JSON - Update installer test fixture to match actual hooks schema - Add state file cleanup mechanism (removes files >7 days old) - Create shared/lib/session-utils.sh for centralized session ID sanitization MEDIUM fixes: - Add RING_AUTO_INSTALL_DEPS opt-in for automatic pip install - Fix BSD sed limitation with cross-platform awk fallback - Add traceback to Python exception handlers for debugging - Fix tier documentation in context-check.sh (4 tiers not 5) - Change handoff query from calendar date to last 24 hours X-Lerian-Ref: 0x1
25 lines
884 B
Bash
Executable file
25 lines
884 B
Bash
Executable file
#!/usr/bin/env bash
|
|
# Session utilities for Ring hooks
|
|
# Provides centralized session ID handling
|
|
|
|
# Sanitize session ID for safe use in filenames
|
|
# SECURITY: Prevents path traversal via malicious session IDs
|
|
# Usage: SESSION_ID_SAFE=$(sanitize_session_id "$SESSION_ID")
|
|
sanitize_session_id() {
|
|
local session_id="${1:-$PPID}"
|
|
# Allow only alphanumeric, hyphens, underscores; max 64 chars
|
|
local sanitized
|
|
sanitized=$(printf '%s' "$session_id" | tr -cd 'a-zA-Z0-9_-' | head -c 64)
|
|
[[ -z "$sanitized" ]] && sanitized="$PPID"
|
|
printf '%s' "$sanitized"
|
|
}
|
|
|
|
# Get safe session ID from environment or fallback
|
|
# Usage: SESSION_ID_SAFE=$(get_safe_session_id)
|
|
get_safe_session_id() {
|
|
sanitize_session_id "${CLAUDE_SESSION_ID:-$PPID}"
|
|
}
|
|
|
|
# Export for use in subshells
|
|
export -f sanitize_session_id 2>/dev/null || true
|
|
export -f get_safe_session_id 2>/dev/null || true
|