fix vector db sql injection (#16096)

This commit is contained in:
Jyong
2025-03-18 15:07:29 +08:00
committed by GitHub
parent 750ec55646
commit 33ba7e659b
4 changed files with 14 additions and 3 deletions

View File

@@ -125,6 +125,8 @@ class MyScaleVector(BaseVector):
def _search(self, dist: str, order: SortOrder, **kwargs: Any) -> list[Document]:
top_k = kwargs.get("top_k", 4)
if not isinstance(top_k, int) or top_k <= 0:
raise ValueError("top_k must be a positive integer")
score_threshold = float(kwargs.get("score_threshold") or 0.0)
where_str = (
f"WHERE dist < {1 - score_threshold}"