| Server IP : 88.99.149.37 / Your IP : 216.73.216.141 Web Server : nginx/1.31.2 System : Linux server-88-99-149-37 6.12.0-124.56.5.el10_1.x86_64 #1 SMP PREEMPT_DYNAMIC Fri May 15 06:12:08 EDT 2026 x86_64 User : muralimurth ( 1015) PHP Version : 8.4.23 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/share/crypto-policies/python/cryptopolicies/validation/ |
Upload File : |
# SPDX-License-Identifier: LGPL-2.1-or-later
# Copyright (c) 2021 Red Hat, Inc.
import fnmatch
from .general import PolicySyntaxError
class ScopeSyntaxError(PolicySyntaxError):
pass
class ScopeUnknownError(ScopeSyntaxError):
def __init__(self, scope_glob):
super().__init__(f'unknown scope {scope_glob}')
class ScopeSelectorEmptyError(ScopeSyntaxError):
def __init__(self):
super().__init__('empty scope selector')
class ScopeSelectorIllegalCharacterError(ScopeSyntaxError):
def __init__(self, selector):
super().__init__(f'illegal character in scope selector `{selector}`')
class ScopeSelectorCurlyBracketsError(ScopeSyntaxError):
def __init__(self, pattern):
super().__init__(f'unsupported curly brackets usage in `{pattern}`')
class ScopeSelectorCommaError(ScopeSyntaxError):
def __init__(self, pattern):
super().__init__(f'unsupported comma usage in `{pattern}`')
class ScopeSelectorMatchedNothingError(ScopeSyntaxError):
def __init__(self, pattern):
super().__init__(f'scope selector `{pattern}` matches no scope')
def illegal_characters(p, original_pattern):
if not all(c.isalnum() or c in '{,}*_-' for c in p):
raise ScopeSelectorIllegalCharacterError(original_pattern)
def curly_brackets(p, original_pattern):
if ((p.count('{'), p.count('}')) not in {(0, 0), (1, 1)}
or (p.startswith('{') and not p.endswith('}'))
or (not p.startswith('{') and p.endswith('}'))):
raise ScopeSelectorCurlyBracketsError(original_pattern)
def resulting_globs(globs, all_scopes, original_pattern):
if any(',' in g for g in globs):
raise ScopeSelectorCommaError(original_pattern)
for g in globs:
if not g:
raise ScopeSelectorEmptyError
if not fnmatch.filter(all_scopes, g):
if '*' in g:
raise ScopeSelectorMatchedNothingError(g)
raise ScopeUnknownError(g)