From fe7709834ccda006b5b3ea3d129727d49dd80ae5 Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Tue, 8 Jun 2021 14:16:02 -0400 Subject: 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 --- b4/pr.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/b4/pr.py b/b4/pr.py index 1e308d8..4782a8c 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 -- cgit v1.2.3