Skip to content

Commit 590dd2a

Browse files
authored
fix(security): resolve Python dependency vulnerabilities (#407)
This pull request primarily updates dependencies across several Python projects to newer versions, switches some dependencies to local development mode for easier testing and development, and introduces improved test utilities for deterministic testing. The updates are aimed at maintaining compatibility, leveraging new features, and ensuring more reliable and maintainable test environments. Dependency updates and improvements: * Updated multiple dependencies to newer versions across `libs/admin-api-lib`, `libs/extractor-api-lib`, `libs/rag-core-api`, `libs/rag-core-lib`, `services/document-extractor`, `services/mcp-server`, and `services/rag-backend`. Notable updates include `openai`, `starlette`, `python-multipart`, `pytest`, `langgraph-checkpoint`, `camelot-py`, `docling`, and others. [[1]](diffhunk://#diff-9c5aeb0db77c2eec077d07ddc3b3810ae1a4a1e50ee7061fba37a46706c513fbL128-R134) [[2]](diffhunk://#diff-dede389bcfb615c4b45cd1da7ac14cbe9535305f41f19cce09e321c91a8bb323L118-R126) [[3]](diffhunk://#diff-dede389bcfb615c4b45cd1da7ac14cbe9535305f41f19cce09e321c91a8bb323L135-R143) [[4]](diffhunk://#diff-9c4162cc1c16dd4c7ec5e95e79df285e8c0882a1db7ff2892c746a0537d26c36L35-R51) [[5]](diffhunk://#diff-b19ab043535569caf9345971969d115d6515ae951a21b00a278145a28230fba1L32-R34) [[6]](diffhunk://#diff-a32cd883126f65652f92c8ecc411d949b7bcf95edb2156c36dc2c1b7063ee690L24-R26) [[7]](diffhunk://#diff-575f4ba32d7ff340b37eb2f875cb9574553092b79335faadd5f3b6be662b6925L19-R19) [[8]](diffhunk://#diff-bda9860363f25ca7829f0bc0121455b5cfea15f6ecc4e98d168aba411d9653c9L76-R76) * Changed `rag-core-lib` dependency to use a local development path instead of a fixed version in several `pyproject.toml` files, facilitating local development and testing. [[1]](diffhunk://#diff-9c5aeb0db77c2eec077d07ddc3b3810ae1a4a1e50ee7061fba37a46706c513fbL116-R116) [[2]](diffhunk://#diff-dede389bcfb615c4b45cd1da7ac14cbe9535305f41f19cce09e321c91a8bb323L96-R97) [[3]](diffhunk://#diff-9c4162cc1c16dd4c7ec5e95e79df285e8c0882a1db7ff2892c746a0537d26c36L23-R23) Testing and development enhancements: * Added a new `MockSparseEmbeddings` class in `libs/rag-core-api/tests/mocks/mock_sparse_embeddings.py` to provide deterministic sparse embeddings for tests, and integrated it into the test setup to improve test reliability. [[1]](diffhunk://#diff-4d25f80941e8e49128a0bd00f1a9424f75a689245809af4cd54198dbb70c3a53R1-R16) [[2]](diffhunk://#diff-596a163e3b70fef32bb64c59bf15f33aeab492eaf41c0cc833bbf2e17439c42aR25-R26) [[3]](diffhunk://#diff-596a163e3b70fef32bb64c59bf15f33aeab492eaf41c0cc833bbf2e17439c42aR73-R74) * Updated test infrastructure in `rag_api_test.py` to override the sparse embedder and reranker with mock implementations and to configure Qdrant collections for sparse vector support. [[1]](diffhunk://#diff-596a163e3b70fef32bb64c59bf15f33aeab492eaf41c0cc833bbf2e17439c42aR73-R74) [[2]](diffhunk://#diff-596a163e3b70fef32bb64c59bf15f33aeab492eaf41c0cc833bbf2e17439c42aR97-R99) Prompt template formatting: * Improved formatting in prompt template files by adjusting how multiline strings are defined, enhancing readability and maintainability. [[1]](diffhunk://#diff-f45d2e4f21bc9442444429d1a64091e4c50132f371b05b72374956fa02b1d966L30-R34) [[2]](diffhunk://#diff-e93a1e7be5b80657d6e435a651dab98960b0d1c1e7a8672f4e3927b4cd0c3fe7L21-R25)
1 parent 87832ad commit 590dd2a

18 files changed

Lines changed: 2609 additions & 2497 deletions

File tree

‎libs/admin-api-lib/poetry.lock‎

Lines changed: 186 additions & 185 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎libs/admin-api-lib/pyproject.toml‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ flake8-docstrings = "^1.7.0"
113113
debugpy = "^1.8.14"
114114

115115
[tool.poetry.dependencies]
116-
rag-core-lib = "==4.2.0"
116+
rag-core-lib = {path = "../rag-core-lib", develop = true}
117117
python = "^3.13"
118118
uvicorn = "^0.47.0"
119119
fastapi = "^0.136.0"
@@ -125,13 +125,13 @@ tqdm = "^4.67.1"
125125
langfuse = "^3.10.1"
126126
redis = "^6.0.0"
127127
pyyaml = "^6.0.2"
128-
python-multipart = "^0.0.30"
128+
python-multipart = "^0.0.32"
129129
marshmallow = "^3.26.2"
130130
protobuf = ">=5.29.6,<6.0.0"
131131
langchain-experimental = "^0.4.0"
132-
nltk = "^3.9.2"
133-
starlette = ">=0.49.1"
134-
langgraph-checkpoint = ">=3.0.0,<4.0.0"
132+
nltk = "^3.9.4"
133+
starlette = ">=1.0.1"
134+
langgraph-checkpoint = ">=4.0.0,<5.0.0"
135135

136136
[tool.pytest.ini_options]
137137
log_cli = true

‎libs/extractor-api-lib/poetry.lock‎

Lines changed: 545 additions & 481 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎libs/extractor-api-lib/pyproject.toml‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ uvicorn = "^0.47.0"
9393
dependency-injector = "^4.46.0"
9494
pydantic-settings = "^2.9.1"
9595
boto3 = "^1.38.10"
96-
rag-core-lib = "==4.2.0"
97-
python-multipart = "^0.0.30"
96+
rag-core-lib = {path = "../rag-core-lib", develop = true}
97+
python-multipart = "^0.0.32"
9898
oauthlib = "^3.2.2"
9999
requests-oauthlib = "^2.0.0"
100100
pdfplumber = "0.11.9"
@@ -115,14 +115,15 @@ langchain-community = "^0.4.1"
115115
atlassian-python-api = "^4.0.3"
116116
markdownify = "^1.1.0"
117117
langchain-core = "^1.0.7"
118-
camelot-py = {extras = ["cv"], version = "^1.0.0"}
118+
camelot-py = {extras = ["cv"], version = "^2.0.0"}
119119
fake-useragent = "^2.2.0"
120120
pypdfium2 = "4.30.0"
121121
mammoth = "^1.11.0"
122122
pypandoc-binary = "^1.15"
123-
starlette = ">=0.49.1"
123+
starlette = ">=1.0.1"
124124
markitdown = {version = "^0.1.3", extras = ["all"]}
125-
docling = "2.95.0"
125+
docling = "2.97.0"
126+
docling-core = ">=2.74.1,<3.0.0"
126127
torch = [
127128
{ version = "2.10.0", source = "pytorch_cpu", markers = "sys_platform == 'darwin'" },
128129
{ version = "2.10.0+cpu", source = "pytorch_cpu", markers = "sys_platform != 'darwin'" },
@@ -132,13 +133,14 @@ torchvision = [
132133
{ version = "0.25.0+82df5f5", source = "pytorch_cpu", markers = "sys_platform == 'win32' and (platform_machine == 'arm64' or platform_machine == 'ARM64')" },
133134
{ version = "0.25.0+cpu", source = "pytorch_cpu", markers = "sys_platform == 'linux' or (sys_platform == 'win32' and platform_machine != 'arm64' and platform_machine != 'ARM64')" },
134135
]
135-
transformers = ">=4.53.3,<5.0.0"
136+
transformers = "^5.10.2"
137+
pypdf = "^6.10.2"
136138
pypandoc = ">=1.6.2"
137139
pypandoc_binary = ">=1.6.2"
138140

139141
[tool.poetry.group.test.dependencies]
140-
pytest = "^8.3.5"
141-
pytest-asyncio = "^0.26.0"
142+
pytest = "^9.0.3"
143+
pytest-asyncio = "^1.0.0"
142144
coverage = "^7.8.0"
143145
httpx = "^0.28.1"
144146

‎libs/poetry.lock‎

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎libs/rag-core-api/poetry.lock‎

Lines changed: 339 additions & 328 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎libs/rag-core-api/pyproject.toml‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ homepage = "https://pypi.org/project/rag-core-api"
2020

2121
[tool.poetry.dependencies]
2222
python = "^3.13"
23-
rag-core-lib = "==4.2.0"
23+
rag-core-lib = {path = "../rag-core-lib", develop = true}
2424
uvicorn = "^0.47.0"
2525
langchain-qdrant = "^1.1.0"
2626
dependency-injector = "^4.46.0"
@@ -32,23 +32,23 @@ datasets = "^4.0.0"
3232
ragas = "^0.4.0"
3333
flashrank = "^0.2.10"
3434
pyyaml = "^6.0.2"
35-
openai = "^1.77.0"
36-
langgraph = "^1.0.3"
37-
pillow = "^12.0.0"
35+
openai = "^2.26.0"
36+
langgraph = "^1.1.10"
37+
pillow = "^12.2.0"
3838
langchain-ollama = "^1.0.0"
3939
langchain-community = "^0.4.1"
4040
fastembed = "^0.8.0"
4141
langdetect = "^1.0.9"
4242
langfuse = "^3.10.1"
4343
marshmallow = "^3.26.2"
44-
langchain-text-splitters = "^1.0.0"
45-
starlette = ">=0.49.1"
46-
langgraph-checkpoint = ">=3.0.0,<4.0.0"
44+
langchain-text-splitters = "^1.1.2"
45+
starlette = ">=1.0.1"
46+
langgraph-checkpoint = ">=4.0.0,<5.0.0"
4747

4848
[tool.poetry.group.test.dependencies]
49-
pytest = "^8.3.5"
49+
pytest = "^9.0.3"
5050
coverage = "^7.8.0"
51-
pytest-asyncio = "^0.26.0"
51+
pytest-asyncio = "^1.0.0"
5252

5353
[tool.poetry.group.dev.dependencies]
5454
debugpy = "^1.8.14"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""Provide deterministic sparse embeddings for tests."""
2+
3+
from langchain_qdrant import SparseEmbeddings
4+
from langchain_qdrant.sparse_embeddings import SparseVector
5+
6+
7+
class MockSparseEmbeddings(SparseEmbeddings):
8+
"""Return a fixed sparse vector without loading an external model."""
9+
10+
def embed_documents(self, texts: list[str]) -> list[SparseVector]:
11+
"""Embed documents with a deterministic test vector."""
12+
return [SparseVector(indices=[0], values=[1.0]) for _ in texts]
13+
14+
def embed_query(self, text: str) -> SparseVector:
15+
"""Embed a query with a deterministic test vector."""
16+
return SparseVector(indices=[0], values=[1.0])

‎libs/rag-core-api/tests/rag_api_test.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
from mocks.mock_environment_variables import mock_environment_variables
2424
from mocks.mock_logging_directory import mock_logging_config
25+
from mocks.mock_reranker import MockReranker
26+
from mocks.mock_sparse_embeddings import MockSparseEmbeddings
2527
from mocks import MockLangfuseManager
2628

2729
mock_environment_variables()
@@ -68,6 +70,8 @@ async def adjusted_app() -> AsyncGenerator[FastAPI, None]:
6870
embedder=providers.Singleton(FakeEmbeddings, **FakeEmbedderSettings().model_dump()),
6971
)
7072
)
73+
app.container.sparse_embedder.override(providers.Singleton(MockSparseEmbeddings))
74+
app.container.reranker.override(providers.Singleton(MockReranker))
7175

7276
# Override Langfuse with mock implementation
7377
mock_langfuse = providers.Singleton(MagicMock)
@@ -90,6 +94,9 @@ async def adjusted_app() -> AsyncGenerator[FastAPI, None]:
9094
client.create_collection(
9195
collection_name=collection_name,
9296
vectors_config=models.VectorParams(size=FakeEmbedderSettings().size, distance=models.Distance.COSINE),
97+
sparse_vectors_config={
98+
"langchain-sparse": models.SparseVectorParams(),
99+
},
93100
)
94101
yield app
95102
# Clean up

0 commit comments

Comments
 (0)