fix: add input validation to event emitter + add test report
- archeflow-event.sh: validate JSON data and parent format before processing - docs/test-report: 42/42 tests passed across all 8 lib scripts
This commit is contained in:
@@ -45,11 +45,20 @@ fi
|
||||
|
||||
TS=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
||||
|
||||
# Validate JSON data
|
||||
if ! echo "$DATA" | jq empty 2>/dev/null; then
|
||||
echo "Error: invalid JSON in data argument: $DATA" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Build parent array from comma-separated seq numbers
|
||||
if [[ -z "$PARENT_RAW" ]]; then
|
||||
PARENT_JSON="[]"
|
||||
else
|
||||
elif [[ "$PARENT_RAW" =~ ^[0-9]+(,[0-9]+)*$ ]]; then
|
||||
PARENT_JSON="[${PARENT_RAW}]"
|
||||
else
|
||||
echo "Error: invalid parent format (expected comma-separated integers): $PARENT_RAW" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Construct the event using jq for reliable JSON assembly
|
||||
|
||||
Reference in New Issue
Block a user