chartbook.conf_validation#
Security validation for user-provided configuration values.
This module provides validation for values that will be inserted into conf.py templates. Since conf.py is executed as Python code by Sphinx, all user input must be validated to prevent code injection attacks.
Module Contents#
Classes#
Validated site configuration for conf.py template rendering. |
Functions#
Validate configuration values intended for conf.py template. |
|
Validate that all source files referenced in the manifest exist. |
API#
- class chartbook.conf_validation.SiteConfig[source]#
Validated site configuration for conf.py template rendering.
All string values are validated against security patterns to prevent Python code injection when rendered into conf.py templates.
Attributes: title: Project title (alphanumeric, spaces, basic punctuation). author: Author name (alphanumeric, spaces, basic punctuation). copyright: Copyright text (alphanumeric, spaces, basic punctuation). sphinx_theme: Sphinx theme name (must be from allowed list).
- SAFE_TEXT_PATTERN: ClassVar[re.Pattern]#
‘compile(…)’
- classmethod from_manifest(manifest: dict, pipeline_theme: str) chartbook.conf_validation.SiteConfig[source]#
Create a validated SiteConfig from manifest dictionary.
- Parameters:
- Returns:
Validated SiteConfig instance.
- Return type:
- Raises:
ValidationError – If any value fails validation.
- chartbook.conf_validation.validate_conf_py_values(manifest: dict, pipeline_theme: str) chartbook.conf_validation.SiteConfig[source]#
Validate configuration values intended for conf.py template.
This is the main entry point for validation. It ensures all values that will be inserted into conf.py are safe from code injection.
- Parameters:
- Returns:
Validated SiteConfig instance with all values safe for templating.
- Return type:
- Raises:
ValidationError – If any value fails security validation.
- chartbook.conf_validation.validate_source_files(manifest: dict, base_dir) list[source]#
Validate that all source files referenced in the manifest exist.
Checks for the existence of:
Dataframe parquet files (path)
Dataframe documentation files (docs_path, when mode=“path”)
Chart HTML files (path)
Chart documentation files (docs_path, when mode=“path”)
Notebook files (path)
Note markdown files (path)
README.md per pipeline
User-specified logo and favicon files
- Parameters:
manifest (dict) – The manifest dictionary from chartbook.toml.
base_dir (Path) – The base directory of the project.
- Returns:
List of MissingFile objects for any files that don’t exist.
- Return type: