INNER CODE UNIT · Python

apply_creation

kejilion/sh · site_access_cli.py:142

def apply_creation(rootfd, request, *, expected_version, expected_domain, staged_name='',
                   worker_group=nginx_worker_group, verify_read=check_worker_read, global_policy=nginx_global_config,
                   verify_only=False, validate=None, reload_config=None):
    fields = {'operation', 'configName', 'scope', 'path', 'username', 'password'}
    if not isinstance(request, dict) or request.keys() != fields or request.get('operation') != 'create-stage':
        raise ConfigError('invalid creation request')
    name = request['configName']
    if not isinstance(name, str) or not re.fullmatch(r'[A-Za-z0-9_.-]{1,253}\.conf', name):
        raise ConfigError('invalid configuration name')
    domain = name[:-5].lower()
    if domain != expected_domain or not re.fullmatch(r'[0-9a-f]{64}', expected_version):
        raise ConfigError('creation identity is invalid')
    if not verify_only and not re.fullmatch(r'\.site-create-[a-f0-9]{32}\.pending', staged_name):
        raise ConfigError('creation staging identity is invalid')
    source_name = name if verify_only else staged_name
    directory = directory_beneath(rootfd, ['conf.d'])
    try:
        fd, _, data = _read(directory, source_name, 2 << 20)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…