Skip to contentSkip to conversation

merge/pull Check for untrusted good GPG signatures

PATCH Superseded Sebastian Götte 1 participant 1 message Jun 15, 2016

v2 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 3/4 merge/pull Check for untrusted good GPG signatures

When --verify-signatures is specified, abort the merge in case a good GPG signature from an untrusted key is encountered.

---
 builtin/merge.c                    |   2 ++
 commit.c                           |   1 +
 commit.h                           |   4 ++--
 gpg-interface.h                    |   2 +-
 t/lib-gpg/pubring.gpg              | Bin 1164 -> 2359 bytes
 t/lib-gpg/random_seed              | Bin 600 -> 600 bytes
 t/lib-gpg/secring.gpg              | Bin 1237 -> 3734 bytes
 t/lib-gpg/trustdb.gpg              | Bin 1280 -> 1360 bytes
 t/t7612-merge-verify-signatures.sh |   9 +++++++++
 9 files changed, 15 insertions(+), 3 deletions(-)
builtin/merge.c +2 -0
index b3788aa..42480e7 100644
@@ -1251,6 +1251,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 					if (verbosity >= 0)
 						printf(_("Commit %s has a good GPG signature by %s\n"), hex, signature.signer);
 					break;
+				case 'U':
+					die(_("Commmit %s has a good GPG signature allegedly by %s, albeit from an untrusted key."), hex, signature.signer);
 				case 'B':
 					die(_("Commmit %s has a bad GPG signature allegedly by %s."), hex, signature.signer);
 				default: /* 'N' */
commit.c +1 -0
index d0d9135..300cf98 100644
@@ -1027,6 +1027,7 @@ static struct {
 	char result;
 	const char *check;
 } signature_check[] = {
+	{ 'U', ": WARNING: This key is not certified with a trusted signature!" },
 	{ 'G', ": Good signature from " },
 	{ 'B', ": BAD signature from " },
 };
commit.h +2 -2
index eada616..2189eb6 100644
@@ -233,8 +233,8 @@ extern void print_commit_list(struct commit_list *list,
 
 /*
  * Check the signature of the given commit. The result of the check is stored in
- * sig->check_result, 'G' for a good signature, 'B' for a bad signature and 'N'
- * for no signature at all.
+ * sig->check_result, 'G' for a good signature, 'U' for a good signature from an
+ * untrusted signer, 'B' for a bad signature and 'N' for no signature at all.
  * This may allocate memory for sig->gpg_output and sig->signer.
  */
 extern void check_commit_signature(const struct commit* commit, struct signature *sig);
gpg-interface.h +1 -1
index c69130f..cbdaf3a 100644
@@ -3,7 +3,7 @@
 
 struct signature {
 	char *gpg_output;
-	char check_result; /* 0 (not checked), N (checked but no further result), G (good) or B (bad) */
+	char check_result; /* 0 (not checked), N (checked but no further result), U (untrusted, good), G (good) or B (bad) */
 	char *signer;
 };
 
t/lib-gpg/pubring.gpg binary +0 -0
index 83855fa4e1c6c37afe550c17afa1e7971042ded5..1a3c2d487c2fda9169751a3068fa51e853a1e519 100644
GIT binary patch
t/lib-gpg/random_seed binary +0 -0
index 8fed1339ed0a744e5663f4a5e6b6ac9bae3d8524..95d249f15fce980f0e8c1a8a18b085b3885708aa 100644
GIT binary patch
t/lib-gpg/secring.gpg binary +0 -0
index d831cd9eb3eee613d3c0e1a71093ae01ea7347e3..82dca8f80bf170fde5705862c3eeb9d994725042 100644
GIT binary patch
t/lib-gpg/trustdb.gpg binary +0 -0
index abace962b8bf84be688a6f27e4ebd0ee7052f210..4879ae9a84650a93a4d15bd6560c5d1b89eb4c2f 100644
GIT binary patch
t/t7612-merge-verify-signatures.sh +9 -0
index 31b67dd..47a4f80 100755
@@ -27,6 +27,10 @@ test_expect_success GPG 'create signed commits' '
 	git hash-object -w -t commit forged >forged.commit &&
 	git checkout initial &&
 
+	git checkout -b side-untrusted &&
+	echo 3 >baz && git add baz &&
+	test_tick && git commit -SB7227189 -m "untrusted on side"
+
 	git checkout master
 '
 
@@ -40,6 +44,11 @@ test_expect_success GPG 'merge commit with bad signature with verification' '
 	grep "has a bad GPG signature" mergeerror
 '
 
+test_expect_success GPG 'merge  commit with untrusted signature with verification' '
+	test_must_fail git merge --ff-only --verify-signatures side-untrusted 2> mergeerror &&
+	grep "from an untrusted key" mergeerror
+'
+
 test_expect_success GPG 'merge signed commit with verification' '
 	git merge -v --ff-only --verify-signatures side-signed > mergeoutput &&
 	grep "has a good GPG signature" mergeoutput
Signature · 1 line
1.8.1.5