1 # Copyright 2016, Tresys Technology, LLC 2 # 3 # This file is part of SETools. 4 # 5 # SETools is free software: you can redistribute it and/or modify 6 # it under the terms of the GNU Lesser General Public License as 7 # published by the Free Software Foundation, either version 2.1 of 8 # the License, or (at your option) any later version. 9 # 10 # SETools is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU Lesser General Public License for more details. 14 # 15 # You should have received a copy of the GNU Lesser General Public 16 # License along with SETools. If not, see 17 # <http://www.gnu.org/licenses/>. 18 # 19 from .descriptors import DiffResultDescriptor 20 from .difference import Difference, SymbolWrapper 21 22 23 class PolCapsDifference(Difference): 24 25 """Determine the difference in polcaps between two policies.""" 26 27 added_polcaps = DiffResultDescriptor("diff_polcaps") 28 removed_polcaps = DiffResultDescriptor("diff_polcaps") 29 30 def diff_polcaps(self): 31 """Generate the difference in polcaps between the policies.""" 32 33 self.log.info("Generating policy cap differences from {0.left_policy} to {0.right_policy}". 34 format(self)) 35 36 self.added_polcaps, self.removed_polcaps, _ = self._set_diff( 37 (SymbolWrapper(n) for n in self.left_policy.polcaps()), 38 (SymbolWrapper(n) for n in self.right_policy.polcaps())) 39 40 # 41 # Internal functions 42 # 43 def _reset_diff(self): 44 """Reset diff results on policy changes.""" 45 self.log.debug("Resetting policy capability differences") 46 self.added_polcaps = None 47 self.removed_polcaps = None 48