aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2021-06-08 14:16:02 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2021-06-09 11:42:27 -0400
commitc3e9f1c0a1c32a8659cb7e98e35a1274d7be9827 (patch)
tree7e8d4dddda0cb0f349f77ef12798d32c78a789bd
parent68578c4c78e283f2c2fed21b96fae5079fab4022 (diff)
downloadb4-c3e9f1c0a1c32a8659cb7e98e35a1274d7be9827.tar.gz
Fix crasher on unsigned FETCH_HEAD
If the FETCH_HEAD is not signed, then keyid is going to be None. Don't attempt to look up UIDs in such situations. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r--b4/pr.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/b4/pr.py b/b4/pr.py
index 86d039c..d8ff7f4 100644
--- a/b4/pr.py
+++ b/b4/pr.py
@@ -141,18 +141,19 @@ def attest_fetch_head(gitdir, lmsg):
ecode, out = b4.git_run_command(gitdir, ['verify-commit', '--raw', 'FETCH_HEAD'], logstderr=True)
good, valid, trusted, keyid, sigtime = b4.check_gpg_status(out)
- try:
- uids = b4.get_gpg_uids(keyid)
- signer = None
- for uid in uids:
- if uid.find(f'<{lmsg.fromemail}') >= 0:
- signer = uid
- break
- if not signer:
- signer = uids[0]
-
- except KeyError:
- signer = f'{lmsg.fromname} <{lmsg.fromemail}'
+ signer = None
+ if keyid:
+ try:
+ uids = b4.get_gpg_uids(keyid)
+ for uid in uids:
+ if uid.find(f'<{lmsg.fromemail}') >= 0:
+ signer = uid
+ break
+ if not signer:
+ signer = uids[0]
+
+ except KeyError:
+ signer = f'{lmsg.fromname} <{lmsg.fromemail}>'
if good and valid:
passing = True