mirror of
https://github.com/MervinPraison/PraisonAI.git
synced 2026-11-07 04:35:58 -10:00
fix: validate URL in compare_extraction before newspaper/requests fetch
Close SSRF gap where compare_extraction fetched via newspaper3k and requests.get without _validate_url, unlike the trafilatura path. Co-authored-by: Mervin Praison <[email protected]>
This commit is contained in:
1 parent
b60ce7d517
commit
df99b2b4c7
1 file changed
+11
-1
@@ -279,7 +279,17 @@ class TrafilaturaTools:
|
||||
"newspaper": None,
|
||||
"spider": None
|
||||
}
|
||||
|
||||
|
||||
# Validate the URL once before any fetcher runs so the newspaper and
|
||||
# requests paths below are protected against SSRF, just like the
|
||||
# trafilatura path (which validates inside extract_content).
|
||||
if not self._validate_url(url):
|
||||
error = {"error": f"Invalid or unsafe URL: {url}"}
|
||||
comparison["trafilatura"] = error
|
||||
comparison["newspaper"] = error
|
||||
comparison["spider"] = error
|
||||
return comparison
|
||||
|
||||
# Get Trafilatura extraction
|
||||
try:
|
||||
comparison["trafilatura"] = self.extract_content(url)
|
||||
|
||||
Reference in new issue
Block a user