| Server IP : 85.112.90.236 / Your IP : 192.168.1.26 Web Server : Apache System : Linux 85-112-90-236.cprapid.com 6.12.0-211.7.3.el10_2.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 19 12:46:58 EDT 2026 x86_64 User : ftechme ( 1002) PHP Version : 8.2.32 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /lib64/python3.12/site-packages/setools/ |
Upload File : |
# Copyright 2016, Tresys Technology, LLC
#
# SPDX-License-Identifier: LGPL-2.1-only
#
from collections.abc import Iterable
import typing
from . import policyrep, query, util
from .descriptors import CriteriaDescriptor, CriteriaSetDescriptor
__all__: typing.Final[tuple[str, ...]] = ("BoundsQuery",)
class BoundsQuery(query.PolicyQuery):
"""
Query *bounds statements.
Parameter:
policy The policy to query.
Keyword Parameters/Class attributes:
ruletype The rule type(s) to match.
"""
ruletype = CriteriaSetDescriptor[policyrep.BoundsRuletype](enum_class=policyrep.BoundsRuletype)
parent = CriteriaDescriptor[policyrep.Type]("parent_regex")
parent_regex: bool = False
child = CriteriaDescriptor[policyrep.Type]("child_regex")
child_regex: bool = False
def results(self) -> Iterable[policyrep.Bounds]:
"""Generator which yields all matching *bounds statements."""
self.log.info(f"Generating bounds results from {self.policy}")
self.log.debug(f"{self.ruletype=}")
self.log.debug(f"{self.parent=}, {self.parent_regex=}")
self.log.debug(f"{self.child=}, {self.child_regex=}")
for b in self.policy.bounds():
if self.ruletype and b.ruletype not in self.ruletype:
continue
if self.parent and not util.match_regex(
b.parent,
self.parent,
self.parent_regex):
continue
if self.child and not util.match_regex(
b.child,
self.child,
self.child_regex):
continue
yield b