Skip to content

Add input validation for DOCS_BUILD_REF environment variable #189

Closed
@coderabbitai

Description

@coderabbitai

As per the suggestion in this comment, we need to add input validation for the DOCS_BUILD_REF environment variable in docs/conf.py to ensure it contains a valid Git reference.

Suggested implementation:

def _validate_git_ref(ref: str) -> str:
    """Validate if the provided string is a valid Git reference.
    
    Args:
        ref: The Git reference to validate
    
    Returns:
        str: The validated Git reference
    
    Raises:
        ValueError: If the reference contains invalid characters
    """
    import re
    if not re.match(r'^[a-zA-Z0-9_\-./]+$', ref):
        raise ValueError(f"Invalid Git reference: {ref}")
    return ref

DOCS_BUILD_REF: str = _validate_git_ref(os.environ.get("DOCS_BUILD_REF", "stable"))

Related PR: #184
Comment URL: #184 (comment)
Requester: @reactive-firewall

Metadata

Metadata

Labels

CIContinuous Integration ToolingdocumentationImprovements or additions to documentation

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions