Mister Spy Say ="Hello Kids ... :D" ___ ____ _ _____ | \/ (_) | | / ___| | . . |_ ___| |_ ___ _ __ \ `--. _ __ _ _ | |\/| | / __| __/ _ \ '__| `--. \ '_ \| | | | | | | | \__ \ || __/ | /\__/ / |_) | |_| | \_| |_/_|___/\__\___|_| \____/| .__/ \__, | | | __/ | |_| |___/ Bot Mister Spy V3
Mister Spy

Mister Spy

Current Path : /lib64/python3.9/site-packages/setools/diff/
Upload File :
Current File : //lib64/python3.9/site-packages/setools/diff/properties.py

# Copyright 2016, Tresys Technology, LLC
#
# SPDX-License-Identifier: LGPL-2.1-only
#
from typing import NamedTuple, Union

from ..policyrep import PolicyEnum

from .descriptors import DiffResultDescriptor
from .difference import Difference


class ModifiedProperty(NamedTuple):

    """Difference details for a modified policy property."""

    property: str
    added: Union[PolicyEnum, bool, int]
    removed: Union[PolicyEnum, bool, int]


class PropertiesDifference(Difference):

    """
    Determine the difference in policy properties
    (unknown permissions, MLS, etc.) between two policies.
    """

    modified_properties = DiffResultDescriptor("diff_properties")

    def diff_properties(self) -> None:
        self.modified_properties = []

        if self.left_policy.handle_unknown != self.right_policy.handle_unknown:
            self.modified_properties.append(
                ModifiedProperty("handle_unknown",
                                 self.right_policy.handle_unknown,
                                 self.left_policy.handle_unknown))

        if self.left_policy.mls != self.right_policy.mls:
            self.modified_properties.append(
                ModifiedProperty("MLS",
                                 self.right_policy.mls,
                                 self.left_policy.mls))

        if self.left_policy.version != self.right_policy.version:
            self.modified_properties.append(
                ModifiedProperty("version",
                                 self.right_policy.version,
                                 self.left_policy.version))

    #
    # Internal functions
    #
    def _reset_diff(self) -> None:
        """Reset diff results on policy changes."""
        self.log.debug("Resetting property differences")
        self.modified_properties = None

Mr. DellatioNx196 GaLers xh3LL Backd00r 1.0, Coded By Mr. DellatioNx196 - Bogor BlackHat