/
usr
/
lib64
/
python3.9
/
site-packages
/
setools
/
/usr/lib64/python3.9/site-packages/setools
mkdir
upload
Name
Size
Mode
Actions
checker/
-
0755
rm
diff/
-
0755
rm
__pycache__/
-
0755
rm
boolquery.py
1742
0644
edit
dl
rm
boundsquery.py
1845
0644
edit
dl
rm
categoryquery.py
1375
0644
edit
dl
rm
commonquery.py
1613
0644
edit
dl
rm
constraintquery.py
5110
0644
edit
dl
rm
defaultquery.py
2340
0644
edit
dl
rm
descriptors.py
9932
0644
edit
dl
rm
devicetreeconquery.py
2276
0644
edit
dl
rm
dta.py
23211
0644
edit
dl
rm
exception.py
6104
0644
edit
dl
rm
fsusequery.py
2868
0644
edit
dl
rm
genfsconquery.py
3260
0644
edit
dl
rm
ibendportconquery.py
3126
0644
edit
dl
rm
ibpkeyconquery.py
5006
0644
edit
dl
rm
infoflow.py
15913
0644
edit
dl
rm
initsidquery.py
2309
0644
edit
dl
rm
iomemconquery.py
4095
0644
edit
dl
rm
ioportconquery.py
4120
0644
edit
dl
rm
mixins.py
6980
0644
edit
dl
rm
mlsrulequery.py
4186
0644
edit
dl
rm
netifconquery.py
2456
0644
edit
dl
rm
nodeconquery.py
3997
0644
edit
dl
rm
objclassquery.py
3348
0644
edit
dl
rm
pcideviceconquery.py
2642
0644
edit
dl
rm
permmap.py
16585
0644
edit
dl
rm
perm_map
86114
0644
edit
dl
rm
pirqconquery.py
2538
0644
edit
dl
rm
polcapquery.py
1144
0644
edit
dl
rm
policyrep.cpython-39-x86_64-linux-gnu.so
1522808
0755
edit
dl
rm
policyrep.pyi
52253
0644
edit
dl
rm
portconquery.py
4889
0644
edit
dl
rm
py.typed
0
0644
edit
dl
rm
query.py
1268
0644
edit
dl
rm
rbacrulequery.py
5463
0644
edit
dl
rm
rolequery.py
1997
0644
edit
dl
rm
sensitivityquery.py
2270
0644
edit
dl
rm
terulequery.py
8939
0644
edit
dl
rm
typeattrquery.py
2157
0644
edit
dl
rm
typequery.py
3021
0644
edit
dl
rm
userquery.py
4290
0644
edit
dl
rm
util.py
7773
0644
edit
dl
rm
__init__.py
3316
0644
edit
dl
rm
Edit:
/usr/lib64/python3.9/site-packages/setools/rbacrulequery.py
(5463B)
# Copyright 2014-2015, Tresys Technology, LLC # # SPDX-License-Identifier: LGPL-2.1-only # import logging import re from typing import cast, Iterable, Optional, Pattern, Union from . import mixins, query from .descriptors import CriteriaDescriptor, CriteriaSetDescriptor from .exception import InvalidType, RuleUseError from .policyrep import AnyRBACRule, RBACRuletype, Role, TypeOrAttr from .util import match_indirect_regex class RBACRuleQuery(mixins.MatchObjClass, query.PolicyQuery): """ Query the RBAC rules. Parameter: policy The policy to query. Keyword Parameters/Class attributes: ruletype The list of rule type(s) to match. source The name of the source role/attribute to match. source_indirect If true, members of an attribute will be matched rather than the attribute itself. source_regex If true, regular expression matching will be used on the source role/attribute. Obeys the source_indirect option. target The name of the target role/attribute to match. target_indirect If true, members of an attribute will be matched rather than the attribute itself. target_regex If true, regular expression matching will be used on the target role/attribute. Obeys target_indirect option. tclass The object class(es) to match. tclass_regex If true, use a regular expression for matching the rule's object class. default The name of the default role to match. default_regex If true, regular expression matching will be used on the default role. """ ruletype = CriteriaSetDescriptor(enum_class=RBACRuletype) source = CriteriaDescriptor("source_regex", "lookup_role") source_regex: bool = False source_indirect: bool = True _target: Optional[Union[Pattern, Role, TypeOrAttr]] = None target_regex: bool = False target_indirect: bool = True tclass = CriteriaSetDescriptor("tclass_regex", "lookup_class") tclass_regex: bool = False default = CriteriaDescriptor("default_regex", "lookup_role") default_regex: bool = False @property def target(self) -> Optional[Union[Pattern, Role, TypeOrAttr]]: return self._target @target.setter def target(self, value: Optional[Union[str, Role, TypeOrAttr]]) -> None: if not value: self._target = None elif self.target_regex: self._target = re.compile(value) else: try: self._target = self.policy.lookup_type_or_attr(cast(Union[str, TypeOrAttr], value)) except InvalidType: self._target = self.policy.lookup_role(cast(Union[str, Role], value)) def __init__(self, policy, **kwargs) -> None: super(RBACRuleQuery, self).__init__(policy, **kwargs) self.log = logging.getLogger(__name__) def results(self) -> Iterable[AnyRBACRule]: """Generator which yields all matching RBAC rules.""" self.log.info("Generating RBAC rule results from {0.policy}".format(self)) self.log.debug("Ruletypes: {0.ruletype}".format(self)) self.log.debug("Source: {0.source!r}, indirect: {0.source_indirect}, " "regex: {0.source_regex}".format(self)) self.log.debug("Target: {0.target!r}, indirect: {0.target_indirect}, " "regex: {0.target_regex}".format(self)) self._match_object_class_debug(self.log) self.log.debug("Default: {0.default!r}, regex: {0.default_regex}".format(self)) for rule in self.policy.rbacrules(): # # Matching on rule type # if self.ruletype: if rule.ruletype not in self.ruletype: continue # # Matching on source role # if self.source and not match_indirect_regex( rule.source, self.source, self.source_indirect, self.source_regex): continue # # Matching on target type (role_transition)/role(allow) # if self.target and not match_indirect_regex( rule.target, self.target, self.target_indirect, self.target_regex): continue # # Matching on object class # try: if not self._match_object_class(rule): continue except RuleUseError: continue # # Matching on default role # if self.default: try: # because default role is always a single # role, hard-code indirect to True # so the criteria can be an attribute if not match_indirect_regex( rule.default, self.default, True, self.default_regex): continue except RuleUseError: continue # if we get here, we have matched all available criteria yield rule
Save
cmd:
run