Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix: resolve Hypothesis fuzz test failures

LearningCircuite47a56752cb2
diff --git a/pdm.lock b/pdm.lock
index 689964e7a5..481e7d3f56 100644
--- a/pdm.lock
+++ b/pdm.lock
@@ -5,7 +5,7 @@
groups = ["default", "dev"]
strategy = ["inherit_metadata"]
lock_version = "4.5.0"
-content_hash = "sha256:1e0a3ee486cd661bfde2e0927c7176748f4ec36c6cfe10cb2586320e6c7a5860"
+content_hash = "sha256:f7d01b06dd38731db4cbc0354505ec604a8952f8225ba603386044bce7fee836"
[[metadata.targets]]
requires_python = ">=3.11,<3.15"
@@ -1980,6 +1980,21 @@ files = [
{file = "huggingface_hub-0.35.3.tar.gz", hash = "sha256:350932eaa5cc6a4747efae85126ee220e4ef1b54e29d31c3b45c5612ddf0b32a"},
]
+[[package]]
+name = "hypothesis"
+version = "6.148.3"
+requires_python = ">=3.10"
+summary = "The property-based testing library for Python"
+groups = ["dev"]
+dependencies = [
+ "exceptiongroup>=1.0.0; python_version < \"3.11\"",
+ "sortedcontainers<3.0.0,>=2.1.0",
+]
+files = [
+ {file = "hypothesis-6.148.3-py3-none-any.whl", hash = "sha256:e7dd193da9800234ec5e1541c1eddde4bddff49b53faf690ba68a0af55a7abb3"},
+ {file = "hypothesis-6.148.3.tar.gz", hash = "sha256:bd81221740d8658473060ad900dc831f889f156fdb41210ba2f47cfad10a66ed"},
+]
+
[[package]]
name = "identify"
version = "2.6.15"
@@ -5893,6 +5908,16 @@ files = [
{file = "sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc"},
]
+[[package]]
+name = "sortedcontainers"
+version = "2.4.0"
+summary = "Sorted Containers -- Sorted List, Sorted Dict, Sorted Set"
+groups = ["dev"]
+files = [
+ {file = "sortedcontainers-2.4.0-py2.py3-none-any.whl", hash = "sha256:a163dcaede0f1c021485e957a39245190e74249897e2ae4b2aa38595db237ee0"},
+ {file = "sortedcontainers-2.4.0.tar.gz", hash = "sha256:25caa5a06cc30b6b83d11423433f65d1f9d76c4c6a0c90e3379eaa43b9bfdb88"},
+]
+
[[package]]
name = "soupsieve"
version = "2.8"
diff --git a/pyproject.toml b/pyproject.toml
index 47a2a39fb0..2df666e27f 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -130,6 +130,7 @@ dev = [
"types-requests>=2.31.0",
"types-setuptools>=69.0.0",
"types-toml>=0.10.8",
+ "hypothesis~=6.122",
]
[tool.pytest.ini_options]
diff --git a/tests/fuzz/test_fuzz_security.py b/tests/fuzz/test_fuzz_security.py
index bdccd92a15..e292bbfbaa 100644
--- a/tests/fuzz/test_fuzz_security.py
+++ b/tests/fuzz/test_fuzz_security.py
@@ -16,24 +16,21 @@ from local_deep_research.security.path_validator import PathValidator
class TestPathValidatorFuzzing:
"""Fuzz tests for PathValidator security functions."""
- @pytest.fixture
- def temp_dir(self):
- """Create a temporary directory for testing."""
- with tempfile.TemporaryDirectory() as tmpdir:
- yield tmpdir
-
@given(user_input=st.text(max_size=1000))
@settings(max_examples=200)
- def test_validate_safe_path_no_crash(self, user_input, temp_dir):
+ def test_validate_safe_path_no_crash(self, user_input):
"""Test that validate_safe_path never crashes on arbitrary input."""
- try:
- PathValidator.validate_safe_path(user_input, temp_dir)
- except ValueError:
- # Expected for invalid paths - this is correct behavior
- pass
- except Exception as e:
- # Any other exception type is a bug
- pytest.fail(f"Unexpected exception type: {type(e).__name__}: {e}")
+ with tempfile.TemporaryDirectory() as temp_dir:
+ try:
+ PathValidator.validate_safe_path(user_input, temp_dir)
+ except ValueError:
+ # Expected for invalid paths - this is correct behavior
+ pass
+ except Exception as e:
+ # Any other exception type is a bug
+ pytest.fail(
+ f"Unexpected exception type: {type(e).__name__}: {e}"
+ )
@given(
user_input=st.text(
@@ -59,10 +56,11 @@ class TestPathValidatorFuzzing:
path=st.from_regex(r"\.\./[a-zA-Z0-9/]+", fullmatch=True),
)
@settings(max_examples=100)
- def test_path_traversal_blocked(self, path, temp_dir):
+ def test_path_traversal_blocked(self, path):
"""Test that path traversal attempts are always blocked."""
- with pytest.raises(ValueError):
- PathValidator.validate_safe_path(path, temp_dir)
+ with tempfile.TemporaryDirectory() as temp_dir:
+ with pytest.raises(ValueError):
+ PathValidator.validate_safe_path(path, temp_dir)
@given(
path=st.sampled_from(
@@ -83,17 +81,14 @@ class TestPathValidatorFuzzing:
PathValidator.validate_config_path(path, "/tmp")
@given(
- path=st.text(
- alphabet=st.characters(
- whitelist_characters="\x00",
- ),
- min_size=1,
- max_size=100,
- ).map(lambda x: f"test{x}file.json")
+ null_count=st.integers(min_value=1, max_value=10),
)
@settings(max_examples=50)
- def test_null_byte_injection_blocked(self, path):
+ def test_null_byte_injection_blocked(self, null_count):
"""Test that null byte injection attempts are handled."""
+ # Generate paths with null bytes embedded (Python 3.11 compatible)
+ null_bytes = "\x00" * null_count
+ path = "test" + null_bytes + "file.json"
try:
PathValidator.validate_config_path(path, "/tmp")
except ValueError: