From patchwork Wed Jul 10 01:24:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Sangorrin X-Patchwork-Id: 11037693 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 9171A14DB for ; Wed, 10 Jul 2019 01:34:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85372288E5 for ; Wed, 10 Jul 2019 01:34:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79A9D28900; Wed, 10 Jul 2019 01:34:51 +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 1F0B7288E5 for ; Wed, 10 Jul 2019 01:34:51 +0000 (UTC) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 30DE940BF; 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 A54673645 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-csw1115.securemx.jp [210.130.202.157]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id EFF57CF for ; Wed, 10 Jul 2019 01:25:07 +0000 (UTC) Received: by mo-csw.securemx.jp (mx-mo-csw1115) id x6A1OvpT002130; Wed, 10 Jul 2019 10:24:57 +0900 X-Iguazu-Qid: 2wGr73g3jC1l4JAxhA X-Iguazu-QSIG: v=2; s=0; t=1562721897; q=2wGr73g3jC1l4JAxhA; m=sI24+3LAO1rxUnGOYU1GolPWW/2YTY6Pp/+Db7SElHk= Received: from imx2.toshiba.co.jp (imx2.toshiba.co.jp [106.186.93.51]) by relay.securemx.jp (mx-mr1111) id x6A1Ot5u020241; Wed, 10 Jul 2019 10:24:56 +0900 Received: from enc01.localdomain ([106.186.93.100]) by imx2.toshiba.co.jp with ESMTP id x6A1OtZe019812; Wed, 10 Jul 2019 10:24:55 +0900 (JST) Received: from hop001.toshiba.co.jp ([133.199.164.63]) by enc01.localdomain with ESMTP id x6A1OtTi025473; Wed, 10 Jul 2019 10:24:55 +0900 From: Daniel Sangorrin To: ben.hutchings@codethink.co.uk Date: Wed, 10 Jul 2019 10:24:45 +0900 X-TSB-HOP: ON Message-Id: <20190710012450.16524-2-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 1/6] check_git_repo: add checks to the local repository 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 Add checks to make sure that the local repository exists and has the configured remotes in place. Signed-off-by: Daniel Sangorrin --- scripts/import_stable.py | 1 + scripts/kernel_sec/branch.py | 21 +++++++++++++++++++++ scripts/report_affected.py | 1 + scripts/webview.py | 1 + 4 files changed, 24 insertions(+) diff --git a/scripts/import_stable.py b/scripts/import_stable.py index 2c88b07..26fcc2f 100755 --- a/scripts/import_stable.py +++ b/scripts/import_stable.py @@ -190,4 +190,5 @@ if __name__ == '__main__': remotes = kernel_sec.branch.get_remotes(args.remote_name, mainline=args.mainline_remote_name, stable=args.stable_remote_name) + kernel_sec.branch.check_git_repo(args.git_repo, remotes) main(args.git_repo, remotes, args.debug) diff --git a/scripts/kernel_sec/branch.py b/scripts/kernel_sec/branch.py index 10f3339..a138b96 100644 --- a/scripts/kernel_sec/branch.py +++ b/scripts/kernel_sec/branch.py @@ -4,10 +4,12 @@ # Public License, Version 3 or later. See http://www.gnu.org/copyleft/gpl.html # for details. +import argparse import io import os import re import subprocess +import sys import time import urllib.error import urllib.request @@ -219,3 +221,22 @@ def get_remotes(mappings, mainline=None, stable=None): if stable: remotes['stable']['git_name'] = stable return remotes + + +def check_git_repo(git_repo, remotes): + if not os.path.isdir(git_repo): + msg = "directory %r not present" % git_repo + raise argparse.ArgumentError(None, msg) + # .git could be a regular file (worktrees) or a directory + if not os.path.exists(os.path.join(git_repo, '.git')): + msg = "directory %r is not a git repository" % git_repo + raise argparse.ArgumentError(None, msg) + + current_remotes = subprocess.check_output( + ['git', 'remote', 'show'], cwd=git_repo).decode( + sys.stdout.encoding).strip().split('\n') + for key in remotes.keys(): + remote = remotes[key] # __getitem__ will add git_name + if remote['git_name'] not in current_remotes: + msg = "remote %r not in git repository" % remote['git_name'] + raise argparse.ArgumentError(None, msg) diff --git a/scripts/report_affected.py b/scripts/report_affected.py index 879c021..d2f1f22 100755 --- a/scripts/report_affected.py +++ b/scripts/report_affected.py @@ -100,5 +100,6 @@ if __name__ == '__main__': remotes = kernel_sec.branch.get_remotes(args.remote_name, mainline=args.mainline_remote_name, stable=args.stable_remote_name) + kernel_sec.branch.check_git_repo(args.git_repo, remotes) main(args.git_repo, remotes, args.only_fixed_upstream, args.include_ignored, *args.branches) diff --git a/scripts/webview.py b/scripts/webview.py index a3a643b..52a7b15 100755 --- a/scripts/webview.py +++ b/scripts/webview.py @@ -219,6 +219,7 @@ if __name__ == '__main__': remotes = kernel_sec.branch.get_remotes(args.remote_name, mainline=args.mainline_remote_name, stable=args.stable_remote_name) + kernel_sec.branch.check_git_repo(args.git_repo, remotes) conf = { '/static/style.css': { From patchwork Wed Jul 10 01:24:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Sangorrin X-Patchwork-Id: 11037689 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 EA7B714DB for ; Wed, 10 Jul 2019 01:34:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDB02288E5 for ; Wed, 10 Jul 2019 01:34:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1AF62890F; Wed, 10 Jul 2019 01:34:43 +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 1FE16288E5 for ; Wed, 10 Jul 2019 01:34:43 +0000 (UTC) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id CE28640C1; Wed, 10 Jul 2019 01:34:41 +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 C6FDA2EDC for ; Wed, 10 Jul 2019 01:25:07 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mo-csw.securemx.jp (mo-csw1514.securemx.jp [210.130.202.153]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 820A0CF for ; Wed, 10 Jul 2019 01:25:06 +0000 (UTC) Received: by mo-csw.securemx.jp (mx-mo-csw1514) id x6A1Oumv003365; Wed, 10 Jul 2019 10:24:56 +0900 X-Iguazu-Qid: 34tMRO62N3Hf6RR6P5 X-Iguazu-QSIG: v=2; s=0; t=1562721896; q=34tMRO62N3Hf6RR6P5; m=2ixczuLmp18UqolXO/k0MgHrjU/A3MGMx0um2sH6SJM= Received: from imx12.toshiba.co.jp (imx12.toshiba.co.jp [61.202.160.132]) by relay.securemx.jp (mx-mr1512) id x6A1Ota2013324; Wed, 10 Jul 2019 10:24:56 +0900 Received: from enc02.toshiba.co.jp ([61.202.160.51]) by imx12.toshiba.co.jp with ESMTP id x6A1OtHA008646; Wed, 10 Jul 2019 10:24:55 +0900 (JST) Received: from hop101.toshiba.co.jp ([133.199.85.107]) by enc02.toshiba.co.jp with ESMTP id x6A1OtJg013621; Wed, 10 Jul 2019 10:24:55 +0900 From: Daniel Sangorrin To: ben.hutchings@codethink.co.uk Date: Wed, 10 Jul 2019 10:24:46 +0900 X-TSB-HOP: ON Message-Id: <20190710012450.16524-3-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 2/6] prepare_remotes: helper script to prepare local repo 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 Helper script that prepares the local git repository with the configured remote branches. Expert developers and kernel maintainers will probably have their own worktrees but for new users or a quickstart, this script should be helpful. Signed-off-by: Daniel Sangorrin --- README.md | 5 +++ conf/remotes.yml | 3 ++ scripts/import_stable.py | 8 ++--- scripts/kernel_sec/branch.py | 10 ++++++ scripts/prepare_remotes.py | 62 ++++++++++++++++++++++++++++++++++++ 5 files changed, 82 insertions(+), 6 deletions(-) create mode 100755 scripts/prepare_remotes.py diff --git a/README.md b/README.md index 4c5808f..576cc75 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,10 @@ this is assumed to be in `../kernel`, with remotes configured in stable and cip repositories. These can be overridden by command-line options or configuration (`~/.config/kernel-sec/remotes.yml`). +* `scripts/prepare_remotes.py` - creates the local git repository +and adds all configured remotes. You may prefer to skip this script +and configure the repository by hand. + * `scripts/import_debian.py` - import information from Debian's `kernel_sec` project. It includes all issues that Debian considers active or that are already tracked here. @@ -81,6 +85,7 @@ with the keys: branch from this remote. * `git_name`: (optional) The name actually used for this git remote, if it's different from the default. +* `git_repo_url`: URL of the remote git repository. ## Contributions diff --git a/conf/remotes.yml b/conf/remotes.yml index 51c523d..cfaa35f 100644 --- a/conf/remotes.yml +++ b/conf/remotes.yml @@ -1,6 +1,9 @@ torvalds: commit_url_prefix: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id= + git_repo_url: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git stable: commit_url_prefix: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit?id= + git_repo_url: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git cip: commit_url_prefix: https://git.kernel.org/pub/scm/linux/kernel/git/cip/linux-cip.git/commit?id= + git_repo_url: https://git.kernel.org/pub/scm/linux/kernel/git/cip/linux-cip.git diff --git a/scripts/import_stable.py b/scripts/import_stable.py index 26fcc2f..194219d 100755 --- a/scripts/import_stable.py +++ b/scripts/import_stable.py @@ -31,11 +31,6 @@ BACKPORT_COMMIT_BOTTOM_RE = re.compile( .format(**RE_USE)) -def update(git_repo, remote_name): - subprocess.check_call(['git', 'remote', 'update', remote_name], - cwd=git_repo) - - def get_backports(git_repo, remotes, branches, debug=False): backports = {} @@ -140,7 +135,8 @@ def main(git_repo, remotes, debug=False): remote_names = set(branch['git_remote'] for branch in branches) for remote_name in remote_names: - update(git_repo, remotes[remote_name]['git_name']) + kernel_sec.branch.remote_update( + git_repo, remotes[remote_name]['git_name']) backports = get_backports(git_repo, remotes, branches, debug) c_b_map = kernel_sec.branch.CommitBranchMap(git_repo, remotes, branches) diff --git a/scripts/kernel_sec/branch.py b/scripts/kernel_sec/branch.py index a138b96..0023497 100644 --- a/scripts/kernel_sec/branch.py +++ b/scripts/kernel_sec/branch.py @@ -223,6 +223,16 @@ def get_remotes(mappings, mainline=None, stable=None): return remotes +def remote_update(git_repo, remote_name): + subprocess.check_call(['git', 'remote', 'update', remote_name], + cwd=git_repo) + + +def remote_add(git_repo, remote_name, remote_url): + subprocess.check_call(['git', 'remote', 'add', remote_name, remote_url], + cwd=git_repo) + + def check_git_repo(git_repo, remotes): if not os.path.isdir(git_repo): msg = "directory %r not present" % git_repo diff --git a/scripts/prepare_remotes.py b/scripts/prepare_remotes.py new file mode 100755 index 0000000..59310fc --- /dev/null +++ b/scripts/prepare_remotes.py @@ -0,0 +1,62 @@ +#!/usr/bin/python3 + +# Copyright 2019 Toshiba corp. +# Based on import_stable.py by Codethink Ltd. +# +# This script is distributed under the terms and conditions of the GNU General +# Public License, Version 3 or later. See http://www.gnu.org/copyleft/gpl.html +# for details. + +# Helper script that prepares the local git repository with the configured +# remote branches + +import argparse +import os +import subprocess + +import kernel_sec.branch + + +def main(git_repo, remotes): + if os.path.isdir(git_repo): + msg = "directory %r already exists" % git_repo + raise argparse.ArgumentError(None, msg) + else: + os.mkdir(git_repo) + subprocess.check_call(['git', 'init', '.'], cwd=git_repo) + + for key in remotes.keys(): + remote = remotes[key] # __getitem__ will add git_name + kernel_sec.branch.remote_add( + git_repo, remote['git_name'], remote['git_repo_url']) + kernel_sec.branch.remote_update(git_repo, remote['git_name']) + + # self-check + kernel_sec.branch.check_git_repo(git_repo, remotes) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description=('Prepare local git repository with configured remotes.')) + parser.add_argument('--git-repo', + dest='git_repo', default='../kernel', + help=('local git repository location ' + '(default: ../kernel)'), + metavar='DIRECTORY') + parser.add_argument('--remote-name', + dest='remote_name', action='append', default=[], + help='git remote name mappings, e.g. stable:korg-stable', + metavar='NAME:OTHER-NAME') + parser.add_argument('--mainline-remote', + dest='mainline_remote_name', + help="git remote name to use instead of 'torvalds'", + metavar='OTHER-NAME') + parser.add_argument('--stable-remote', + dest='stable_remote_name', + help="git remote name to use instead of 'stable'", + metavar='OTHER-NAME') + args = parser.parse_args() + remotes = kernel_sec.branch.get_remotes(args.remote_name, + mainline=args.mainline_remote_name, + stable=args.stable_remote_name) + main(args.git_repo, remotes) 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'] From patchwork Wed Jul 10 01:24:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Sangorrin X-Patchwork-Id: 11037697 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 2412814DB for ; Wed, 10 Jul 2019 01:35:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 163E1288E5 for ; Wed, 10 Jul 2019 01:35:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A97F28900; Wed, 10 Jul 2019 01:35:09 +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 82942288E5 for ; Wed, 10 Jul 2019 01:35:08 +0000 (UTC) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 8C6DA40C4; 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 8664940B0 for ; Wed, 10 Jul 2019 01:25:09 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mo-csw.securemx.jp (mo-csw1116.securemx.jp [210.130.202.158]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 22E73887 for ; Wed, 10 Jul 2019 01:25:06 +0000 (UTC) Received: by mo-csw.securemx.jp (mx-mo-csw1116) id x6A1OwQU014451; Wed, 10 Jul 2019 10:24:58 +0900 X-Iguazu-Qid: 2wGrbTCrNNIavu1H1e X-Iguazu-QSIG: v=2; s=0; t=1562721898; q=2wGrbTCrNNIavu1H1e; m=T6TRSandT7fvkQiQJNY6ACUYhKzo8LEmmQwuHKQXL9s= Received: from imx2.toshiba.co.jp (imx2.toshiba.co.jp [106.186.93.51]) by relay.securemx.jp (mx-mr1110) id x6A1Ovlr026370; Wed, 10 Jul 2019 10:24:57 +0900 Received: from enc01.localdomain ([106.186.93.100]) by imx2.toshiba.co.jp with ESMTP id x6A1OvLt019833; Wed, 10 Jul 2019 10:24:57 +0900 (JST) Received: from hop001.toshiba.co.jp ([133.199.164.63]) by enc01.localdomain with ESMTP id x6A1OvdM025494; Wed, 10 Jul 2019 10:24:57 +0900 From: Daniel Sangorrin To: ben.hutchings@codethink.co.uk Date: Wed, 10 Jul 2019 10:24:48 +0900 X-TSB-HOP: ON Message-Id: <20190710012450.16524-5-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 4/6] report_affected: add support for reporting on tags 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 Reporting on tags is useful for product engineers that have shipped a kernel with a specific tag and need to know which issues affect their product after some time. Examples: $ ./scripts/report_affected.py linux-4.14.y linux-4.4.y:v4.4.107 v4.4.181-cip33 $ cd ../kernel $ git tag myproduct-v1 0f13d9b4d0efa9e87381717c113df57718bc92d6 $ cd ../cip-kernel-sec $ ./scripts/report_affected.py linux-4.19.y-cip:myproduct-v1 v4.19.50-cip3 Signed-off-by: Daniel Sangorrin --- conf/branches.yml | 2 + scripts/kernel_sec/branch.py | 4 +- scripts/report_affected.py | 77 +++++++++++++++++++++++++++++++----- 3 files changed, 72 insertions(+), 11 deletions(-) diff --git a/conf/branches.yml b/conf/branches.yml index 2ed9db6..8197596 100644 --- a/conf/branches.yml +++ b/conf/branches.yml @@ -2,7 +2,9 @@ base_ver: "4.4" git_remote: cip git_name: linux-4.4.y-cip + tag_regexp: '^v4\.4\.\d+-cip\d+$' - short_name: linux-4.19.y-cip base_ver: "4.19" git_remote: cip git_name: linux-4.19.y-cip + tag_regexp: '^v4\.19\.\d+-cip\d+$' diff --git a/scripts/kernel_sec/branch.py b/scripts/kernel_sec/branch.py index ef88b54..96f1cab 100644 --- a/scripts/kernel_sec/branch.py +++ b/scripts/kernel_sec/branch.py @@ -141,7 +141,7 @@ def get_sort_key(branch): return version.get_sort_key(base_ver) -def _get_commits(git_repo, end, start=None): +def iter_rev_list(git_repo, end, start=None): if start: list_expr = '%s..%s' % (start, end) else: @@ -170,7 +170,7 @@ class CommitBranchMap: branch['git_name']) else: end = 'v' + branch['base_ver'] - for commit in _get_commits(git_repo, end, start): + for commit in iter_rev_list(git_repo, end, start): self._commit_sort_key[commit] \ = self._branch_sort_key[branch_name] start = end diff --git a/scripts/report_affected.py b/scripts/report_affected.py index 0ac27f6..7ec4af7 100755 --- a/scripts/report_affected.py +++ b/scripts/report_affected.py @@ -9,7 +9,9 @@ # Report issues affecting each stable branch. import argparse +import copy import subprocess +import re import kernel_sec.branch import kernel_sec.issue @@ -22,15 +24,47 @@ def main(git_repo, remotes, if branch_names: branches = [] for branch_name in branch_names: + tag = None if branch_name[0].isdigit(): # 4.4 is mapped to linux-4.4.y name = 'linux-%s.y' % branch_name + elif branch_name[0] == 'v': + # an official tag, e.g. v4.4.92-cip11 + # infer branch from tag (regexp's must be specific) + for branch in live_branches: + if 'tag_regexp' in branch: + # predefined in conf/branches.yml + tag_regexp = branch['tag_regexp'] + elif branch['git_remote'] == 'stable': + # stable format, e.g. v4.19.12 + esc_base_ver = branch['base_ver'].replace('.', '\.') + tag_regexp = r'(^v%s$|^v%s\.\d+$)' % ( + esc_base_ver, esc_base_ver) + else: + # no tag_regexp defined, or mainline + continue + + if re.match(tag_regexp, branch_name): + tag = branch_name + name = branch['short_name'] + break + else: + raise ValueError('Failed to match tag %r' % branch_name) + elif ':' in branch_name: + # a possibly custom tag, e.g. linux-4.19.y-cip:myproduct-v1 + name_tuple = tuple(branch_name.split(':')) + name = name_tuple[0] + tag = name_tuple[1] else: name = branch_name for branch in live_branches: if branch['short_name'] == name: - branches.append(branch) + # there could be multiple tags for the same branch + branch_copy = copy.deepcopy(branch) + if tag: + branch_copy['tag'] = tag + branches.append(branch_copy) break else: msg = "Branch %s could not be found" % branch_name @@ -45,6 +79,18 @@ def main(git_repo, remotes, c_b_map = kernel_sec.branch.CommitBranchMap(git_repo, remotes, branches) + # cache tag commits and set full_name to show the tag + tag_commits = {} + for branch in branches: + if 'tag' in branch: + start = 'v' + branch['base_ver'] + end = branch['tag'] + tag_commits[end] = set( + kernel_sec.branch.iter_rev_list(git_repo, end, start)) + branch['full_name'] = ':'.join([branch['short_name'], end]) + else: + branch['full_name'] = branch['short_name'] + branch_issues = {} issues = set(kernel_sec.issue.get_list()) @@ -65,15 +111,26 @@ def main(git_repo, remotes, if not include_ignored and ignore.get(branch_name): continue + # Check if the branch is affected. If not and the issue was fixed + # on that branch, then make sure the tag contains that fix if kernel_sec.issue.affects_branch( issue, branch, c_b_map.is_commit_in_branch): - branch_issues.setdefault(branch_name, []).append(cve_id) + branch_issues.setdefault( + branch['full_name'], []).append(cve_id) + elif 'tag' in branch and fixed: + if fixed.get(branch_name, 'never') == 'never': + continue + for commit in fixed[branch_name]: + if commit not in tag_commits[branch['tag']]: + branch_issues.setdefault( + branch['full_name'], []).append(cve_id) + break for branch in branches: - branch_name = branch['short_name'] - print('%s:' % branch_name, - *sorted(branch_issues.get(branch_name, []), - key=kernel_sec.issue.get_id_sort_key)) + sorted_cve_ids = sorted( + branch_issues.get(branch['full_name'], []), + key=kernel_sec.issue.get_id_sort_key) + print('%s:' % branch['full_name'], *sorted_cve_ids) if __name__ == '__main__': @@ -104,9 +161,11 @@ if __name__ == '__main__': help='include issues that have been marked as ignored') parser.add_argument('branches', nargs='*', - help=('specific branch to report on ' - '(default: all active branches)'), - metavar='BRANCH') + help=('specific branch[:tag] or stable tag to ' + 'report on (default: all active branches). ' + 'e.g. linux-4.14.y linux-4.4.y:v4.4.107 ' + 'v4.4.181-cip33 linux-4.19.y-cip:myproduct-v33'), + metavar='[BRANCH[:TAG]|TAG]') args = parser.parse_args() remotes = kernel_sec.branch.get_remotes(args.remote_name, mainline=args.mainline_remote_name, From patchwork Wed Jul 10 01:24:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Sangorrin X-Patchwork-Id: 11037691 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 A552514DB for ; Wed, 10 Jul 2019 01:34:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98550288E5 for ; Wed, 10 Jul 2019 01:34:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8BD0328900; Wed, 10 Jul 2019 01:34:46 +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 292D2288E5 for ; Wed, 10 Jul 2019 01:34:46 +0000 (UTC) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 15D2A40BB; 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 733D13645 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-csw1116.securemx.jp [210.130.202.158]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 21053886 for ; Wed, 10 Jul 2019 01:25:06 +0000 (UTC) Received: by mo-csw.securemx.jp (mx-mo-csw1116) id x6A1Owce014452; Wed, 10 Jul 2019 10:24:58 +0900 X-Iguazu-Qid: 2wGr1P8H2t2RwrLHdY X-Iguazu-QSIG: v=2; s=0; t=1562721898; q=2wGr1P8H2t2RwrLHdY; m=wHO8XbjNMaiBCXLgtopy9TFhduQkO6Z3B+ECrHDkbcE= Received: from imx2.toshiba.co.jp (imx2.toshiba.co.jp [106.186.93.51]) by relay.securemx.jp (mx-mr1110) id x6A1Oviw026378; Wed, 10 Jul 2019 10:24:57 +0900 Received: from enc01.localdomain ([106.186.93.100]) by imx2.toshiba.co.jp with ESMTP id x6A1OvmL019834; Wed, 10 Jul 2019 10:24:57 +0900 (JST) Received: from hop001.toshiba.co.jp ([133.199.164.63]) by enc01.localdomain with ESMTP id x6A1OvG4025497; Wed, 10 Jul 2019 10:24:57 +0900 From: Daniel Sangorrin To: ben.hutchings@codethink.co.uk Date: Wed, 10 Jul 2019 10:24:49 +0900 X-TSB-HOP: ON Message-Id: <20190710012450.16524-6-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 5/6] pep8: fix pep8-related errors such as too long lines 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 These were distracting when checking new code. Signed-off-by: Daniel Sangorrin --- scripts/import_stable.py | 8 +++++--- scripts/kernel_sec/branch.py | 4 ++-- scripts/prepare_remotes.py | 2 +- scripts/report_affected.py | 2 +- scripts/webview.py | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/import_stable.py b/scripts/import_stable.py index 194219d..b4d8e0a 100755 --- a/scripts/import_stable.py +++ b/scripts/import_stable.py @@ -64,7 +64,8 @@ def get_backports(git_repo, remotes, branches, debug=False): backports.setdefault(mainline_commit, {})[branch_name] \ = stable_commit if line.strip() != '': - commit_re = BACKPORT_COMMIT_BOTTOM_RE # next line is not top + # next line is not top + commit_re = BACKPORT_COMMIT_BOTTOM_RE return backports @@ -120,7 +121,8 @@ def add_backports(branches, c_b_map, issue_commits, all_backports, if debug_context: print('%s/%s: recording commits' % (debug_context, branch_name)) - issue_commits.setdefault(branch_name, []).extend(branch_commits) + issue_commits.setdefault( + branch_name, []).extend(branch_commits) changed = True else: if debug_context: @@ -169,7 +171,7 @@ if __name__ == '__main__': metavar='DIRECTORY') parser.add_argument('--remote-name', dest='remote_name', action='append', default=[], - help='git remote name mappings, e.g. stable:korg-stable', + help='git remote name mappings, e.g. stable:mystable', metavar='NAME:OTHER-NAME') parser.add_argument('--mainline-remote', dest='mainline_remote_name', diff --git a/scripts/kernel_sec/branch.py b/scripts/kernel_sec/branch.py index 96f1cab..52f3b42 100644 --- a/scripts/kernel_sec/branch.py +++ b/scripts/kernel_sec/branch.py @@ -62,8 +62,8 @@ def _extract_live_stable_branches(doc): if match: version = match.group(1) eol = match.group(2) is not None - if branch_type not in ['mainline', 'stable', 'longterm', 'linux-next'] \ - or version is None: + if branch_type not in ['mainline', 'stable', 'longterm', + 'linux-next'] or version is None: raise ValueError('failed to parse releases row text %r' % row_text) # Filter out irrelevant branches diff --git a/scripts/prepare_remotes.py b/scripts/prepare_remotes.py index 59310fc..ab0db24 100755 --- a/scripts/prepare_remotes.py +++ b/scripts/prepare_remotes.py @@ -45,7 +45,7 @@ if __name__ == '__main__': metavar='DIRECTORY') parser.add_argument('--remote-name', dest='remote_name', action='append', default=[], - help='git remote name mappings, e.g. stable:korg-stable', + help='git remote name mappings, e.g. stable:mystable', metavar='NAME:OTHER-NAME') parser.add_argument('--mainline-remote', dest='mainline_remote_name', diff --git a/scripts/report_affected.py b/scripts/report_affected.py index 7ec4af7..a97986c 100755 --- a/scripts/report_affected.py +++ b/scripts/report_affected.py @@ -143,7 +143,7 @@ if __name__ == '__main__': metavar='DIRECTORY') parser.add_argument('--remote-name', dest='remote_name', action='append', default=[], - help='git remote name mappings, e.g. stable:korg-stable', + help='git remote name mappings, e.g. stable:mystable', metavar='NAME:OTHER-NAME') parser.add_argument('--mainline-remote', dest='mainline_remote_name', diff --git a/scripts/webview.py b/scripts/webview.py index 52a7b15..cf54948 100755 --- a/scripts/webview.py +++ b/scripts/webview.py @@ -205,7 +205,7 @@ if __name__ == '__main__': metavar='DIRECTORY') parser.add_argument('--remote-name', dest='remote_name', action='append', default=[], - help='git remote name mappings, e.g. stable:korg-stable', + help='git remote name mappings, e.g. stable:mystable', metavar='NAME:OTHER-NAME') parser.add_argument('--mainline-remote', dest='mainline_remote_name', From patchwork Wed Jul 10 01:24:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Sangorrin X-Patchwork-Id: 11037687 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 D63E714C0 for ; Wed, 10 Jul 2019 01:34:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8933288FD for ; Wed, 10 Jul 2019 01:34:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A8F892890B; Wed, 10 Jul 2019 01:34:43 +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 2044F288FD for ; Wed, 10 Jul 2019 01:34:43 +0000 (UTC) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id EEB8540B4; Wed, 10 Jul 2019 01:34:41 +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 23F7C3645 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-csw1116.securemx.jp [210.130.202.158]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 24D1B88E for ; Wed, 10 Jul 2019 01:25:06 +0000 (UTC) Received: by mo-csw.securemx.jp (mx-mo-csw1116) id x6A1Owwc014450; Wed, 10 Jul 2019 10:24:58 +0900 X-Iguazu-Qid: 2wGr1P8H2t2RsAg2RY X-Iguazu-QSIG: v=2; s=0; t=1562721898; q=2wGr1P8H2t2RsAg2RY; m=Z8Sdo52SdMSBsPoC6B2QkTdGWFb34RP8j//SsArs7bw= Received: from imx2.toshiba.co.jp (imx2.toshiba.co.jp [106.186.93.51]) by relay.securemx.jp (mx-mr1111) id x6A1Ou9T020288; Wed, 10 Jul 2019 10:24:57 +0900 Received: from enc01.localdomain ([106.186.93.100]) by imx2.toshiba.co.jp with ESMTP id x6A1OuT0019827; 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 x6A1OuGq025485; Wed, 10 Jul 2019 10:24:56 +0900 From: Daniel Sangorrin To: ben.hutchings@codethink.co.uk Date: Wed, 10 Jul 2019 10:24:50 +0900 X-TSB-HOP: ON Message-Id: <20190710012450.16524-7-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 6/6] report_affected: add show-description option 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 Rather than looking up each issue file, I would like to have an overview of what each CVE ID means. Example: $ ./scripts/report_affected.py --show-description linux-4.4.y-cip Signed-off-by: Daniel Sangorrin --- scripts/report_affected.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/scripts/report_affected.py b/scripts/report_affected.py index a97986c..b7a2678 100755 --- a/scripts/report_affected.py +++ b/scripts/report_affected.py @@ -18,8 +18,8 @@ import kernel_sec.issue import kernel_sec.version -def main(git_repo, remotes, - only_fixed_upstream, include_ignored, *branch_names): +def main(git_repo, remotes, only_fixed_upstream, + include_ignored, show_description, *branch_names): live_branches = kernel_sec.branch.get_live_branches() if branch_names: branches = [] @@ -130,7 +130,13 @@ def main(git_repo, remotes, sorted_cve_ids = sorted( branch_issues.get(branch['full_name'], []), key=kernel_sec.issue.get_id_sort_key) - print('%s:' % branch['full_name'], *sorted_cve_ids) + if show_description: + print('%s:' % branch['full_name']) + for cve_id in sorted_cve_ids: + print(cve_id, '=>', + kernel_sec.issue.load(cve_id).get('description', 'None')) + else: + print('%s:' % branch['full_name'], *sorted_cve_ids) if __name__ == '__main__': @@ -159,6 +165,9 @@ if __name__ == '__main__': parser.add_argument('--include-ignored', action='store_true', help='include issues that have been marked as ignored') + parser.add_argument('--show-description', + action='store_true', + help='show the issue description') parser.add_argument('branches', nargs='*', help=('specific branch[:tag] or stable tag to ' @@ -171,5 +180,5 @@ if __name__ == '__main__': mainline=args.mainline_remote_name, stable=args.stable_remote_name) kernel_sec.branch.check_git_repo(args.git_repo, remotes) - main(args.git_repo, remotes, - args.only_fixed_upstream, args.include_ignored, *args.branches) + main(args.git_repo, remotes, args.only_fixed_upstream, + args.include_ignored, args.show_description, *args.branches)