From patchwork Fri Nov 22 11:39:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anuj Mittal X-Patchwork-Id: 180060 Delivered-To: patch@linaro.org Received: by 2002:ac9:5f8c:0:0:0:0:0 with SMTP id h12csp83454ocv; Fri, 22 Nov 2019 03:41:25 -0800 (PST) X-Google-Smtp-Source: APXvYqyyF1khoVWM1oXFTGQsaKnFCO/sveRM5N9oIvpzLIMULcwN0vuGuzv8rRm36Clf11x8XeiG X-Received: by 2002:a17:90b:24c:: with SMTP id fz12mr18177529pjb.51.1574422885182; Fri, 22 Nov 2019 03:41:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574422885; cv=none; d=google.com; s=arc-20160816; b=Eu9WF/Xl37WuQsxsnvamFK+VQQZSscc6jgFy42Pu7xf+irsyPo8T/XB3cABMX7G8Gz fcw+KyhJcvlxMxLPlZ/sHur+f596XLoFtZqz9ykXz81eptBcCm4ehMjY3bGHBcobDD5E JiPcgXKMvjanyrKKnaL3rhxzCt+haINduKrq2fDcy8DghkgdTmdE+/mN4NsPekPDB4uo mrGlhIKwY0SIatyi2uwEyTqNtZVyTubBICXci077KhwfJ5QbY62YYefAjwWPYJi9w4zP YBnXwQfNOjZ2KtmMn38/T9QOc0d9MuIhRZuhqQ/y5b6WupNPfBlpHotSMPe772N5jQgW HdGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=xiCQDXPmHAHIyyslKdG7I+VYKEDfqOhg8qLM/vq8toA=; b=Gco8DPPTyLI4amUvg7xbu/ZmoOozsVgp8MUhcp8a6mgml7wmLfNYELdx+7gAE7rpdu xvCZ3LbUhsRvbs5szCo+QySXyCX+Z7z3bi61cAYh1aJfLeD/8HOZe48nc7FT662XouQP 7x8jIwrZIdhvZLVN6S4S6g0i6Z8P4CyauYQB8Jk5mhRXsCHfjot7DqAQtNs5zKrRodvT UQfr/bUepDHMYBB+WVXoJiL9ITfn0ppVh8QXQmqlKlKdp9BWaPKy+WRorqQT60layQv4 g7lKNSEWMzsF+BO6s8y0TEZl46EoyWNhxZfDrfOvCr36/vcvTYcDnm4qw2jg6t59QGzj pwDQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) smtp.mailfrom=openembedded-core-bounces@lists.openembedded.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from mail.openembedded.org (mail.openembedded.org. [140.211.169.62]) by mx.google.com with ESMTP id c1si3045818plr.412.2019.11.22.03.41.24; Fri, 22 Nov 2019 03:41:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) client-ip=140.211.169.62; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) smtp.mailfrom=openembedded-core-bounces@lists.openembedded.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from ec2-34-214-78-129.us-west-2.compute.amazonaws.com (localhost [127.0.0.1]) by mail.openembedded.org (Postfix) with ESMTP id D1D0E7FD02; Fri, 22 Nov 2019 11:40:40 +0000 (UTC) X-Original-To: openembedded-core@lists.openembedded.org Delivered-To: openembedded-core@lists.openembedded.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mail.openembedded.org (Postfix) with ESMTP id 9F3957FCD3 for ; Fri, 22 Nov 2019 11:40:37 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Nov 2019 03:40:39 -0800 X-IronPort-AV: E=Sophos;i="5.69,229,1571727600"; d="scan'208";a="201485408" Received: from anmitta2-mobl1.gar.corp.intel.com ([10.255.164.245]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Nov 2019 03:40:35 -0800 From: Anuj Mittal To: openembedded-core@lists.openembedded.org Date: Fri, 22 Nov 2019 19:39:08 +0800 Message-Id: <3413cd334f70f67eb6befae818b30a82d113c6c3.1574422359.git.anuj.mittal@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Subject: [OE-core] [zeus][PATCH 09/15] cve-check: neaten get_cve_info X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: openembedded-core-bounces@lists.openembedded.org Errors-To: openembedded-core-bounces@lists.openembedded.org From: Ross Burton Remove obsolete Python 2 code, and use convenience methods for neatness. (From OE-Core rev: f19253cc9e70c974a8e21a142086c13d7cde04ff) Signed-off-by: Ross Burton Signed-off-by: Richard Purdie Signed-off-by: Anuj Mittal --- meta/classes/cve-check.bbclass | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) -- 2.21.0 -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core diff --git a/meta/classes/cve-check.bbclass b/meta/classes/cve-check.bbclass index c1cbdbde7b..e95716d9de 100644 --- a/meta/classes/cve-check.bbclass +++ b/meta/classes/cve-check.bbclass @@ -261,23 +261,15 @@ def check_cves(d, patched_cves): def get_cve_info(d, cves): """ Get CVE information from the database. - - Unfortunately the only way to get CVE info is set the output to - html (hard to parse) or query directly the database. """ - try: - import sqlite3 - except ImportError: - from pysqlite2 import dbapi2 as sqlite3 + import sqlite3 cve_data = {} - db_file = d.getVar("CVE_CHECK_DB_FILE") - placeholder = ",".join("?" * len(cves)) - query = "SELECT * FROM NVD WHERE id IN (%s)" % placeholder - conn = sqlite3.connect(db_file) - cur = conn.cursor() - for row in cur.execute(query, tuple(cves)): + conn = sqlite3.connect(d.getVar("CVE_CHECK_DB_FILE")) + placeholders = ",".join("?" * len(cves)) + query = "SELECT * FROM NVD WHERE id IN (%s)" % placeholders + for row in conn.execute(query, tuple(cves)): cve_data[row[0]] = {} cve_data[row[0]]["summary"] = row[1] cve_data[row[0]]["scorev2"] = row[2]