mirror of
https://git.yoctoproject.org/poky
synced 2026-08-20 00:49:34 +02:00
Compare commits
2 Commits
dunfell-23
...
dunfell
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
265fe4e664 | ||
|
|
83a78bea91 |
@@ -25,8 +25,9 @@
|
||||
CVE_PRODUCT ??= "${BPN}"
|
||||
CVE_VERSION ??= "${PV}"
|
||||
|
||||
CVE_CHECK_DB_DIR ?= "${DL_DIR}/CVE_CHECK"
|
||||
CVE_CHECK_DB_FILE ?= "${CVE_CHECK_DB_DIR}/nvdcve_2.db"
|
||||
CVE_CHECK_DB_FILENAME ?= "nvdcve_2.db"
|
||||
CVE_CHECK_DB_DIR ?= "${STAGING_DIR}/CVE_CHECK"
|
||||
CVE_CHECK_DB_FILE ?= "${CVE_CHECK_DB_DIR}/${CVE_CHECK_DB_FILENAME}"
|
||||
CVE_CHECK_DB_FILE_LOCK ?= "${CVE_CHECK_DB_FILE}.lock"
|
||||
|
||||
CVE_CHECK_LOG ?= "${T}/cve.log"
|
||||
@@ -156,7 +157,7 @@ python do_cve_check () {
|
||||
}
|
||||
|
||||
addtask cve_check before do_build
|
||||
do_cve_check[depends] = "cve-update-nvd2-native:do_fetch"
|
||||
do_cve_check[depends] = "cve-update-nvd2-native:do_unpack"
|
||||
do_cve_check[nostamp] = "1"
|
||||
|
||||
python cve_check_cleanup () {
|
||||
|
||||
@@ -63,8 +63,13 @@ python do_fetch() {
|
||||
shutil.copy2(db_file, db_tmp_file)
|
||||
|
||||
if update_db_file(db_tmp_file, d) == True:
|
||||
# Update downloaded correctly, can swap files
|
||||
shutil.move(db_tmp_file, db_file)
|
||||
# Update downloaded correctly, we can swap files. To avoid potential
|
||||
# NFS caching issues, ensure that the destination file has a new inode
|
||||
# number. We do this in two steps as the downloads directory may be on
|
||||
# a different filesystem to tmpdir we're working in.
|
||||
new_file = "%s.new" % (db_file)
|
||||
shutil.move(db_tmp_file, new_file)
|
||||
os.rename(new_file, db_file)
|
||||
else:
|
||||
# Update failed, do not modify the database
|
||||
bb.note("CVE database update failed")
|
||||
|
||||
@@ -8,7 +8,6 @@ INHIBIT_DEFAULT_DEPS = "1"
|
||||
|
||||
inherit native
|
||||
|
||||
deltask do_unpack
|
||||
deltask do_patch
|
||||
deltask do_configure
|
||||
deltask do_compile
|
||||
@@ -35,7 +34,9 @@ CVE_DB_INCR_UPDATE_AGE_THRES ?= "10368000"
|
||||
# Number of attempts for each http query to nvd server before giving up
|
||||
CVE_DB_UPDATE_ATTEMPTS ?= "5"
|
||||
|
||||
CVE_DB_TEMP_FILE ?= "${CVE_CHECK_DB_DIR}/temp_nvdcve_2.db"
|
||||
CVE_CHECK_DB_DLDIR_FILE ?= "${DL_DIR}/CVE_CHECK/${CVE_CHECK_DB_FILENAME}"
|
||||
CVE_CHECK_DB_DLDIR_LOCK ?= "${CVE_CHECK_DB_DLDIR_FILE}.lock"
|
||||
CVE_CHECK_DB_TEMP_FILE ?= "${CVE_CHECK_DB_FILE}.tmp"
|
||||
|
||||
python () {
|
||||
if not bb.data.inherits_class("cve-check", d):
|
||||
@@ -52,9 +53,9 @@ python do_fetch() {
|
||||
|
||||
bb.utils.export_proxies(d)
|
||||
|
||||
db_file = d.getVar("CVE_CHECK_DB_FILE")
|
||||
db_file = d.getVar("CVE_CHECK_DB_DLDIR_FILE")
|
||||
db_dir = os.path.dirname(db_file)
|
||||
db_tmp_file = d.getVar("CVE_DB_TEMP_FILE")
|
||||
db_tmp_file = d.getVar("CVE_CHECK_DB_TEMP_FILE")
|
||||
|
||||
cleanup_db_download(db_file, db_tmp_file)
|
||||
# By default let's update the whole database (since time 0)
|
||||
@@ -77,22 +78,34 @@ python do_fetch() {
|
||||
pass
|
||||
|
||||
bb.utils.mkdirhier(db_dir)
|
||||
bb.utils.mkdirhier(os.path.dirname(db_tmp_file))
|
||||
if os.path.exists(db_file):
|
||||
shutil.copy2(db_file, db_tmp_file)
|
||||
|
||||
if update_db_file(db_tmp_file, d, database_time) == True:
|
||||
# Update downloaded correctly, can swap files
|
||||
shutil.move(db_tmp_file, db_file)
|
||||
# Update downloaded correctly, we can swap files. To avoid potential
|
||||
# NFS caching issues, ensure that the destination file has a new inode
|
||||
# number. We do this in two steps as the downloads directory may be on
|
||||
# a different filesystem to tmpdir we're working in.
|
||||
new_file = "%s.new" % (db_file)
|
||||
shutil.move(db_tmp_file, new_file)
|
||||
os.rename(new_file, db_file)
|
||||
else:
|
||||
# Update failed, do not modify the database
|
||||
bb.warn("CVE database update failed")
|
||||
os.remove(db_tmp_file)
|
||||
}
|
||||
|
||||
do_fetch[lockfiles] += "${CVE_CHECK_DB_FILE_LOCK}"
|
||||
do_fetch[lockfiles] += "${CVE_CHECK_DB_DLDIR_LOCK}"
|
||||
do_fetch[file-checksums] = ""
|
||||
do_fetch[vardeps] = ""
|
||||
|
||||
python do_unpack() {
|
||||
import shutil
|
||||
shutil.copyfile(d.getVar("CVE_CHECK_DB_DLDIR_FILE"), d.getVar("CVE_CHECK_DB_FILE"))
|
||||
}
|
||||
do_unpack[lockfiles] += "${CVE_CHECK_DB_DLDIR_LOCK} ${CVE_CHECK_DB_FILE_LOCK}"
|
||||
|
||||
def cleanup_db_download(db_file, db_tmp_file):
|
||||
"""
|
||||
Cleanup the download space from possible failed downloads
|
||||
|
||||
Reference in New Issue
Block a user