From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web12.3318.1591512574455304515 for ; Sat, 06 Jun 2020 23:49:35 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=eOhMf2Bz; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: liming.gao@intel.com) IronPort-SDR: tZVD4N6NDtcIS1WrB9HlF0MGiX2C99fNrOiyLTjxYNIjCXlHzx9aG8PEQicVJZ9JGyZTN/wfzJ GaWwpWm7nNUA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2020 23:49:33 -0700 IronPort-SDR: Bq2e9593fUSPZ0Mr76PC9HVB87Kmu7UCG8n2Ppg8jdKWHJRZHbl6uLaVoDp/d43Wg8jmB8pJsY mebWCf0fWGPQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,483,1583222400"; d="scan'208";a="273900229" Received: from orsmsx107.amr.corp.intel.com ([10.22.240.5]) by orsmga006.jf.intel.com with ESMTP; 06 Jun 2020 23:49:33 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by ORSMSX107.amr.corp.intel.com (10.22.240.5) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sat, 6 Jun 2020 23:49:32 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.102) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sat, 6 Jun 2020 23:49:33 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C/A4q7V9SJ+uyIHUD4b3UH5Ye7vF9tMEPe9a6EYUZ4u6WeHFcopX8GYC+HxkuyPAI8F0onz5bwXPj3v+LSANw4yXDQa7W4a/WZJStIIH9hnHNEoY1jM/dc6iwyaWdH9acov6/NnE4qKeu/bAs8gleJgD7kFNUnl6ozgZB+sFYDHK6lw8ZrvfCJiGyFtRybbHGENXgRKG3c4B//CB7u4bIIOAu+Z5hjdO+UokDWUVFwTXdTm8jy5Md0fBZ8NJcybwawlVWFp87xBJKcx9jKda5eDbh7e0Wn0nEmqwaqtK80+pKvqq35yUZq6cJL2kRvpD96O4SUia/zHSvNcKZJW6Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2XUxdHCuz4GSi/y5WB7aW5gUloUj3NIqXMdEsyLOqbg=; b=c1dIaNEZwGSGIFzrMWHr4hEtt/SHLgxUgEuow4GIsN8mOr9cabcIQwmScF2FYo5d+0iOjTixk9FTFeEnBdDoaYdGoPmjrCjinKnqAISx2cd64UVLdvW7uE7jy/gHG3Pt37YXhCh4SSTf3dLapWyCaRmAL4zzfhl37Vh5opALMfuWly6fWLRWenjk4aJWxgVi+Lo4iRt4KN8Zu2ITwSyMsVnq0ottu0N+56mwFror3DB4tEJKD1C9Gw43Szd1el80wwjeM/d8+oN22s2kcaCbgErpZKtnRgQdOgUIy9vLdHontqjyq9KR0Ez+Y1bPPqyFxXAjtyg1f2GGfDfPSApepw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2XUxdHCuz4GSi/y5WB7aW5gUloUj3NIqXMdEsyLOqbg=; b=eOhMf2BzF9/Q9PkpJtI1IxoaNifvkZeOT+Y4PuuwiR20TV5DizPzXfTuYBsj9uInzKnY7XzG5L2FP+Qya+JHttD3pzZi10wxPVcK41dYFXVP7hdwMcslepsFwirOZEKJhkUVaJ2uRIdG3bvP7B+MgM9o3G6wiIkhoQL/DTbXSwY= Received: from MWHPR11MB1630.namprd11.prod.outlook.com (2603:10b6:301:e::7) by MWHPR11MB1535.namprd11.prod.outlook.com (2603:10b6:301:d::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18; Sun, 7 Jun 2020 06:49:30 +0000 Received: from MWHPR11MB1630.namprd11.prod.outlook.com ([fe80::50fb:d63c:5958:a67e]) by MWHPR11MB1630.namprd11.prod.outlook.com ([fe80::50fb:d63c:5958:a67e%7]) with mapi id 15.20.3066.023; Sun, 7 Jun 2020 06:49:30 +0000 From: "Liming Gao" To: "Zhang, Shenglei" , "devel@edk2.groups.io" CC: "Feng, Bob C" Subject: Re: [PATCH v4] BaseTools/PatchCheck.py: Add LicenseCheck Thread-Topic: [PATCH v4] BaseTools/PatchCheck.py: Add LicenseCheck Thread-Index: AQHWOxq+gZ+CpeEwq0uCYepW4IYqz6jMuVpw Date: Sun, 7 Jun 2020 06:49:30 +0000 Message-ID: References: <20200605092138.32660-1-shenglei.zhang@intel.com> In-Reply-To: <20200605092138.32660-1-shenglei.zhang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.2.0.6 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.52.205] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 40140f6a-13e2-41c7-88fb-08d80aaeedf0 x-ms-traffictypediagnostic: MWHPR11MB1535: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 04270EF89C x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: RwVEORjgW6x/J7RL3pDcTymM3uvmmBWMcVfxIVomUYk9CbpybdVRDmkMx0dG2SzUfEpfDLU5v+c9E9pVO23KsmxZAz+cSNkmkjU5QjpAMwgJo6mSegUKATdsMLBjkbACbDidMtYIZcjlXu8GI79yORydVtlXDeEy15Rkj9R3p/sKJuMzzc4ber6vp/QObV/BYM6Xlsl205ZtKt5bLc2y12cwFawsJz687MQw88e8Le8wUIYfhsick7MdT3YKvE2g5mwa0ooZgRyH/fq9j6P2oJgdI6Nsr5uWxcgqxGDKegm33hcFFMO0UEKXpOlvP0wlfRfbx3FKs6ItthKbPasKhwxTNpJ3AbVq6fJACfUz/0+hUwbVqd/imNhZrd6nohGs/xvP7aUxjhv/2OYWOGaeHg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR11MB1630.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(396003)(346002)(376002)(136003)(39860400002)(366004)(2906002)(52536014)(8676002)(76116006)(33656002)(71200400001)(86362001)(8936002)(5660300002)(55016002)(66946007)(26005)(53546011)(6506007)(186003)(7696005)(66446008)(966005)(478600001)(66556008)(66476007)(64756008)(316002)(9686003)(4326008)(107886003)(83380400001)(110136005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: AwK9sNCqsDH1QobosFpkopPre3jGWwF3IsJ3DwnT/0VR3p9d8llLwrm42Q8WJHfIDWBlplMmH3zq0EIF5QYdqb3W9pkLjJbUadhcqACMBQ4x2fFva4w2kTx95OYFPfU2PRGiINdBry860wP2ERG6Zsv7zpa4zHuRdvDg2x6DhQi7xfywR1Ytzgg6+Go5cIvYMUQudNhl0eQcKeQKJ64IvR9w6EB2Zv9DgNHsO8yjfjSXvM9PAifY3ZzjpQSJ6y5OPNfZlbtOS3McPklQMjYKB7OsUbVA+JLoLENrvLTDRjg4frbbJAp6oTIyEhjKUiC21MlvQquWTbgMX0EF2dNQdfHo4GQReQmE7i0bbgrH4iPvf2EmjhhwXaU/UKK/xvOlqAHe8BhEdozTzdIseDXRDVj9BQhKp1LG5lTlJaumH+UMTBKlgVGye5wTAlSpYRqVWUXO9QXBGXV2BOSwVr/ricYGf1bFsc8oyEpCSIS0QCc= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 40140f6a-13e2-41c7-88fb-08d80aaeedf0 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Jun 2020 06:49:30.2857 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: nbmeYnuJEdZ5FB/1gKjkXB9HlLSGGOGv2snL5le0s5UX+z/QbjN8UWhIlxGdZfDufaPVlxP1HVL5WVrAv4WWSA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1535 Return-Path: liming.gao@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: Zhang, Shenglei > Sent: Friday, June 5, 2020 5:22 PM > To: devel@edk2.groups.io > Cc: Feng, Bob C ; Gao, Liming > Subject: [PATCH v4] BaseTools/PatchCheck.py: Add LicenseCheck >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2691 > For files to be added to the tree, this feature will check > whether it has BSD plus patent license. If not, licenses listed in > Readme are also accepted but warning will be reported. > Otherwise, it should be error. >=20 > Cc: Bob Feng > Cc: Liming Gao > Signed-off-by: Shenglei Zhang > --- > v2: Update handling methods for different licenses. >=20 > v3: Change the position of LicenseCheck(). No functional > update. >=20 > v4: Extend the scope of file types to scan. >=20 > BaseTools/Scripts/PatchCheck.py | 50 +++++++++++++++++++++++++++++++++ > 1 file changed, 50 insertions(+) >=20 > diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchChe= ck.py > index 13da6967785d..106b434c750d 100755 > --- a/BaseTools/Scripts/PatchCheck.py > +++ b/BaseTools/Scripts/PatchCheck.py > @@ -304,12 +304,49 @@ class GitDiffCheck: > self.line_num =3D 0 > self.state =3D START > self.new_bin =3D [] > + self.LicenseCheck(self.lines, self.count) > while self.line_num < self.count and self.format_ok: > line_num =3D self.line_num > self.run() > assert(self.line_num > line_num) > self.report_message_result() >=20 > + def LicenseCheck(self, lines, count): > + self.ok =3D True > + self.startcheck =3D False > + self.license =3D True > + line_index =3D 0 > + for line in lines: > + if line.startswith('--- /dev/null'): > + nextline =3D lines[line_index + 1] > + added_file =3D self.Readdedfileformat.search(nextline).g= roup(1) > + added_file_extension =3D os.path.splitext(added_file)[1] > + if added_file_extension in self.file_extension_list: > + self.startcheck =3D True > + self.license =3D False > + if self.startcheck and self.license_format_preflix in line: > + if self.bsd2_patent in line or self.bsd3_patent in line: > + self.license =3D True > + else: > + for optional_license in self.license_optional_list: > + if optional_license in line: > + self.license =3D True > + self.warning(added_file) > + if line_index + 1 =3D=3D count or lines[line_index + 1].star= tswith('diff --') and self.startcheck: > + if not self.license: > + error_message =3D "Invalid License in: " + added_fil= e > + self.error(error_message) > + self.startcheck =3D False > + self.license =3D True > + line_index =3D line_index + 1 > + > + def warning(self, *err): > + count =3D 0 > + for line in err: > + warning_format =3D 'Warning: License accepted but not BSD pl= us patent license in' > + print(warning_format, line) > + count +=3D 1 > + > def report_message_result(self): > if Verbose.level < Verbose.NORMAL: > return > @@ -491,6 +528,19 @@ class GitDiffCheck: > print(prefix, line) > count +=3D 1 >=20 > + license_format_preflix =3D 'SPDX-License-Identifier' > + > + bsd2_patent =3D 'BSD-2-Clause-Patent' > + > + bsd3_patent =3D 'BSD-3-Clause-Patent' > + > + license_optional_list =3D ['BSD-2-Clause', 'BSD-3-Clause', 'MIT', 'P= ython-2.0', 'Zlib'] > + > + Readdedfileformat =3D re.compile(r'\+\+\+ b\/(.*)\n') > + > + file_extension_list =3D [".c", ".h", ".inf", ".dsc", ".dec", ".py", = ".bat", ".sh", ".uni", ".yaml", ".fdf", ".inc", "yml", ".asm", \ > + ".asm16", ".asl", ".vfr", ".s", ".S", ".aslc",= ".nasm", ".nasmb", ".idf", ".Vfr", ".H"] > + > class CheckOnePatch: > """Checks the contents of a git email formatted patch. >=20 > -- > 2.18.0.windows.1