Gentoo Archives: gentoo-portage-dev

From: Wynn Wolf Arbor <wolf@××××××.systems>
To: gentoo-portage-dev@l.g.o
Cc: Wynn Wolf Arbor <wolf@××××××.systems>
Subject: [gentoo-portage-dev] [PATCH 2/2] git: Verify boolean values passed to sync-git-verify-commit-signature
Date: Thu, 02 Jul 2020 15:50:57
Message-Id: 20200702155018.82993-3-wolf@oriole.systems
In Reply to: [gentoo-portage-dev] [PATCH 0/2] Use consistent list of booleans & validate verify-commit-signature by Wynn Wolf Arbor
1 Currently, if 'sync-git-verify-commit-signature' is set to anything
2 other than 'yes', 'no', 'true', or 'false', its value is ignored
3 silently and nothing is verified because the option defaults to 'false'.
4
5 Introduce a check to CheckGitConfig that warns the user if their input
6 is invalid.
7
8 Closes: https://bugs.gentoo.org/703698
9 Signed-off-by: Wynn Wolf Arbor <wolf@××××××.systems>
10 ---
11 lib/portage/sync/modules/git/__init__.py | 11 +++++++++++
12 1 file changed, 11 insertions(+)
13
14 diff --git a/lib/portage/sync/modules/git/__init__.py b/lib/portage/sync/modules/git/__init__.py
15 index 270d97186..913e391cb 100644
16 --- a/lib/portage/sync/modules/git/__init__.py
17 +++ b/lib/portage/sync/modules/git/__init__.py
18 @@ -14,6 +14,7 @@ class CheckGitConfig(CheckSyncConfig):
19 def __init__(self, repo, logger):
20 CheckSyncConfig.__init__(self, repo, logger)
21 self.checks.append('check_depth')
22 + self.checks.append('check_verify_commit_signature')
23
24 def check_depth(self):
25 for attr in ('clone_depth', 'sync_depth'):
26 @@ -33,6 +34,16 @@ class CheckGitConfig(CheckSyncConfig):
27 else:
28 setattr(self.repo, attr, d)
29
30 + def check_verify_commit_signature(self):
31 + v = self.repo.module_specific_options.get(
32 + 'sync-git-verify-commit-signature', 'false')
33 +
34 + if v not in ['yes', 'no', 'true', 'false']:
35 + writemsg_level("!!! %s\n" %
36 + _("sync-git-verify-commit-signature not one of: %s")
37 + % ('{yes, no, true, false}'),
38 + level=self.logger.ERROR, noiselevel=-1)
39 +
40
41 module_spec = {
42 'name': 'git',
43 --
44 2.27.0