From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 165161382C5 for ; Wed, 20 May 2020 03:43:13 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 58CE1E0905; Wed, 20 May 2020 03:43:12 +0000 (UTC) Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 51BDDE0905 for ; Wed, 20 May 2020 03:43:12 +0000 (UTC) Received: by mail-pf1-f180.google.com with SMTP id x13so899801pfn.11 for ; Tue, 19 May 2020 20:43:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TrH0Q1cZ80vRshC4VturPJ+s37e/6rqV+20T49sfGJc=; b=mHyazqZZUAvhpq2nWV4IgDZKK5BlPt5QKURCDJfgDTHoYis518OzCyK0Pd17IZvPnJ +eokzPFJ9dkx+9w/ZGdK8MHQqPCyvgQZM6ZJtATa98KRDsJHy5GeyDpJIfUYzHD5acO5 Tj87K3213AaZEHXMGZG8EIL+F3QcYkFeSPU0ei/7/mGaQmCBzqR5Up5Afpi5+hz74kt4 UobReB4ZjDsIEqDF0mRt0vCYjLT4cmkd6l8vd9hJ9Z0JCODby9TrEhw3o6VYqchw90jf jeKXiNmCMzxrDgBkUAh+ffzHZCxr2ULpMc2TvYl/t8whsZuBegkxYvET+sxSUe1u+yjH hKQQ== X-Gm-Message-State: AOAM531v94M9rMBLyzwWyDYityGyo6a4AD4dnTSfzMWwzmucNN92GzAE ODHvcvjaaelhdgeex1S5aQlbLi/4 X-Google-Smtp-Source: ABdhPJwoc/LZ6lyHnX//3/QM/DvDbXNEJfL5iRtG/xCEH4SZTEjdDcTxafak8AGYmo31ZaQFRUi1ig== X-Received: by 2002:a63:5717:: with SMTP id l23mr2129164pgb.217.1589946191060; Tue, 19 May 2020 20:43:11 -0700 (PDT) Received: from localhost ([134.134.137.77]) by smtp.gmail.com with ESMTPSA id r2sm757451pfq.194.2020.05.19.20.43.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 20:43:10 -0700 (PDT) From: Matt Turner To: gentoo-catalyst@lists.gentoo.org Cc: Matt Turner Subject: [gentoo-catalyst] [PATCH 15/21] catalyst: Verify config options against valid_config_file_values Date: Tue, 19 May 2020 20:42:20 -0700 Message-Id: <20200520034226.2870937-15-mattst88@gentoo.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200520034226.2870937-1-mattst88@gentoo.org> References: <20200520034226.2870937-1-mattst88@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-catalyst@lists.gentoo.org Reply-to: gentoo-catalyst@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archives-Salt: 4580fb59-fd5c-4440-8995-0d098c5e8790 X-Archives-Hash: 1cb2816cbcc80050cc528cc2bb72ddc5 Signed-off-by: Matt Turner --- catalyst/main.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/catalyst/main.py b/catalyst/main.py index 159fe454..543895c6 100644 --- a/catalyst/main.py +++ b/catalyst/main.py @@ -15,7 +15,8 @@ from DeComp.contents import ContentsMap from catalyst import log import catalyst.config -from catalyst.defaults import confdefaults, option_messages, DEFAULT_CONFIG_FILE +from catalyst.defaults import (confdefaults, option_messages, + DEFAULT_CONFIG_FILE, valid_config_file_values) from catalyst.support import CatalystError from catalyst.version import get_version @@ -34,7 +35,12 @@ def parse_config(config_files): for config_file in config_files: log.notice('Loading configuration file: %s', config_file) try: - conf_values.update(toml.load(config_file)) + config = toml.load(config_file) + for key in config: + if key not in valid_config_file_values: + log.critical("Unknown option '%s' in config file %s", + key, config_file) + conf_values.update(config) except Exception as e: log.critical('Could not find parse configuration file: %s: %s', config_file, e) -- 2.26.2