fix(api): enforce integer limit and cap at 1000 in scrape_data function

This commit is contained in:
2026-03-14 17:35:05 +00:00
parent 062937ec3c
commit d2b919cd66

View File

@@ -150,15 +150,19 @@ def scrape_data():
if "name" not in source: if "name" not in source:
return jsonify({"error": "Each source must contain a name"}), 400 return jsonify({"error": "Each source must contain a name"}), 400
if "limit" in source: name = source["name"]
limit = source.get("limit", 1000)
category = source.get("category")
search = source.get("search")
if limit:
try: try:
source["limit"] = int(source["limit"]) limit = int(limit)
except (ValueError, TypeError): except (ValueError, TypeError):
return jsonify({"error": "Limit must be an integer"}), 400 return jsonify({"error": "Limit must be an integer"}), 400
name = source["name"] if limit > 1000:
category = source.get("category") limit = 1000
search = source.get("search")
if name not in connector_metadata: if name not in connector_metadata:
return jsonify({"error": "Source not supported"}), 400 return jsonify({"error": "Source not supported"}), 400