From 35465fe21d7e342bf3f87c75ab88c4b81358620f Mon Sep 17 00:00:00 2001 From: Chris PeBenito Date: Thu, 15 Apr 2021 16:36:29 -0400 Subject: [PATCH] ConfigSetDescriptor: Fix parsing of multiline values. The parsing did not correctly handle newline and tab characters. Add a multiline value in the sechecker test config file to make sure this case is tested. Signed-off-by: Chris PeBenito --- ChangeLog | 2 ++ setools/checker/descriptors.py | 3 ++- tests/checker/checker-valid.ini | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b38a57c7..4e1ca480 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ + * Fix bug in sechecker parsing of multiline values. + *setools-4.4.0 (5 Mar 2021) * Updated policy representation to handle policydb version 33, compressed diff --git a/setools/checker/descriptors.py b/setools/checker/descriptors.py index 551b4d3b..84568221 100644 --- a/setools/checker/descriptors.py +++ b/setools/checker/descriptors.py @@ -16,6 +16,7 @@ # License along with SETools. If not, see # . # +import re from typing import Callable, Union from ..exception import InvalidCheckValue @@ -90,7 +91,7 @@ def __set__(self, obj, value): else: lookup = getattr(obj.policy, self.lookup_function) ret = set() - for item in (i for i in value.split(" ") if i): + for item in (i for i in re.split(r"\s", value) if i): try: o = lookup(item) if self.expand: diff --git a/tests/checker/checker-valid.ini b/tests/checker/checker-valid.ini index 2a25c53c..d601cfd7 100644 --- a/tests/checker/checker-valid.ini +++ b/tests/checker/checker-valid.ini @@ -7,7 +7,8 @@ attr = empty_source_attr desc = read only executables test check_type = ro_execs exempt_exec_domain = unconfined -exempt_write_domain = domain1 domain2 unconfined +exempt_write_domain = domain1 + domain2 unconfined [assertte] check_type = assert_te