aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-10-27 08:49:37 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-10-27 08:49:37 -0400
commit1b4913f371f5296292abbc608d0bbfe172cb6739 (patch)
tree96889a19e14c3b0b80da779a61e6318f9324dcde
parent86de8218b74e2b304071c66ba325485300f0451b (diff)
downloadb4-1b4913f371f5296292abbc608d0bbfe172cb6739.tar.gz
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 <greg@kroah.com> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r--b4/__init__.py8
1 files 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))