mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-04-10 03:13:29 +08:00
fix: harden CI validators, shell scripts, and expand test suite
- Add try-catch around readFileSync in validate-agents, validate-commands, validate-skills to handle TOCTOU races and file read errors - Add validate-hooks.js and all test suites to package.json test script (was only running 4/5 validators and 0/4 test files) - Fix shell variable injection in observe.sh: use os.environ instead of interpolating $timestamp/$OBSERVATIONS_FILE into Python string literals - Fix $? always being 0 in start-observer.sh: capture exit code before conditional since `if !` inverts the status - Add OLD_VERSION validation in release.sh and use pipe delimiter in sed to avoid issues with slash-containing values - Add jq dependency check in evaluate-session.sh before parsing config - Sync .cursor/ copies of all modified shell scripts
This commit is contained in:
@@ -103,10 +103,10 @@ PARSED_OK=$(echo "$PARSED" | python3 -c "import json,sys; print(json.load(sys.st
|
||||
if [ "$PARSED_OK" != "True" ]; then
|
||||
# Fallback: log raw input for debugging
|
||||
timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||
echo "$INPUT_JSON" | python3 -c "
|
||||
import json, sys
|
||||
TIMESTAMP="$timestamp" echo "$INPUT_JSON" | python3 -c "
|
||||
import json, sys, os
|
||||
raw = sys.stdin.read()[:2000]
|
||||
print(json.dumps({'timestamp': '$timestamp', 'event': 'parse_error', 'raw': raw}))
|
||||
print(json.dumps({'timestamp': os.environ['TIMESTAMP'], 'event': 'parse_error', 'raw': raw}))
|
||||
" >> "$OBSERVATIONS_FILE"
|
||||
exit 0
|
||||
fi
|
||||
@@ -124,12 +124,12 @@ fi
|
||||
# Build and write observation
|
||||
timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||
|
||||
echo "$PARSED" | python3 -c "
|
||||
import json, sys
|
||||
TIMESTAMP="$timestamp" echo "$PARSED" | python3 -c "
|
||||
import json, sys, os
|
||||
|
||||
parsed = json.load(sys.stdin)
|
||||
observation = {
|
||||
'timestamp': '$timestamp',
|
||||
'timestamp': os.environ['TIMESTAMP'],
|
||||
'event': parsed['event'],
|
||||
'tool': parsed['tool'],
|
||||
'session': parsed['session']
|
||||
@@ -140,9 +140,8 @@ if parsed['input']:
|
||||
if parsed['output']:
|
||||
observation['output'] = parsed['output']
|
||||
|
||||
with open('$OBSERVATIONS_FILE', 'a') as f:
|
||||
f.write(json.dumps(observation) + '\n')
|
||||
"
|
||||
print(json.dumps(observation))
|
||||
" >> "$OBSERVATIONS_FILE"
|
||||
|
||||
# Signal observer if running
|
||||
OBSERVER_PID_FILE="${CONFIG_DIR}/.observer.pid"
|
||||
|
||||
Reference in New Issue
Block a user