From patchwork Mon Nov 11 22:13:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 179156 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp7263891ilf; Mon, 11 Nov 2019 14:14:34 -0800 (PST) X-Google-Smtp-Source: APXvYqwFimxaPJVl3Xrak6+uulL9P5fmV2nLLbKg8nrdbhh84CCHXMIkOPh2cxp1pCrqUdIt2/Fz X-Received: by 2002:a63:5966:: with SMTP id j38mr31083234pgm.304.1573510474110; Mon, 11 Nov 2019 14:14:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573510474; cv=none; d=google.com; s=arc-20160816; b=lptWn6n5mnPI9lf9DvFwotvkIGLJ1nLYI9qfn3h3uFRb3F8blqda2pvN6D/kQQZhhM Q2lv2TC4va5qA9Ahho2K2ZQbJYOhDZRBdJx8NFz4OPAibaM0dlRnvt5XyJsrl191MO4I o9gRbpAN7AyqY12pK+L50PhfH34swH5DuaK6l/yeb35uNlBWGxFJ+vXlOxcV/mzEAWMf 2gHpe6Bq+abOkHb3Mx5J8KXZ/8nDi4EBTAknBpS/3gg6n2LI/Uk873arsN57b5dDXsT+ 6ZZzrWAkT0306xPEZV2inEaC8wt1xsJ8AuKrX/5dmjRcsgFNBlag98D390hy6Bj4+7tE kU7A== 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 :dkim-signature:delivered-to; bh=QgONmI5M0f6ZfLAa8/Mi60U3ELSHg8eXbDkFjXRNtLw=; b=C1qgWmDfU+nqKaPKPj2BPrdbjHCgUQZ1bEWX3LQlXe2Lyd6ZRKwgQRut308tcUHuhK DdlTYP5x69dRdKDxvJr9BOQ4YLE9TdfjO+IWkV9tsXHGSwA5PHZbLMqU70zmcYKnTkVL 3MXG+3zQ/hz3xQC3zmdzLjF+ZLlSxXYlva4QMNN42E11nIs6EUylP3xhoemuwv/cTi2/ OpoyQyW5c6T8KBSYNqLyNme+GYH+CL/4acwEvRL96wsBIJQFP9ygIdKht/cHLfJdLbI2 enB/bjn0Wz8q67ndWRlebGEIVndpSJnsCwLWQwT/knMNTA4rR8gNp3TFDBFmRdZi3o+v Dhsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=P1QmOfbq; 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 jx8si836785pjb.53.2019.11.11.14.14.33; Mon, 11 Nov 2019 14:14:34 -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; dkim=neutral (body hash did not verify) header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=P1QmOfbq; 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 4C5F87FAAA; Mon, 11 Nov 2019 22:14:31 +0000 (UTC) X-Original-To: openembedded-core@lists.openembedded.org Delivered-To: openembedded-core@lists.openembedded.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by mail.openembedded.org (Postfix) with ESMTP id 5FE277FAAA for ; Mon, 11 Nov 2019 22:13:42 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id t1so16369919wrv.4 for ; Mon, 11 Nov 2019 14:13:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=BvLw+Q5ig6tUnaYjdSmgh3xKOEyw45Rn18F3gm7mWBk=; b=P1QmOfbqqCwiu9CuYXVohJXXuydBw3FCN0F3GutpRENAHyUC7gr8OPIM6PsZ6HM/xz aAK7TYKXM1naoOMs+ch5eD7hVHZjVC5Jg+yP4vGPxEsaDD4j7tUkQzM1zMDvz/lNCd3j rEtzvmkgjFAYrLHQBUGtIYzqwZwDksLfbVoa2C7sUwsxoNl5EB+Fy4ufJy8lUR/noZJo ujZuMb+I5fQT+DuNvS2wGK35bHalACMPVcE2gIHRYeHkmD8U3d5JkLCo8v0e3EyRG3gj wsrqPj6BHTR8VMkK49iVkJxiN392q0yBjPCpkRaJPPRHo1Lw1pKroB+j5qoGZm62sIt8 dGuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BvLw+Q5ig6tUnaYjdSmgh3xKOEyw45Rn18F3gm7mWBk=; b=RixVwaTC3xzdfLE9/F17CCKRdWfyLeET7P6a1Fh7XrQ1ButCx7e3RycS4phwNn4Jyf s3RVX8xLpvUbEijkEDOcwJfNIQFWWtwHe55qoJ5Szu0AaiiZFZa1dY+vR/1vnYkIn6bS 3HtWhoFq0iiFA7mZARyXKEkn1ALEXWPkHjMkwLu6Y4CxKgAt9eaQiwjSH9F6seER3ZGY mRCVZoueoPxFO2O2rxPWcJYQpFhiptOGQN7VGZeVnh7npP7uPE3Dz0RucY7MJgesi9TM TRPLSu1VUf40Qg9qN31B6C5DRGHt24zqpAYGmJ2AERmxzJS5AGOZuBMbbn+/LyrMRdFj vpsQ== X-Gm-Message-State: APjAAAWydX0O/HstrN2c0j2gOHTmeeiJMF4uQXlInaWe2Ax6wG66VrV2 SvLWOSXh/CTcuXEDKAaF1SrXayVuew0= X-Received: by 2002:adf:e78c:: with SMTP id n12mr20979334wrm.94.1573510422808; Mon, 11 Nov 2019 14:13:42 -0800 (PST) Received: from flashheart.burtonini.com (35.106.2.81.in-addr.arpa. [81.2.106.35]) by smtp.gmail.com with ESMTPSA id d11sm24900083wrf.80.2019.11.11.14.13.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2019 14:13:42 -0800 (PST) From: Ross Burton To: openembedded-core@lists.openembedded.org Date: Mon, 11 Nov 2019 22:13:36 +0000 Message-Id: <20191111221337.20332-3-ross.burton@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191111221337.20332-1-ross.burton@intel.com> References: <20191111221337.20332-1-ross.burton@intel.com> MIME-Version: 1.0 Subject: [OE-core] [PATCH 3/4] 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 Remove obsolete Python 2 code, and use convenience methods for neatness. Signed-off-by: Ross Burton --- 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 3326944d791..419b2c9148f 100644 --- a/meta/classes/cve-check.bbclass +++ b/meta/classes/cve-check.bbclass @@ -256,23 +256,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]