* [OE-core][PATCH v2 1/2] cve-update-db-native: update the CVE database once a day only
@ 2022-05-02 14:25 Marta Rybczynska
2022-05-02 14:25 ` [OE-core][PATCH v2 2/2] cve-update-db-native: let the user to drive the update interval Marta Rybczynska
0 siblings, 1 reply; 2+ messages in thread
From: Marta Rybczynska @ 2022-05-02 14:25 UTC (permalink / raw)
To: openembedded-core, ross.burton; +Cc: Marta Rybczynska, Marta Rybczynska
The update of the NVD database was expected to happen once per hour.
However, the database file date changes only if the content was actually
updated. In practice, the check worked for the first hour after the
new download.
As the NVD database changes usually only once a day, we can just
update it less frequently.
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
---
meta/recipes-core/meta/cve-update-db-native.bb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/meta/recipes-core/meta/cve-update-db-native.bb b/meta/recipes-core/meta/cve-update-db-native.bb
index e5822cee58..af39480dda 100644
--- a/meta/recipes-core/meta/cve-update-db-native.bb
+++ b/meta/recipes-core/meta/cve-update-db-native.bb
@@ -43,10 +43,10 @@ python do_fetch() {
if os.path.exists(db_file):
os.remove(db_file)
- # Don't refresh the database more than once an hour
+ # The NVD database changes once a day, so no need to update more frequently
try:
import time
- if time.time() - os.path.getmtime(db_file) < (60*60):
+ if time.time() - os.path.getmtime(db_file) < (24*60*60):
bb.debug(2, "Recently updated, skipping")
return
except OSError:
--
2.33.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* [OE-core][PATCH v2 2/2] cve-update-db-native: let the user to drive the update interval
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
0 siblings, 0 replies; 2+ messages in thread
From: Marta Rybczynska @ 2022-05-02 14:25 UTC (permalink / raw)
To: openembedded-core, ross.burton; +Cc: Marta Rybczynska, Marta Rybczynska
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-02 14:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [OE-core][PATCH v2 2/2] cve-update-db-native: let the user to drive the update interval Marta Rybczynska
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox