public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Wynn Wolf Arbor <wolf@oriole.systems>
To: gentoo-portage-dev@lists.gentoo.org
Cc: Wynn Wolf Arbor <wolf@oriole.systems>
Subject: [gentoo-portage-dev] [PATCH 2/2] git: Verify boolean values passed to sync-git-verify-commit-signature
Date: Thu,  2 Jul 2020 17:50:18 +0200	[thread overview]
Message-ID: <20200702155018.82993-3-wolf@oriole.systems> (raw)
In-Reply-To: <20200702155018.82993-1-wolf@oriole.systems>

Currently, if 'sync-git-verify-commit-signature' is set to anything
other than 'yes', 'no', 'true', or 'false', its value is ignored
silently and nothing is verified because the option defaults to 'false'.

Introduce a check to CheckGitConfig that warns the user if their input
is invalid.

Closes: https://bugs.gentoo.org/703698
Signed-off-by: Wynn Wolf Arbor <wolf@oriole.systems>
---
 lib/portage/sync/modules/git/__init__.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/lib/portage/sync/modules/git/__init__.py b/lib/portage/sync/modules/git/__init__.py
index 270d97186..913e391cb 100644
--- a/lib/portage/sync/modules/git/__init__.py
+++ b/lib/portage/sync/modules/git/__init__.py
@@ -14,6 +14,7 @@ class CheckGitConfig(CheckSyncConfig):
 	def __init__(self, repo, logger):
 		CheckSyncConfig.__init__(self, repo, logger)
 		self.checks.append('check_depth')
+		self.checks.append('check_verify_commit_signature')
 
 	def check_depth(self):
 		for attr in ('clone_depth', 'sync_depth'):
@@ -33,6 +34,16 @@ class CheckGitConfig(CheckSyncConfig):
 			else:
 				setattr(self.repo, attr, d)
 
+	def check_verify_commit_signature(self):
+		v = self.repo.module_specific_options.get(
+			'sync-git-verify-commit-signature', 'false')
+
+		if v not in ['yes', 'no', 'true', 'false']:
+			writemsg_level("!!! %s\n" %
+				_("sync-git-verify-commit-signature not one of: %s")
+				% ('{yes, no, true, false}'),
+				level=self.logger.ERROR, noiselevel=-1)
+
 
 module_spec = {
 	'name': 'git',
-- 
2.27.0



  parent reply	other threads:[~2020-07-02 15:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-02 15:50 [gentoo-portage-dev] [PATCH 0/2] Use consistent list of booleans & validate verify-commit-signature Wynn Wolf Arbor
2020-07-02 15:50 ` [gentoo-portage-dev] [PATCH 1/2] repos.conf: Use consistent list of values for boolean options Wynn Wolf Arbor
2020-07-02 15:50 ` Wynn Wolf Arbor [this message]
2020-07-02 22:17 ` [gentoo-portage-dev] [PATCH 0/2] Use consistent list of booleans & validate verify-commit-signature Zac Medico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200702155018.82993-3-wolf@oriole.systems \
    --to=wolf@oriole.systems \
    --cc=gentoo-portage-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox