From patchwork Wed Jul 17 10:45: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: 169109 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp798283ilk; Wed, 17 Jul 2019 03:45:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqxSVoj1efR/tdd/fhj2lO9I/w7CdOo42XqMbZynzYPByZ/ZQFKHTIlrBANmhB2RtY0QpPnj X-Received: by 2002:a17:902:54d:: with SMTP id 71mr41387440plf.140.1563360351809; Wed, 17 Jul 2019 03:45:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563360351; cv=none; d=google.com; s=arc-20160816; b=v6tiP0USML1rqLoMX2WcDzaVJgXjkerqIAya+s2pl345cBAnwFWWapfWBgm/EoFToG 67AOnImU1vDgxYek5yBjFqIoBQyBxSKFMUrWlfuvuO5usvZUMokgF/edo5xWGPu7tD29 sh4sK4AGz76kvggBbhMspHmtNwrZPWTHPrJzevqTqZ0Z2dNPktSm5wz+8u1AujTku0qP XQXwbu5O4gEpQtpfPsEAV9NHy5ljPIrwTB+vMXCs9NrNYE3bemfjdP71YilgZwtrStlq LedZcIsI67YQEUt8YZl9/whVxSoegRNr8PTnSE8fIK+TWNRHNiLEz8F3DOWm3oX2rw+h ktdQ== 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:message-id:date:to:from:dkim-signature:delivered-to; bh=mIme21rM1QrwI/am5emnx9e7Sg70NoddpW/GYB82phk=; b=nYNSdVXFrG2r2K9w2P4yeSo7yhzxdar4XzEjf2d/2bvcdD8+Mn6lSzI7lW+6In3uXD cvE0Q1kEuMg4G+0q4liSu2IkoWj4HONLN/Eghp056R7FzdFWVeAooIMrfsav2bkIJKls JR8M9ke4sI/AExVt5fg9Nr5TJpeDk88cLLouCLdvMzI9AhOlnLGFeh2uzkG+B/M/VIhe gncI0TFz3YXEzN3f8WdtB+vtFM/g4wrVZs3F2rNrD4mSCmuDLMJVw2SuYmqud8bBvqZ3 u1J+LOV4hqoV/Pa1s7GmduxZff/WZpWR3diTxi+nsQko6lMHQbngxQnxUFMLCHPTlioh UDEA== 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="khJyOY/0"; 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 w16si23644695pfi.31.2019.07.17.03.45.51; Wed, 17 Jul 2019 03:45:51 -0700 (PDT) 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="khJyOY/0"; 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 755CB7ED36; Wed, 17 Jul 2019 10:45:47 +0000 (UTC) X-Original-To: openembedded-core@lists.openembedded.org Delivered-To: openembedded-core@lists.openembedded.org Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by mail.openembedded.org (Postfix) with ESMTP id 3F0A27ECE5 for ; Wed, 17 Jul 2019 10:45:46 +0000 (UTC) Received: by mail-wm1-f66.google.com with SMTP id 207so21664466wma.1 for ; Wed, 17 Jul 2019 03:45:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lfPFoX4HvJR9R/nnGjGvAmUDiw6rIPnEWENxuw+SRmE=; b=khJyOY/0zzNmf8lXSoBpEbP9w0Ez0hBqk14yCtvnm9m0KMoUYtesGFGeTn9TRpqSQU +cSlCIKkgavyJ0U0gEmhPZM1HwkqvJwAsW0GVpGX2hwr9zaDUq1lnGdpoFm2I/W+Ptbw cB0DN/xM3AFH8bdhWA9gLxNa1RiSqbUI04p+OSwudfz8wJXDPYX7nZOGBCpBeZEv5YqY J5yOTWYavaK/8mvRhyCn365MDSL0wciM4cSc60ZljeOVRPur0RJtup+vXTHpu8wMDP+B yDvjHC/zGxcTlWr/cL9M/UanusHuuhd+9YUF4jq8/DYIpRVdg3G5GnW0H1YctrNGfSZB /QEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lfPFoX4HvJR9R/nnGjGvAmUDiw6rIPnEWENxuw+SRmE=; b=kPuf5eDx2Tz02k11nVGp4jsam25OB7BzYNESRacsSGejhyCvvu3iZRcaTfciimrzdt EdFyXFiAgdFPI3U6J29mCPxwsSAa1Ag8c/0xYR0ZhGIWakOlWG/HqT1KZJ8qTHj7x6pI 7gwGOS+Cyd4u1Gwi6/ZnTaiUgb4faKCqxJlqBeqFMfJCmkY/kvOLfXAQcY94NpuokVtX edzKTiRwYIa8yFrWCYwMwzJKLS2Au1pV8oEYgPvijYaBElaworj5UemojTnrDVREVijv a8mzMYHjTUyddSPUDA8Fj2IHcVk+Tnmiqy/+ldMrYhSNfxKYSbodBTN80tKX6aMC6DCz qFXw== X-Gm-Message-State: APjAAAWs2N/tAU7iej0AtCTIdAibrtY8vuxmZfycRYpZv0gHGYPO4cqV 1nWYlG+oJtiAKwaaEiCVdcTJwdJ6koc= X-Received: by 2002:a1c:c14b:: with SMTP id r72mr20444555wmf.166.1563360346667; Wed, 17 Jul 2019 03:45:46 -0700 (PDT) Received: from flashheart.burtonini.com (35.106.2.81.in-addr.arpa. [81.2.106.35]) by smtp.gmail.com with ESMTPSA id o11sm22822097wmh.37.2019.07.17.03.45.44 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 17 Jul 2019 03:45:44 -0700 (PDT) From: Ross Burton To: openembedded-core@lists.openembedded.org Date: Wed, 17 Jul 2019 11:45:36 +0100 Message-Id: <20190717104538.20990-1-ross.burton@intel.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [OE-core] [PATCH 1/3] cve-check: allow comparison of Vendor as well as Product 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 Some product names are too vague to be searched without also matching the vendor, for example Flex could be the parser compiler we ship, or Adobe Flex, or Apache Flex, or IBM Flex. If entries in CVE_PRODUCT contain a colon then split it as vendor:product to improve the search. Also don't use .format() to construct SQL as that can lead to security issues. Instead, use ? placeholders and lets sqlite3 handle the escaping. Signed-off-by: Ross Burton --- meta/classes/cve-check.bbclass | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 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 2a1381604ad..e8668b25663 100644 --- a/meta/classes/cve-check.bbclass +++ b/meta/classes/cve-check.bbclass @@ -190,12 +190,16 @@ def check_cves(d, patched_cves): import sqlite3 db_file = d.getVar("CVE_CHECK_DB_FILE") conn = sqlite3.connect(db_file) - c = conn.cursor() - - query = "SELECT * FROM PRODUCTS WHERE PRODUCT IS '{0}';" for product in products: - for row in c.execute(query.format(product, pv)): + c = conn.cursor() + if ":" in product: + vendor, product = product.split(":", 1) + c.execute("SELECT * FROM PRODUCTS WHERE PRODUCT IS ? AND VENDOR IS ?", (product, vendor)) + else: + c.execute("SELECT * FROM PRODUCTS WHERE PRODUCT IS ?", (product,)) + + for row in c: cve = row[1] version_start = row[4] operator_start = row[5]