From nobody Sun Feb 8 09:02:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+53169+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53169+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1578696841; cv=none; d=zohomail.com; s=zohoarc; b=JHuV+m6DLEqkpKhc+bEsu3rlggn4IWkpEsNf5WVXTzmXzX+FRPTOtHVLhRtbrBt8wg3JrResXYTczvGI/mr1FkrbUHmi1wpMxQ4NGNrdWpCgfPLKnRJdbC2qya/ooZ2alW99qyNLwS1OAQWmTGeYLpkeYfROcKunQDyytzGGPAo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578696841; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=rok+JgMixtc404+omh+OSewl9+USRS7ePDlyqq/o8p0=; b=IevvvDn79iByuOW8mpHvCGiYb3RGuGvJps+reNDOZ/OXDI0YYPVYeoMilQO/ahLLAHXMXzIlO6Rgqrzcx2mLKtXPCcJ0IfwP8Lgr+HWbf8iP1XNmA6eiczXMNcXCSiCtpwhyQQuyX5t/UTM/caFcQd3cEj7nx3+HONv8WkUm4YQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53169+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1578696841888744.4904061301371; Fri, 10 Jan 2020 14:54:01 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id LHM3YY1788612xD8yhltuILB; Fri, 10 Jan 2020 14:54:01 -0800 X-Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.877.1578696840424186636 for ; Fri, 10 Jan 2020 14:54:00 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jan 2020 14:53:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,418,1571727600"; d="scan'208";a="224333042" X-Received: from mdkinney-mobl2.amr.corp.intel.com ([10.255.229.97]) by orsmga003.jf.intel.com with ESMTP; 10 Jan 2020 14:53:59 -0800 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Bob Feng , Liming Gao , Laszlo Ersek , Jordan Justen Subject: [edk2-devel] [Patch] BaseTools/Scripts/PatchCheck: Address false error conditions Date: Fri, 10 Jan 2020 14:53:58 -0800 Message-Id: <20200110225358.8204-1-michael.d.kinney@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.d.kinney@intel.com X-Gm-Message-State: rMWWsmh46TH2dBSlkpeBejUOx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1578696841; bh=SDJVjb48SP4xvqrVC3O6zZjV5SSj/4+E5xIFBOzQS0g=; h=Cc:Date:From:Reply-To:Subject:To; b=B5BMFDQ2S3IP8yoz6A60seKhhvDZ6KLNMRlOyWqEQmzWpl27FgKX+5nXHLKmGSZ1EdH Llf5s2wWcsX9UPVRXHA64LrUbFAk5XHRKjgLtLV+sVKAO2kv484we2mrtt8/eV9Rxa1dY xBxON6Lxr9n01uQrACptUws60Ly43KGvXMM= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" https://bugzilla.tianocore.org/show_bug.cgi?id=3D2406 * Always print subject line after the git commit id to make it easier to know the context of warnings or errors. * Allow UTF-8 characters in subject line * Error if subject line length > 75 without CVE-xxx-xxxxx present * Error if subject line length > 92 with CVE-xxxx-xxxxx present * If body line length is > 75, then print warning instead of error. Cc: Bob Feng Cc: Liming Gao Cc: Laszlo Ersek Cc: Jordan Justen Signed-off-by: Michael D Kinney Reviewed-by: Bob Feng Tested-by (and with an R-b from a BaseTools maintainer, of course). Tested-by: Laszlo Ersek --- BaseTools/Scripts/PatchCheck.py | 57 +++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck= .py index 9668025798..ff4572bb7c 100755 --- a/BaseTools/Scripts/PatchCheck.py +++ b/BaseTools/Scripts/PatchCheck.py @@ -1,7 +1,7 @@ ## @file # Check a patch for various format issues # -# Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -35,6 +35,8 @@ class CommitMessageCheck: self.subject =3D subject self.msg =3D message =20 + print (subject) + self.check_contributed_under() self.check_signed_off_by() self.check_misc_signatures() @@ -179,6 +181,8 @@ class CommitMessageCheck: for sig in self.sig_types: self.find_signatures(sig) =20 + cve_re =3D re.compile('CVE-[0-9]{4}-[0-9]{5}[^0-9]') + def check_overall_format(self): lines =3D self.msg.splitlines() =20 @@ -196,9 +200,26 @@ class CommitMessageCheck: self.error('Empty commit message!') return =20 - if count >=3D 1 and len(lines[0].rstrip()) >=3D 72: - self.error('First line of commit message (subject line) ' + - 'is too long.') + if count >=3D 1 and re.search(self.cve_re, lines[0]): + # + # If CVE-xxxx-xxxxx is present in subject line, then limit len= gth of + # subject line to 92 characters + # + if len(lines[0].rstrip()) >=3D 93: + self.error( + 'First line of commit message (subject line) is too lo= ng (%d >=3D 93).' % + (len(lines[0].rstrip())) + ) + else: + # + # If CVE-xxxx-xxxxx is not present in subject line, then limit + # length of subject line to 75 characters + # + if len(lines[0].rstrip()) >=3D 76: + self.error( + 'First line of commit message (subject line) is too lo= ng (%d >=3D 76).' % + (len(lines[0].rstrip())) + ) =20 if count >=3D 1 and len(lines[0].strip()) =3D=3D 0: self.error('First line of commit message (subject line) ' + @@ -212,7 +233,14 @@ class CommitMessageCheck: if (len(lines[i]) >=3D 76 and len(lines[i].split()) > 1 and not lines[i].startswith('git-svn-id:')): - self.error('Line %d of commit message is too long.' % (i += 1)) + # + # Print a warning if body line is longer than 75 characters + # + print( + 'WARNING - Line %d of commit message is too long (%d >= =3D 76).' % + (i + 1, len(lines[i])) + ) + print(lines[i]) =20 last_sig_line =3D None for i in range(count - 1, 0, -1): @@ -503,8 +531,25 @@ class CheckOnePatch: else: self.stat =3D mo.group('stat') self.commit_msg =3D mo.group('commit_message') + # + # Parse subject line from email header. The subject line may be + # composed of multiple parts with different encodings. Decode and + # combine all the parts to produce a single string with the conten= ts of + # the decoded subject line. + # + parts =3D email.header.decode_header(pmail.get('subject')) + subject =3D '' + for (part, encoding) in parts: + if encoding: + part =3D part.decode(encoding) + else: + try: + part =3D part.decode() + except: + pass + subject =3D subject + part =20 - self.commit_subject =3D pmail['subject'].replace('\r\n', '') + self.commit_subject =3D subject.replace('\r\n', '') self.commit_subject =3D self.commit_subject.replace('\n', '') self.commit_subject =3D self.subject_prefix_re.sub('', self.commit= _subject, 1) =20 --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#53169): https://edk2.groups.io/g/devel/message/53169 Mute This Topic: https://groups.io/mt/69610631/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-