Update optimize wave3 (need update wave 4 to wave 8)
This commit is contained in:
@@ -206,6 +206,26 @@ if [[ "$MODE" == "input" ]]; then
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Optional semantic escalation (opt-in: CASAN_SEMANTIC_CLASSIFY=1). The regex
|
||||
# layer above catches known phrasings; a genuinely novel paraphrase slips
|
||||
# through as low-risk. When enabled, route still-allowed input to the model
|
||||
# classifier. It can only ADD a block, never remove one. If the model backend
|
||||
# is unreachable, record it and keep the regex verdict (no silent pass of a
|
||||
# blocked item; no hard pipeline failure on infra outage).
|
||||
if [[ "$STATUS" != "blocked" && "${CASAN_SEMANTIC_CLASSIFY:-0}" == "1" && -x "$SCRIPT_DIR/model-router.sh" ]]; then
|
||||
SEM_JSON="$TRACE_DIR/semantic-$TRACE_ID.json"
|
||||
"$SCRIPT_DIR/model-router.sh" "$INPUT_FILE" "$SEM_JSON" --role classify >/dev/null 2>&1 || true
|
||||
if [[ -f "$SEM_JSON" ]]; then
|
||||
SEM_VERDICT="$(python3 -c "import json;print(json.load(open('$SEM_JSON')).get('verdict',''))" 2>/dev/null || echo "")"
|
||||
if [[ "$SEM_VERDICT" == "INJECTION" ]]; then
|
||||
STATUS="blocked"; ACTION="block"; RISK_LEVEL="high"
|
||||
MATCHED_RULES+=("semantic-injection")
|
||||
fi
|
||||
else
|
||||
MATCHED_RULES+=("semantic-unavailable")
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
SAFE_CONTENT="$CONTENT"
|
||||
|
||||
Reference in New Issue
Block a user