From 1b4913f371f5296292abbc608d0bbfe172cb6739 Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Tue, 27 Oct 2020 08:49:37 -0400 Subject: Fix attestation code for base64-encoded messages We need to fix all legacy encodings before we pass an email to git-mailinfo. Additionally, even if that fails, don't crash on a missing attestation. Reported-by: Greg Kroah-Hartman Signed-off-by: Konstantin Ryabitsev --- b4/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/b4/__init__.py b/b4/__init__.py index f7486f8..7e38e13 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -519,8 +519,7 @@ class LoreSeries: if attpolicy != 'off': lmsg.load_hashes() latt = lmsg.attestation - latt.validate(lmsg.msg) - if latt.passing: + if latt and latt.validate(lmsg.msg): # Make sure it's not too old compared to the message date # Timezone doesn't matter as we calculate whole days tdelta = lmsg.date.replace(tzinfo=None) - latt.lsig.sigdate @@ -1124,7 +1123,8 @@ class LoreMessage: logger.debug('Calculating hashes for: %s', self.full_subject) # Calculate git-patch-id first cmdargs = ['patch-id', '--stable'] - stdin = self.msg.as_string(policy=emlpolicy).encode() + msg = self.get_am_message(add_trailers=False) + stdin = msg.as_string(policy=emlpolicy).encode() ecode, out = git_run_command(None, cmdargs, stdin) if ecode > 0: # Git doesn't think there's a patch there @@ -1675,6 +1675,8 @@ class LoreAttestation: if self.iv and self.mv and self.pv: self.passing = True + return self.passing + def _run_command(cmdargs, stdin=None): logger.debug('Running %s' % ' '.join(cmdargs)) -- cgit v1.2.3