summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/meta
diff options
context:
space:
mode:
authorPierre Le Magourou <pierre.lemagourou@softbankrobotics.com>2019-06-24 11:44:38 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-06-27 12:20:35 +0100
commit3baf4d7fd0887519d5d38ac0afd7d1963261a95f (patch)
treed12cbe40adc8f63e3a97e244abc27103391118b8 /meta/recipes-core/meta
parent469f037b3b7c73a8aeb362eccca935618388d4ea (diff)
downloadpoky-3baf4d7fd0887519d5d38ac0afd7d1963261a95f.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) Signed-off-by: Pierre Le Magourou <pierre.lemagourou@softbankrobotics.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/meta')
-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)