From patchwork Wed Jul 10 01:24:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Sangorrin X-Patchwork-Id: 11037695 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1190814C0 for ; Wed, 10 Jul 2019 01:34:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03E8C288E5 for ; Wed, 10 Jul 2019 01:34:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC65928900; Wed, 10 Jul 2019 01:34:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 92193288E5 for ; Wed, 10 Jul 2019 01:34:56 +0000 (UTC) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4A09D40C0; Wed, 10 Jul 2019 01:34:42 +0000 (UTC) X-Original-To: cip-dev@lists.cip-project.org Delivered-To: cip-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id DA93B3645 for ; Wed, 10 Jul 2019 01:25:08 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mo-csw.securemx.jp (mo-csw1114.securemx.jp [210.130.202.156]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id D47BC883 for ; Wed, 10 Jul 2019 01:25:06 +0000 (UTC) Received: by mo-csw.securemx.jp (mx-mo-csw1114) id x6A1OvIA009743; Wed, 10 Jul 2019 10:24:58 +0900 X-Iguazu-Qid: 2wGrVoDmKYTYN6kYEB X-Iguazu-QSIG: v=2; s=0; t=1562721897; q=2wGrVoDmKYTYN6kYEB; m=AHbe8hE5JIwwjhphG+7x0zc9gjad5M7ANWVdGaIOqKU= Received: from imx2.toshiba.co.jp (imx2.toshiba.co.jp [106.186.93.51]) by relay.securemx.jp (mx-mr1112) id x6A1Ourr029488; Wed, 10 Jul 2019 10:24:57 +0900 Received: from enc01.localdomain ([106.186.93.100]) by imx2.toshiba.co.jp with ESMTP id x6A1Ouqx019821; Wed, 10 Jul 2019 10:24:56 +0900 (JST) Received: from hop001.toshiba.co.jp ([133.199.164.63]) by enc01.localdomain with ESMTP id x6A1OurL025478; Wed, 10 Jul 2019 10:24:56 +0900 From: Daniel Sangorrin To: ben.hutchings@codethink.co.uk Date: Wed, 10 Jul 2019 10:24:47 +0900 X-TSB-HOP: ON Message-Id: <20190710012450.16524-4-daniel.sangorrin@toshiba.co.jp> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190710012450.16524-1-daniel.sangorrin@toshiba.co.jp> References: <20190710012450.16524-1-daniel.sangorrin@toshiba.co.jp> Cc: cip-dev@lists.cip-project.org Subject: [cip-dev] [cip-kernel-sec][RESEND 3/6] report_affected: fix code when branches are specified X-BeenThere: cip-dev@lists.cip-project.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: cip-dev-bounces@lists.cip-project.org Errors-To: cip-dev-bounces@lists.cip-project.org X-Virus-Scanned: ClamAV using ClamSMTP The previous code could not handle branches with names other than stable branch names. For example, passing "linux-4.4.y-cip" as a branch would return an error. Signed-off-by: Daniel Sangorrin --- scripts/kernel_sec/branch.py | 8 -------- scripts/report_affected.py | 23 +++++++++++++++++------ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/scripts/kernel_sec/branch.py b/scripts/kernel_sec/branch.py index 0023497..ef88b54 100644 --- a/scripts/kernel_sec/branch.py +++ b/scripts/kernel_sec/branch.py @@ -21,9 +21,6 @@ import yaml from . import version -_STABLE_BRANCH_RE = re.compile(r'^linux-([\d.]+)\.y$') - - def get_base_ver_stable_branch(base_ver): branch_name = 'linux-%s.y' % base_ver return { @@ -34,11 +31,6 @@ def get_base_ver_stable_branch(base_ver): } -def get_stable_branch(branch_name): - match = _STABLE_BRANCH_RE.match(branch_name) - return match and get_base_ver_stable_branch(match.group(1)) - - def _extract_live_stable_branches(doc): xhtml_ns = 'http://www.w3.org/1999/xhtml' ns = {'html': xhtml_ns} diff --git a/scripts/report_affected.py b/scripts/report_affected.py index d2f1f22..0ac27f6 100755 --- a/scripts/report_affected.py +++ b/scripts/report_affected.py @@ -18,14 +18,25 @@ import kernel_sec.version def main(git_repo, remotes, only_fixed_upstream, include_ignored, *branch_names): + live_branches = kernel_sec.branch.get_live_branches() if branch_names: - # Support stable release strings as shorthand for stable branches - branches = [kernel_sec.branch.get_base_ver_stable_branch(name) - if name[0].isdigit() - else kernel_sec.branch.get_stable_branch(name) - for name in branch_names] + branches = [] + for branch_name in branch_names: + if branch_name[0].isdigit(): + # 4.4 is mapped to linux-4.4.y + name = 'linux-%s.y' % branch_name + else: + name = branch_name + + for branch in live_branches: + if branch['short_name'] == name: + branches.append(branch) + break + else: + msg = "Branch %s could not be found" % branch_name + raise argparse.ArgumentError(None, msg) else: - branches = kernel_sec.branch.get_live_branches() + branches = live_branches if only_fixed_upstream: branches = [branch for branch in branches if branch['short_name'] != 'mainline']