summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarta Rybczynska <rybczynska@gmail.com>2022-05-02 16:25:36 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-05-14 20:26:34 +0100
commit2120a39b09e33755e62d23cb565d37c8cc2ffec7 (patch)
tree31cf30a86d5b9b158c3aca79eb3a09a6e0c7ab0e
parentdd76704ea5e05a317b454726958c350996b6462b (diff)
downloadpoky-2120a39b09e33755e62d23cb565d37c8cc2ffec7.tar.gz
cve-update-db-native: let the user to drive the update interval
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 (From OE-Core rev: ce79a724dc0f9baac480cbadc05894ffcaf48eb7) Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit fe7bc6f16184d5ebdb1dd914b6dcb75c9e5e0c9c) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-core/meta/cve-update-db-native.bb11
1 files changed, 10 insertions, 1 deletions
diff --git a/meta/recipes-core/meta/cve-update-db-native.bb b/meta/recipes-core/meta/cve-update-db-native.bb
index a6144979f0..594bf947c8 100644
--- a/meta/recipes-core/meta/cve-update-db-native.bb
+++ b/meta/recipes-core/meta/cve-update-db-native.bb
@@ -12,6 +12,10 @@ deltask do_compile
12deltask do_install 12deltask do_install
13deltask do_populate_sysroot 13deltask do_populate_sysroot
14 14
15# CVE database update interval, in seconds. By default: once a day (24*60*60).
16# Use 0 to force the update
17CVE_DB_UPDATE_INTERVAL ?= "86400"
18
15python () { 19python () {
16 if not bb.data.inherits_class("cve-check", d): 20 if not bb.data.inherits_class("cve-check", d):
17 raise bb.parse.SkipRecipe("Skip recipe when cve-check class is not loaded.") 21 raise bb.parse.SkipRecipe("Skip recipe when cve-check class is not loaded.")
@@ -43,10 +47,15 @@ python do_fetch() {
43 os.remove(db_file) 47 os.remove(db_file)
44 48
45 # The NVD database changes once a day, so no need to update more frequently 49 # The NVD database changes once a day, so no need to update more frequently
50 # Allow the user to force-update
46 try: 51 try:
47 import time 52 import time
48 if time.time() - os.path.getmtime(db_file) < (24*60*60): 53 update_interval = int(d.getVar("CVE_DB_UPDATE_INTERVAL"))
54 if (update_interval < 0):
55 update_interval = 0
56 if time.time() - os.path.getmtime(db_file) < update_interval:
49 return 57 return
58
50 except OSError: 59 except OSError:
51 pass 60 pass
52 61