From: Marta Rybczynska <rybczynska@gmail.com>
To: openembedded-core@lists.openembedded.org, ross.burton@arm.com
Cc: Marta Rybczynska <rybczynska@gmail.com>,
Marta Rybczynska <marta.rybczynska@huawei.com>
Subject: [OE-core][PATCH v2 2/2] cve-update-db-native: let the user to drive the update interval
Date: Mon, 2 May 2022 16:25:36 +0200 [thread overview]
Message-ID: <20220502142536.1654021-2-rybczynska@gmail.com> (raw)
In-Reply-To: <20220502142536.1654021-1-rybczynska@gmail.com>
Add a new variable CVE_DB_UPDATE_INTERVAL allowing the user to set
the database update interval.
- a positive value sets an interval (in seconds)
- a zero ("0") forces the database update
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
---
Changes from v1:
- allow to set the interval, not only force the update
---
meta/recipes-core/meta/cve-update-db-native.bb | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/meta/recipes-core/meta/cve-update-db-native.bb b/meta/recipes-core/meta/cve-update-db-native.bb
index af39480dda..c8c1cbf115 100644
--- a/meta/recipes-core/meta/cve-update-db-native.bb
+++ b/meta/recipes-core/meta/cve-update-db-native.bb
@@ -13,6 +13,9 @@ deltask do_install
deltask do_populate_sysroot
NVDCVE_URL ?= "https://nvd.nist.gov/feeds/json/cve/1.1/nvdcve-1.1-"
+# CVE database update interval, in seconds. By default: once a day (24*60*60).
+# Use 0 to force the update
+CVE_DB_UPDATE_INTERVAL ?= "86400"
python () {
if not bb.data.inherits_class("cve-check", d):
@@ -44,11 +47,16 @@ python do_fetch() {
os.remove(db_file)
# The NVD database changes once a day, so no need to update more frequently
+ # Allow the user to force-update
try:
import time
- if time.time() - os.path.getmtime(db_file) < (24*60*60):
+ update_interval = int(d.getVar("CVE_DB_UPDATE_INTERVAL"))
+ if (update_interval < 0):
+ update_interval = 0
+ if time.time() - os.path.getmtime(db_file) < update_interval:
bb.debug(2, "Recently updated, skipping")
return
+
except OSError:
pass
--
2.33.0
prev parent reply other threads:[~2022-05-02 14:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-02 14:25 [OE-core][PATCH v2 1/2] cve-update-db-native: update the CVE database once a day only Marta Rybczynska
2022-05-02 14:25 ` Marta Rybczynska [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220502142536.1654021-2-rybczynska@gmail.com \
--to=rybczynska@gmail.com \
--cc=marta.rybczynska@huawei.com \
--cc=openembedded-core@lists.openembedded.org \
--cc=ross.burton@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox