D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
usr
/
share
/
crypto-policies
/
python
/
cryptopolicies
/
validation
/
Filename :
scope.py
back
Copy
# 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)
Name
Size
Last Modified
Owner
Permissions
Actions
__pycache__
Dir
December 10 2023 3:44:18
root
0755
__init__.py
0.278
KB
August 01 2023 3:18:06
root
0644
alg_lists.py
0.651
KB
August 01 2023 3:18:06
root
0644
general.py
0.362
KB
August 01 2023 3:18:06
root
0644
rules.py
1.141
KB
August 01 2023 3:18:06
root
0644
scope.py
1.925
KB
August 01 2023 3:18:06
root
0644
2017 © D7net | D704T team