From patchwork Thu Jul 18 20:04:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 169217 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2839158ilk; Thu, 18 Jul 2019 13:04:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPJzFhpApEsp4RfsI2mevg1zfmUh1HR1d4eK+4aXMG7ykKo5/sUZEjqdIXSC//apR/r7Y8 X-Received: by 2002:a17:90a:1a45:: with SMTP id 5mr54088327pjl.43.1563480270384; Thu, 18 Jul 2019 13:04:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563480270; cv=none; d=google.com; s=arc-20160816; b=HYjsT1gbXeRhu9ZEmrjXkVkX8PsjNfW0yXhQR50xMmuQrQgr59ZjQACcrUsoxfQI75 51CYs17mGjC9hwixFGQXmV//yiSmS4YyANP4/VXnLGus8iXJ0Li8eT9y411qIAW56R5Z p6c/PhvEIITgB9s05HPUyeLg1+IZipXNOcNk/C+8otHnwVZcauCvTyuk7e3lgBLS6ej4 YgISmcsFL92CHBWC+dXLG7hpF2yWdBmDnHFisuiRvtvRf667mIPcErJGZmUsZej64bnx 2wRP1/kgyuR/+tdEN9oO3m0qgF55FRFVM/BsglRThNu2M1sF2sVAeLmdCNKP87AyAXib VcHw== 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=WPlPYgbHty0QkVBaijhWgCE+uCHe5HobssU0pRsBoeM=; b=sZJ5MIzqSHgJ+Saev979rsYqHN07dQX7B4FoSRQeBeFuNbUPSq4udj6vvotBUqA2gB DzRvmLgQRdP7Ab8URqeT1NYi1iijusMqDkHvMIvPq2ubED3m1eqaXGjHyapz9G2gYKQF ZlijRtLyjybII5mnDE6AmPY6mNWXZ4OWQoOnL4GplSuPWZtvarsYbkAcDg0hPZgDWN2u 3YtFgjkTFYCZKhroSUV4FRKdgPI8U+jzEZDygsyyvbFfXJFyL1sIMKP5OF+YZjfVQDG+ w7FSHZaYJStvsVKZNf0UsJFCa0exZ9WXqr4vOIsQ/Q2GES7Xy++p8Yt/9qnVzC5otLRn ZPvA== 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=uFteZaBo; 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 c1si67717pgp.105.2019.07.18.13.04.29; Thu, 18 Jul 2019 13:04:30 -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=uFteZaBo; 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 5FCA67F081; Thu, 18 Jul 2019 20:04:24 +0000 (UTC) X-Original-To: openembedded-core@lists.openembedded.org Delivered-To: openembedded-core@lists.openembedded.org Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) by mail.openembedded.org (Postfix) with ESMTP id 03AFE7F048 for ; Thu, 18 Jul 2019 20:04:04 +0000 (UTC) Received: by mail-wm1-f49.google.com with SMTP id x15so26742010wmj.3 for ; Thu, 18 Jul 2019 13:04:06 -0700 (PDT) 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=BcPcGSJZjembycdGvjortxGHcKvVMam91E2fyF024d0=; b=uFteZaBo7YH/s4oOSK2zkwsrLH3Ypm0FFeyXSfPx169/TIvDEDYgwUu/f6n4cOI3zY DOGCDy6IFjDnpH+CXEAyBS2DhIGJ63NKLPibOz/W6qGYhksQqDawwphjyzCe+TqV5/qa 04y6OAuoyzCp3SfSo4mT60JP2aiOqYga4uGNruEwG4tuUtekEX5Fvfz1AULhgtq7lPlI P5zcTqy40k0aGwk3/TeV61Q0eTxhECTxwlA1eMkxuxlsIQM8VlM439doo5csrnpm4gQ1 Cmy4yCkR3T30ZGRl1Qi6rsXHxlVES/jilwi5tZ2x9pF+X3pIF2Tm18Ia1gLmRL9rhOay 6kMQ== 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=BcPcGSJZjembycdGvjortxGHcKvVMam91E2fyF024d0=; b=DNdRcqGp0Y2yRZ8UZJ8V9lyVlgugfCARGukFks1Zf8mZ1M47SsyR0VtQnmsvENfUVb Fmn83+AGMeVkGHG6Ez22ccZqaMhUFmDUKjVcxcHNpq3/rCzaeJot49bG2+15/fxRV/Gt mAROd3smwQxMqn1bo/7APNmbb9/K5xGQTSuhsedRB0BinSKj+r7eAuuvLqvi7Hdn3WnJ uRIzcdRMDpZINwqekEQlelFw8zLLQXjbcEjsE9KyiANxp0yqNutCj2mbdPWHZ37WjLXr Q1a1O7TuUUtuuyMuHpUfGh4+S0qe3OmARysMsTaYCjCHMqF1JWe7wLq6oVISDN6WNqLN XpnA== X-Gm-Message-State: APjAAAUvHITWXJP0DEjRQYXO8Q63/Ii+z3Rkq9EsZHDsJABl/9MNT4ET xV5ctlhb9rEsKS/7vtZ1cl8We7x6iGA= X-Received: by 2002:a05:600c:23cd:: with SMTP id p13mr40391215wmb.86.1563480245512; Thu, 18 Jul 2019 13:04:05 -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 r12sm35331858wrt.95.2019.07.18.13.04.04 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 18 Jul 2019 13:04:04 -0700 (PDT) From: Ross Burton To: openembedded-core@lists.openembedded.org Date: Thu, 18 Jul 2019 21:04:00 +0100 Message-Id: <20190718200400.19750-3-ross.burton@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190718200400.19750-1-ross.burton@intel.com> References: <20190718200400.19750-1-ross.burton@intel.com> MIME-Version: 1.0 Subject: [OE-core] [PATCH 3/3] cve-update-db: refresh once every 24 hours 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 Check the mtime of the database before updating, and if it's less than 24 hours ago don't refresh. This saves the HTTP fetches to determine if the data has been updated. Signed-off-by: Ross Burton --- meta/recipes-core/meta/cve-update-db-native.bb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 2.20.1 -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core diff --git a/meta/recipes-core/meta/cve-update-db-native.bb b/meta/recipes-core/meta/cve-update-db-native.bb index cabbde5066c..2afca94fc6b 100644 --- a/meta/recipes-core/meta/cve-update-db-native.bb +++ b/meta/recipes-core/meta/cve-update-db-native.bb @@ -22,7 +22,7 @@ python do_populate_cve_db() { Update NVD database with json data feed """ - import sqlite3, urllib, shutil, gzip, re + import sqlite3, urllib, shutil, gzip, re, time from datetime import date BASE_URL = "https://nvd.nist.gov/feeds/json/cve/1.0/nvdcve-1.0-" @@ -37,6 +37,11 @@ python do_populate_cve_db() { if not os.path.isdir(db_dir): os.mkdir(db_dir) + expiry = time.time() - (60*60*24) # This time yesterday + if os.path.exists(db_file) and expiry < os.path.getmtime(db_file): + bb.note("CVE data updated less than 24 hours ago, not refreshing. Delete %s to force update." % db_file) + return + # Connect to database conn = sqlite3.connect(db_file) c = conn.cursor()