confini

Parse and merge multiple ini files in python3
git clone git://git.defalsify.org/python-confini.git
Log | Files | Refs | README | LICENSE

commit dde120dc326862f84eba956787bd4e95b04d8406
parent cd9ddc6c94572869936d6370cb5b4c60a39d167b
Author: nolash <dev@holbrook.no>
Date:   Sun, 31 Jan 2021 08:56:35 +0100

Avoid crash in decrypt when value is not string

Diffstat:
Mconfini/config.py | 3+++
Msetup.py | 2+-
Mtest/files/crypt/foo.ini | 1+
Mtest/test_enc.py | 11+++++++++++
4 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/confini/config.py b/confini/config.py @@ -131,6 +131,9 @@ class Config: def _decrypt(self, k, v): + if type(v).__name__ != 'str': + logg.debug('entry {} is not type str'.format(k)) + return v if self.decrypt: m = re.match(r'^\!gpg\((.*)\)', v) if m != None: diff --git a/setup.py b/setup.py @@ -6,7 +6,7 @@ f.close() setup( name='confini', - version='0.3.6a1', + version='0.3.6b1', description='Parse, verify and merge all ini files in a single directory', author='Louis Holbrook', author_email='dev@holbrook.no', diff --git a/test/files/crypt/foo.ini b/test/files/crypt/foo.ini @@ -1,3 +1,4 @@ [FOO] bar = 42 baz = !gpg(baz.asc) +xyzzy = diff --git a/test/test_enc.py b/test/test_enc.py @@ -31,6 +31,17 @@ class TestBasic(unittest.TestCase): c.get('FOO_BAZ') os.environ['GNUPGHOME'] = gnupg_dir c.get('FOO_BAZ') + + + def test_decrypt_with_non_string(self): + inidir = os.path.join(self.wd, 'files/crypt') + c = Config(inidir, decrypt=True) + c.process() + override = { + 'FOO_XYZZY': False, + } + c.dict_override(override, 'test') + c.get('FOO_XYZZY') if __name__ == '__main__': unittest.main()