From 852e334191af5b6bc6825424acc5cfed3891272d Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Tue, 7 Jul 2020 12:28:56 -0400 Subject: Fix attestation error messages Fix a crash when multiple patches fail attestation. Also fixes fancy chechmarks. Reported-by: Christian Brauner Signed-off-by: Konstantin Ryabitsev --- b4/__init__.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/b4/__init__.py b/b4/__init__.py index 37121be..5c2de31 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -39,7 +39,7 @@ FILENAME_RE = re.compile(r'^(---|\+\+\+) (\S+)') PASS_SIMPLE = '[P]' FAIL_SIMPLE = '[F]' PASS_FANCY = '[\033[32m\u2713\033[0m]' -FAIL_FANCY = '[\033[31m\u2717\034[0m]' +FAIL_FANCY = '[\033[31m\u2717\033[0m]' # You can use bash-style globbing here WANTHDRS = [ @@ -521,15 +521,22 @@ class LoreSeries: if attpolicy in ('softfail', 'hardfail'): logger.info(' %s %s', attfail, lmsg.full_subject) # Which part failed? - failed = ['commit metadata', 'commit message', 'patch content'] + fi = fm = fp = True for attdoc in ATTESTATIONS: for i, m, p in attdoc.hashes: if p == lmsg.attestation.p: - failed.remove('patch content') + fp = False if m == lmsg.attestation.m: - failed.remove('commit message') + fm = False if i == lmsg.attestation.i: - failed.remove('commit metadata') + fi = False + failed = list() + if fp: + failed.append('patch content') + if fm: + failed.append('commit message') + if fi: + failed.append('patch metadata') atterrors.append('Patch %s/%s failed attestation (%s)' % (at, lmsg.expected, ', '.join(failed))) else: -- cgit v1.2.3