summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Le Magourou <pierre.lemagourou@softbankrobotics.com>2019-11-06 17:37:21 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-11-07 19:47:26 +0000
commit5f1c80f2b87574aaaab3ec9f983168fbdcff13b2 (patch)
tree6ebd89e396f299f1298a776f062cde6cadc148b9
parentac0073b70acfb75723fd521847691bf6f55a8730 (diff)
downloadpoky-5f1c80f2b87574aaaab3ec9f983168fbdcff13b2.tar.gz
cve-update-db: Use std library instead of urllib3
urllib3 was used in this recipe but it was not set as a dependency. As it is not specifically needed, rewrite the recipe with urllib from the standard library. (From OE-Core rev: c0eabd30d7b9c2517f4ec9229640be421ecc8a5e) (From OE-Core rev: bfaee04b8a7cb0fc6e149106619a01b848fd8a98) Signed-off-by: Pierre Le Magourou <pierre.lemagourou@softbankrobotics.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-core/meta/cve-update-db.bb10
1 files changed, 4 insertions, 6 deletions
diff --git a/meta/recipes-core/meta/cve-update-db.bb b/meta/recipes-core/meta/cve-update-db.bb
index 522fd23807..1f48820cc6 100644
--- a/meta/recipes-core/meta/cve-update-db.bb
+++ b/meta/recipes-core/meta/cve-update-db.bb
@@ -19,7 +19,7 @@ python do_populate_cve_db() {
19 Update NVD database with json data feed 19 Update NVD database with json data feed
20 """ 20 """
21 21
22 import sqlite3, urllib3, shutil, gzip, re 22 import sqlite3, urllib, shutil, gzip, re
23 from datetime import date 23 from datetime import date
24 24
25 BASE_URL = "https://nvd.nist.gov/feeds/json/cve/1.0/nvdcve-1.0-" 25 BASE_URL = "https://nvd.nist.gov/feeds/json/cve/1.0/nvdcve-1.0-"
@@ -33,16 +33,14 @@ python do_populate_cve_db() {
33 33
34 initialize_db(c) 34 initialize_db(c)
35 35
36 http = urllib3.PoolManager()
37
38 for year in range(YEAR_START, date.today().year + 1): 36 for year in range(YEAR_START, date.today().year + 1):
39 year_url = BASE_URL + str(year) 37 year_url = BASE_URL + str(year)
40 meta_url = year_url + ".meta" 38 meta_url = year_url + ".meta"
41 json_url = year_url + ".json.gz" 39 json_url = year_url + ".json.gz"
42 40
43 # Retrieve meta last modified date 41 # Retrieve meta last modified date
44 with http.request('GET', meta_url, preload_content=False) as r: 42 with urllib.request.urlopen(meta_url) as r:
45 date_line = str(r.data.splitlines()[0]) 43 date_line = str(r.read().splitlines()[0])
46 last_modified = re.search('lastModifiedDate:(.*)', date_line).group(1) 44 last_modified = re.search('lastModifiedDate:(.*)', date_line).group(1)
47 45
48 # Compare with current db last modified date 46 # Compare with current db last modified date
@@ -50,7 +48,7 @@ python do_populate_cve_db() {
50 meta = c.fetchone() 48 meta = c.fetchone()
51 if not meta or meta[0] != last_modified: 49 if not meta or meta[0] != last_modified:
52 # Update db with current year json file 50 # Update db with current year json file
53 with http.request('GET', json_url, preload_content=False) as r, open(JSON_TMPFILE, 'wb') as tmpfile: 51 with urllib.request.urlopen(json_url) as r, open(JSON_TMPFILE, 'wb') as tmpfile:
54 shutil.copyfileobj(r, tmpfile) 52 shutil.copyfileobj(r, tmpfile)
55 with gzip.open(JSON_TMPFILE, 'rt') as jsonfile: 53 with gzip.open(JSON_TMPFILE, 'rt') as jsonfile:
56 update_db(c, jsonfile) 54 update_db(c, jsonfile)