Files
docling-core/docling_core/utils/settings.py
COTHSC 864036d545 feat: add DOCLINGCORE_ALLOWED_PRIVATE_IPS setting to allow private IPs (#608)
* feat: add DOCLINGCORE_ALLOWED_PRIVATE_IPS setting to allow private IP access

Signed-off-by: COTHSC <thierryscully.colomban@gmail.com>

* fix: address review feedback on private-IP allowlist

fix broken response in test_allowed_private_ips (use _closeable_response instead of Response)
document allowed_private_ips
widen _ip_in_allowlist typehint to include ipv6 addresses + add docstring
clarify the malformed entry logmessage to hint at strict CIDR parsing

Signed-off-by: COTHSC <thierryscully.colomban@gmail.com>

* fix: use strict=False with normalization warning for CIDR allowlist entries

Signed-off-by: COTHSC <thierryscully.colomban@gmail.com>

* style: apply ruff-format

Signed-off-by: COTHSC <thierryscully.colomban@gmail.com>

---------

Signed-off-by: COTHSC <thierryscully.colomban@gmail.com>
2026-09-10 14:04:28 +02:00

32 lines
969 B
Python

from typing import Annotated
from pydantic import Field
from pydantic_settings import BaseSettings, SettingsConfigDict
class CoreSettings(BaseSettings):
model_config = SettingsConfigDict(env_prefix="DOCLINGCORE_")
allow_image_file_uri: bool = False
max_image_decoded_size: int = 20 * 1024 * 1024 # 20MB
allowed_private_ips: Annotated[
list[str],
Field(
description=(
"List of IP addresses and/or CIDR ranges that bypass SSRF protection. "
"Defaults to empty, which preserves full SSRF protection."
),
examples=[
["192.168.1.0/24", "10.0.0.5", "127.0.0.1"],
],
),
] = []
# DocLang deserialize budgets (DoS protection for untrusted markup / .dclx)
max_doclang_xml_bytes: int = 128 * 1024 * 1024 # 128 MiB
max_doclang_xml_depth: int = 128
max_doclang_xml_elements: int = 1_000_000
settings = CoreSettings()