summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-03-15 17:23:16 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-03-15 17:23:16 -0400
commita038fd7e12e6ca9cbb31e75d7ac63edb8a879f83 (patch)
treeb575ea4f10478b1b5cf6204c6e13c5a8191c540e
parentae57d6ea0b7abb7f945cac6010f5c9b28b041dde (diff)
downloadb4-a038fd7e12e6ca9cbb31e75d7ac63edb8a879f83.tar.gz
Tweak attestation parameters
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r--.gitignore3
-rw-r--r--b4/__init__.py3
-rw-r--r--b4/attest.py25
-rw-r--r--b4/command.py9
-rw-r--r--setup.py2
5 files changed, 24 insertions, 18 deletions
diff --git a/.gitignore b/.gitignore
index 68be5d4..a5e4883 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,6 @@ dist/*
MANIFEST
.idea
__pycache__
+*.egg-info
+*.patch
+*.mbx
diff --git a/b4/__init__.py b/b4/__init__.py
index 217508e..46c2ffc 100644
--- a/b4/__init__.py
+++ b/b4/__init__.py
@@ -660,7 +660,8 @@ class LoreMessage:
msg_out = mkstemp()
patch_out = mkstemp()
cmdargs = ['mailinfo', '--encoding=UTF-8', msg_out[1], patch_out[1]]
- ecode, info = git_run_command(None, cmdargs, self.msg.as_bytes())
+ emlout = self.msg.as_string(policy=emlpolicy)
+ ecode, info = git_run_command(None, cmdargs, emlout.encode('utf-8'))
if ecode > 0:
logger.debug('ERROR: Could not get mailinfo')
return
diff --git a/b4/attest.py b/b4/attest.py
index 16c2213..35c062b 100644
--- a/b4/attest.py
+++ b/b4/attest.py
@@ -12,7 +12,6 @@ import email.utils
import email.message
import smtplib
import mailbox
-
import b4
logger = b4.logger
@@ -22,12 +21,12 @@ def create_attestation(cmdargs):
attlines = list()
subject = 'Patch attestation'
for patchfile in cmdargs.patchfile:
- with open(patchfile, 'rb') as fh:
+ with open(patchfile, 'r', encoding='utf-8') as fh:
content = fh.read()
- if content.find(b'From') != 0:
+ if content.find('From') != 0:
logger.info('SKIP | %s', os.path.basename(patchfile))
continue
- msg = email.message_from_bytes(content)
+ msg = email.message_from_string(content)
lmsg = b4.LoreMessage(msg)
lmsg.load_hashes()
att = lmsg.attestation
@@ -81,7 +80,7 @@ def create_attestation(cmdargs):
att_msg['Subject'] = subject
logger.info('---')
- if not cmdargs.nomail:
+ if not cmdargs.nosubmit:
# Try to deliver it via mail.kernel.org
try:
mailserver = smtplib.SMTP('mail.kernel.org', 587)
@@ -139,15 +138,19 @@ def verify_attestation(cmdargs):
sys.exit(1)
logger.info('---')
- attpass = 'PASS'
- attfail = 'FAIL'
attrailers = set()
ecode = 1
+ if config['attestation-checkmarks'] == 'fancy':
+ attpass = b4.PASS_FANCY
+ attfail = b4.FAIL_FANCY
+ else:
+ attpass = b4.PASS_SIMPLE
+ attfail = b4.FAIL_SIMPLE
for lmsg in eligible:
attdoc = lmsg.get_attestation(lore_lookup=True, exact_from_match=exact_from_match)
if not attdoc:
- logger.critical('%s | %s', attfail, lmsg.full_subject)
+ logger.critical('%s %s', attfail, lmsg.full_subject)
if not cmdargs.nofast:
logger.critical('Aborting due to failure.')
ecode = 1
@@ -157,7 +160,7 @@ def verify_attestation(cmdargs):
continue
if ecode != 128:
ecode = 0
- logger.critical('%s | %s', attpass, lmsg.full_subject)
+ logger.critical('%s %s', attpass, lmsg.full_subject)
attrailers.add(attdoc.attestor.get_trailer(lmsg.fromemail))
logger.critical('---')
@@ -170,10 +173,10 @@ def verify_attestation(cmdargs):
logger.critical('---')
logger.critical('The validation process reported the following errors:')
for error in errors:
- logger.critical(' %s', error)
+ logger.critical(' %s %s', attfail, error)
else:
logger.critical('All patches passed attestation:')
for attrailer in attrailers:
- logger.critical(' %s', attrailer)
+ logger.critical(' %s %s', attpass, attrailer)
sys.exit(ecode)
diff --git a/b4/command.py b/b4/command.py
index 457115e..6830b92 100644
--- a/b4/command.py
+++ b/b4/command.py
@@ -85,12 +85,11 @@ def cmd():
# GDPR-proofing: by default, we add as little PII-sensitive info as possible
sp_att.add_argument('-f', '--from', dest='sender', default='devnull@kernel.org',
help='Use a custom From field')
- sp_att.add_argument('-o', '--output', default='xxxx-attestation-letter.patch',
- help='Save attestation message in this file')
- sp_att.add_argument('-n', '--no-mail', dest='nomail', action='store_true', default=False,
+ sp_att.add_argument('-n', '--no-submit', dest='nosubmit', action='store_true', default=False,
help='Do not submit attestation, just save the message ready to send')
- sp_att.add_argument('patchfile', nargs='+',
- help='Patches to attest')
+ sp_att.add_argument('-o', '--output', default='xxxx-attestation-letter.patch',
+ help='Save attestation message in this file if not submitting it')
+ sp_att.add_argument('patchfile', nargs='+', help='Patches to attest')
sp_att.set_defaults(func=cmd_attest)
# b4 verify
diff --git a/setup.py b/setup.py
index de9fabf..c8acc52 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
import os
-from distutils.core import setup
+from setuptools import setup
# Utility function to read the README file.
# Used for the long_description. It's nice, because now 1) we have a top level