You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.4 KiB
49 lines
1.4 KiB
From ce89ed552ff6feb1ecc1c05269022913b5a8edcc Mon Sep 17 00:00:00 2001
|
|
From: Rob Crittenden <rcritten@redhat.com>
|
|
Date: Thu, 28 Apr 2022 08:46:02 -0400
|
|
Subject: [PATCH] Limit config file delimiters to =, catch empty values
|
|
|
|
ConfigParser allows both = and : as a delimiter. Limit to
|
|
just = to match the configuration file man page.
|
|
|
|
Don't allow empty values in options in the config file.
|
|
|
|
https://bugzilla.redhat.com/show_bug.cgi?id=2079739
|
|
|
|
Signed-off-by: Rob Crittenden <rcritten@redhat.com>
|
|
---
|
|
src/ipahealthcheck/core/config.py | 11 +++++++++--
|
|
1 file changed, 9 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/ipahealthcheck/core/config.py b/src/ipahealthcheck/core/config.py
|
|
index c4322a5..01c7722 100644
|
|
--- a/src/ipahealthcheck/core/config.py
|
|
+++ b/src/ipahealthcheck/core/config.py
|
|
@@ -87,7 +87,7 @@ def read_config(config_file):
|
|
)
|
|
return config
|
|
|
|
- parser = ConfigParser()
|
|
+ parser = ConfigParser(delimiters='=')
|
|
try:
|
|
parser.read(config_file)
|
|
except ParsingError as e:
|
|
@@ -102,6 +102,13 @@ def read_config(config_file):
|
|
items = parser.items(CONFIG_SECTION)
|
|
|
|
for (key, value) in items:
|
|
- config[key] = value
|
|
+ if len(value) == 0 or value is None:
|
|
+ logging.error(
|
|
+ "Empty value for %s in %s [%s]",
|
|
+ key, config_file, CONFIG_SECTION
|
|
+ )
|
|
+ return None
|
|
+ else:
|
|
+ config[key] = value
|
|
|
|
return config
|
|
--
|
|
2.31.1
|
|
|