cve-update-db: do_populate_cve_db depends on do_fetch
PATCH v3 1/1 cve-update-db: do_populate_cve_db depends on do_fetch
From: Pierre Le Magourou <[email protected]>
To be able to populate NVD database on a fetchall
(bitbake <image> --run-all=fetch), set the do_populate_cve_db task to be executed before do_fetch.
Do not get CVE_CHECK_DB_DIR, CVE_CHECK_DB_FILE and CVE_CHECK_TMP_FILE variable because do_populate_cve_db can be called in a context where cve-check class is not loaded.
--- meta/recipes-core/meta/cve-update-db.bb | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)
meta/recipes-core/meta/cve-update-db.bb +14 -8
@@ -6,7 +6,6 @@ PACKAGES = "" inherit nopackages -deltask do_fetch deltask do_unpack deltask do_patch deltask do_configure
@@ -24,10 +23,16 @@ python do_populate_cve_db() { BASE_URL = "https://nvd.nist.gov/feeds/json/cve/1.0/nvdcve-1.0-" YEAR_START = 2002 - JSON_TMPFILE = d.getVar("CVE_CHECK_DB_DIR") + '/nvd.json.gz' + + db_dir = d.getVar("DL_DIR") + 'CVE_CHECK' + db_file = db_dir + '/nvd-json.db' + json_tmpfile = db_dir + '/nvd.json.gz' + proxy = d.getVar("https_proxy") + + if not os.path.isdir(db_dir): + os.mkdir(db_dir) # Connect to database - db_file = d.getVar("CVE_CHECK_DB_FILE") conn = sqlite3.connect(db_file) c = conn.cursor()
@@ -50,9 +55,9 @@ python do_populate_cve_db() { meta = c.fetchone() if not meta or meta[0] != last_modified: # Update db with current year json file - with http.request('GET', json_url, preload_content=False) as r, open(JSON_TMPFILE, 'wb') as tmpfile: + with http.request('GET', json_url, preload_content=False) as r, open(json_tmpfile, 'wb') as tmpfile: shutil.copyfileobj(r, tmpfile) - with gzip.open(JSON_TMPFILE, 'rt') as jsonfile: + with gzip.open(json_tmpfile, 'rt') as jsonfile: update_db(c, jsonfile) c.execute("insert or replace into META values (?, ?)", [year, last_modified])
@@ -60,8 +65,9 @@ python do_populate_cve_db() { conn.commit() conn.close() - with open(d.getVar("CVE_CHECK_TMP_FILE"), 'a'): - os.utime(d.getVar("CVE_CHECK_TMP_FILE"), None) + cve_check_tmp_file = d.getVar("TMPDIR") + '/cve_check' + with open(cve_check_tmp_file, 'a'): + os.utime(cve_check_tmp_file, None) } # DJB2 hash algorithm
@@ -115,7 +121,7 @@ def update_db(c, json_filename): -addtask do_populate_cve_db before do_cve_check +addtask do_populate_cve_db before do_fetch do_populate_cve_db[nostamp] = "1" EXCLUDE_FROM_WORLD = "1"
Signature · 1 line
2.11.0
✗ patchtest: failure for cve-update-db: do_populate_cve_db depends on do_fetch (rev3)
== Series Details ==
Series: cve-update-db: do_populate_cve_db depends on do_fetch (rev3)
Revision: 3
URL : https://patchwork.openembedded.org/series/18357/
State : failure
== Summary ==
Thank you for submitting this patch series to OpenEmbedded Core. This is an automated response. Several tests have been executed on the proposed series by patchtest resulting in the following failures:
* Patch [meta-oe,v3] cve-update-db: do_populate_cve_db depends on do_fetch Issue Series sent to the wrong mailing list [test_target_mailing_list] Suggested fix Check the project's README (meta-oe,v3) and send the patch to the indicated list
* Issue Series does not apply on top of target branch [test_series_merge_on_head]
Suggested fix Rebase your series on top of targeted branch
Targeted branch master (currently at 9f674a88c7)
If you believe any of these test results are incorrect, please reply to the mailing list ([email protected]) raising your concerns. Otherwise we would appreciate you correcting the issues and submitting a new version of the patchset if applicable. Please ensure you add/increment the version number when sending the new version (i.e. [PATCH] -> [PATCH v2] -> [PATCH v3] -> ...).
---
Guidelines: https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest Test suite: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe