mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-14 12:16:20 +00:00
Harden protection with pinned requests and path-param encoding (#2486)
* Harden protection with pinned requests and path-param encoding * fix: domain pinning * fix: tests * fix: html test 2 --------- Co-authored-by: Alex <a@tushynski.me>
This commit is contained in:
1 parent
6cfdc4fbae
commit
aaad51f951
20 files changed
+623
-723
No files matched your search
@@ -11,10 +11,7 @@ class TestReadWebpageErrors:
|
||||
|
||||
tool = ReadWebpageTool(config={})
|
||||
with patch(
|
||||
"application.agents.tools.read_webpage.validate_url",
|
||||
return_value=None,
|
||||
), patch(
|
||||
"application.agents.tools.read_webpage.requests.get",
|
||||
"application.agents.tools.read_webpage.pinned_request",
|
||||
side_effect=requests.exceptions.RequestException("bad url"),
|
||||
):
|
||||
got = tool.execute_action(
|
||||
@@ -27,20 +24,17 @@ class TestReadWebpageErrors:
|
||||
|
||||
tool = ReadWebpageTool(config={})
|
||||
with patch(
|
||||
"application.agents.tools.read_webpage.validate_url",
|
||||
return_value=None,
|
||||
), patch(
|
||||
"application.agents.tools.read_webpage.markdownify",
|
||||
side_effect=RuntimeError("boom"),
|
||||
), patch(
|
||||
"application.agents.tools.read_webpage.requests.get",
|
||||
) as mock_get:
|
||||
mock_get.return_value.text = "<h1>hi</h1>"
|
||||
mock_get.return_value.raise_for_status.return_value = None
|
||||
"application.agents.tools.read_webpage.pinned_request",
|
||||
) as mock_pinned_request:
|
||||
mock_pinned_request.return_value.text = "<h1>hi</h1>"
|
||||
mock_pinned_request.return_value.raise_for_status.return_value = None
|
||||
got = tool.execute_action(
|
||||
"read_webpage", url="https://example.com/",
|
||||
)
|
||||
assert "Error processing URL" in got
|
||||
assert "Error fetching URL" in got
|
||||
|
||||
|
||||
class TestBaseAgentMinorBranches:
|
||||
|
||||
Reference in new issue
Block a user