🔐 Sid Gifari File Manager Pro
v8.0.5 | 2026-08-09 23:41:07 | PHP 8.2.33
📂
/ (Root)
/
opt
/
cloudlinux
/
venv
/
lib
/
python3.11
/
site-packages
/
clcagefslib
/
webisolation
/
__pycache__
📍 /opt/cloudlinux/venv/lib/python3.11/site-packages/clcagefslib/webisolation/__pycache__
🔄 Refresh
✏️
Editing: docroot_validation.cpython-311.pyc
Read Only
� �9Vj � �Z � d Z ddlmZ ddlZddlZ ej d� � ZdZdd �Zd d�Z dS )ab Trust-boundary validation for panel-supplied document root strings. The docroot value originates from the hosting panel (cPanel / DirectAdmin / Plesk) and is consumed by privileged code that writes jail.c mount configuration files read by root. The jail.c mount syntax is whitespace-delimited (MountEntry.render in mount_types.py joins source/target/options with spaces) and section headers are bracketed (`[<docroot>]` in jail_config.MountConfig.render), so any whitespace, control character, newline, or bracket inside the docroot corrupts the parser. A sibling module already rejects newlines/carriage-returns on the analogous crontab write path (crontab/libhooks.py and crontab/parser.py); this module is the equivalent guard for the jail mount config write path. Validation is centralized at the trust boundary - call sites are `enable_website_isolation` (where a tenant-owned domain is resolved to a docroot for the first time) and `write_jail_mounts_config` (where the docroot map is re-read from the panel for every regeneration). The helper raises ValueError on rejection, matching the sibling crontab pattern. � )�annotationsNz^/[A-Za-z0-9_./-]*$i �docroot�str�returnc � � t | t � � st d| ��� � �| st d� � �t | � � t k r*t dt | � � � dt � d| ��� � �| � d� � st d| ��� � �t � | � � st d| ��� � �| � d� � D ]}|d k rt d | ��� � ��| S )a1 Validate a panel-supplied document root before it reaches the jail mount config writer. Args: docroot: Document root string returned by the panel (e.g. from ``clcommon.cpapi.docroot`` or ``clcommon.cpapi.userdomains``). Returns: The validated docroot string, unchanged. Raises: ValueError: If the docroot is empty, not an absolute path, too long, contains a path-traversal segment, or contains any character outside the strict allowlist (alnum, `_`, `-`, `.`, `/`). z Invalid docroot (not a string): zInvalid docroot: empty stringzInvalid docroot (length z exceeds �): �/z Invalid docroot (not absolute): z)Invalid docroot (disallowed characters): z..z$Invalid docroot (parent traversal): ) � isinstancer � ValueError�len�_DOCROOT_MAX_LEN� startswith�_DOCROOT_ALLOWED_RE�match�split)r �segments �_opt/cloudlinux/venv/lib/python3.11/site-packages/clcagefslib/webisolation/docroot_validation.py�validate_docrootr 3 s3 � �"