From patchwork Sun Dec 8 18:35:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niko Mauno X-Patchwork-Id: 180970 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp3449797ile; Sun, 8 Dec 2019 10:41:28 -0800 (PST) X-Google-Smtp-Source: APXvYqziFMXaZyINB3ZbIR2BqK1oxrHblWD+6gdDtAakTKqYjh7BMCgxgeDTCilkgX2gFkRE30B6 X-Received: by 2002:a17:902:fe98:: with SMTP id x24mr25812800plm.155.1575830487579; Sun, 08 Dec 2019 10:41:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575830487; cv=none; d=google.com; s=arc-20160816; b=AIRCOn0m+aS+Ie61cK6wUDZwfZL3tOR8r0ArhFJYe4ocRvujARXqI5sYcVK+wFeBBI NKkTaVq+WzKbvcy1iNv/6eR+RryXH3I57YXhGcAr7OnWU0rDfRP2Xjl5CIrN4P/TpLeU feWzm/evXOpWAf0U1QgcdDavda3RkJqKHN/wmJjUAfz00Jx15YCILu49fYWBU4pAiwQM B0k5p0KKn7breSXARYL/yDejz2AB/Q0/R9a3UyYYJYwLpMfP6Znzqot8aol6yp6IwwjE B/6J0t0hepQEdowwr6bUHDQGpdg6I7mtQ1UvrW0jGNKeNctroNjy4C3T457jCYJtxfxI 3ONQ== 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=mh5LxRA0J1Qsk9K5qGZWDoVCg/ts9B/s4ZzcFH/Y1vs=; b=Ng1RuMVo0Hri5tFhK5vWRHMyzKiojhiNR407C0Cvd33OOr6rVGNw74f86fI2/pGeG7 heVd0O4zg7RE7gp5O4k4ifrGE/u3/9Y4OqTsG1UEqI6qV6qo6RnvvP3DJQnUw58TDNH5 5xSXohc1L/weOQWjEolKb0Z3xrZ0U+Eipeqyws2hUL+jFwv1cmWe9Ikf3HOk/U7u4Q4u rm/vOyDmjCUFSp/6iEJ314Z9TrXnicR+4a/QPHRpwDALuNZzOag3tKk/Lv+Yh5G7gH3w UwqIj8O3shEkZCvUN9KKNzm75zLxCQGO9HxB3Mr6Npl0KQ10Rkab9YdyZ/M5rTB6OYRk 7lEw== 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=iki.fi Return-Path: Received: from mail.openembedded.org (mail.openembedded.org. [140.211.169.62]) by mx.google.com with ESMTP id bc6si14712501plb.367.2019.12.08.10.41.26; Sun, 08 Dec 2019 10:41:27 -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=iki.fi 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 C14817FBC1; Sun, 8 Dec 2019 18:41:24 +0000 (UTC) X-Original-To: openembedded-core@lists.openembedded.org Delivered-To: openembedded-core@lists.openembedded.org Received: from sypressi2.dnainternet.net (sypressi2.dnainternet.net [83.102.40.154]) by mail.openembedded.org (Postfix) with ESMTP id B7E9D7F8DB for ; Sun, 8 Dec 2019 18:41:23 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by sypressi2.dnainternet.net (Postfix) with ESMTP id 6729C150FC; Sun, 8 Dec 2019 20:41:24 +0200 (EET) X-Virus-Scanned: DNA Internet at dnainternet.net X-Spam-Flag: NO X-Spam-Score: 0.653 X-Spam-Level: X-Spam-Status: No, score=0.653 tagged_above=-9999 required=6 tests=[SPF_HELO_NONE=0.001, SPF_NEUTRAL=0.652] autolearn=disabled Received: from sypressi2.dnainternet.net ([83.102.40.154]) by localhost (sypressi2.dnainternet.net [127.0.0.1]) (DNA Internet, port 10041) with ESMTP id 3imeECL7qwIB; Sun, 8 Dec 2019 20:41:23 +0200 (EET) Received: from luumupuu2.dnainternet.net (luumupuu2.dnainternet.net [83.102.40.55]) by sypressi2.dnainternet.net (Postfix) with ESMTP id E0E8B14E51; Sun, 8 Dec 2019 20:41:23 +0200 (EET) Received: from localhost.localdomain (62-78-161-185.bb.dnainternet.fi [62.78.161.185]) by luumupuu2.dnainternet.net (Postfix) with ESMTP id 15B8489; Sun, 8 Dec 2019 20:41:18 +0200 (EET) From: Niko Mauno To: openembedded-core@lists.openembedded.org Date: Sun, 8 Dec 2019 20:35:56 +0200 Message-Id: <20191208183557.32589-10-niko.mauno@iki.fi> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191208183557.32589-1-niko.mauno@iki.fi> References: <20191208183557.32589-1-niko.mauno@iki.fi> MIME-Version: 1.0 Subject: [OE-core] [thud-next][PATCH 10/11] 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 --- meta/classes/cve-check.bbclass | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) -- 2.20.1 -- _______________________________________________ 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]