From patchwork Mon Dec 16 16:00:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Kuster X-Patchwork-Id: 181746 Delivered-To: patch@linaro.org Received: by 2002:ac9:44c4:0:0:0:0:0 with SMTP id t4csp4482321och; Mon, 16 Dec 2019 08:02:30 -0800 (PST) X-Google-Smtp-Source: APXvYqyg6jTtnY9DmpBsTmgZ2or27WGWcwrenQEsGuDcryKNuLT+Db5MLmie16rH9JJmNBzxv0DY X-Received: by 2002:a65:6815:: with SMTP id l21mr18489405pgt.283.1576512149988; Mon, 16 Dec 2019 08:02:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576512149; cv=none; d=google.com; s=arc-20160816; b=c3sUi62Qm10KHdeoILXE345jB2keTnU1cv9Z6dd7mBavSWf+Xru7PPLiH8eW/i/8ZY xUQpP7YWj+eh27OkcdsqiP5ESVzb3vwbSHQfOPdJQpNwPwhG5l3v3nSQaChzBv2vyphL kfrPUgm7NcKf4ptyD1QGIar+sZClsgglgViHssL18LxtxqiaoUdqnxlsFEqM3TSL9z55 RxRzOHT8IpRnxIAB9EL25uKRfa/0S9SyyDhzLs7TNcvqCwn3SZVqkleB59z5fcqHPeB9 gEPjZZZb+k+shAhRZ4WfMN6IXN0MnDE5D2oW4WOH4Wf4yi+xkfdWdtAwIKXr3L55Uxrz eNsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=Rg9OcnIt/pOoGLUjgTDxrwzQqmjFm/CjH3xZgv7EJvA=; b=bHxTEuivxrA3tTX/Jl9XY7Nj1RRJsFa3R4ACFk3e9wWH4mF3MwR15wp/D7BC/XcKdb LGebBgLmHkKVuZEFWGRFeSvkScRpZR84aRoslSoBhyD1pQ8YSdMiXm60siqI/eYC3JjZ qBGsD8k2Hnr9I/iaGZHr1wqEjcyfdCsgZBYY2ZiTuoniLSnJtKkwyJux0HucDzAuGhmN 3+MhbFyra5uiEM8l2qgtvk7+ZvxcMCJJvj7YCqpMepQzEJO/dMBLDf1G7QdAkD5f9jCs oYrolIAoByVE3PYJXYPPNhxlOzSnFbhBE3/KIGpvCRAndEU+VW88iU5LEgTvPuJR8G4/ x8Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=sWuilZB8; spf=pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) smtp.mailfrom=openembedded-core-bounces@lists.openembedded.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from mail.openembedded.org (mail.openembedded.org. [140.211.169.62]) by mx.google.com with ESMTP id z23si16580394pju.99.2019.12.16.08.02.29; Mon, 16 Dec 2019 08:02:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) client-ip=140.211.169.62; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=sWuilZB8; spf=pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) smtp.mailfrom=openembedded-core-bounces@lists.openembedded.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from ec2-34-214-78-129.us-west-2.compute.amazonaws.com (localhost [127.0.0.1]) by mail.openembedded.org (Postfix) with ESMTP id BC93F7FE14; Mon, 16 Dec 2019 16:00:48 +0000 (UTC) X-Original-To: openembedded-core@lists.openembedded.org Delivered-To: openembedded-core@lists.openembedded.org Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by mail.openembedded.org (Postfix) with ESMTP id A8CF37FDC9 for ; Mon, 16 Dec 2019 16:00:23 +0000 (UTC) Received: by mail-pg1-f170.google.com with SMTP id q127so3963649pga.4 for ; Mon, 16 Dec 2019 08:00:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=lVCLDTPb0GFJoEWDw+Gg93KUJz04qQroZhCJYvxuk0E=; b=sWuilZB8F0LS6JkHR2J1gr3jonJfTHDzARzpPkr4nKd5/OU7yLLFAiNSYhpgC1+/gf pcbGm3v/L7LrCXfYblFujPm0EWFlCUuKnZcxSse5Vb2vnvGhnxy+ELKgDhqZGDudT4Ka jc6W1TQD6LenGjy/NM+G0ynEPXfJsPTlVGk/zLTe+DMsMuGcllHoYdzd81QBg2PcN5t7 BuyXvHnbgW87PpGb/bZhXvPI/tGKcrcBFFS7XooNMWdiJaun41LLdmd6RRfMNpHu3Bm+ Qa+IQyHN2JNVtLhlZuVcF83xVu52sj4ZrTUgnVcrvM0dYv1zZRYgm5VPY5b6+76OAB7Q SfqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=lVCLDTPb0GFJoEWDw+Gg93KUJz04qQroZhCJYvxuk0E=; b=h9OmJcLkCes7X/TtucwE7lHOHH+CFImMCpvHtmV2QJVS5yOtXfW5v8xqjwx7k+xXJ3 WfITjuR6qoni3T5kTIOtHfWhn+8/vsFEbbeY1rIAbw4CfW1ZalaiKm/mDaZ51pv1uL7R IR4ox3CCiU3e1iWXekQxRkPlTtkwHAvfTGba0Yaq+xchDfyCwNr5jxyLKTuqljMZf5xf 3V4i9mIDdTWeQJd1e33NOesAcqALoKdph21Z7XB0of2/xvMAjKI/p8wi+dKACrMROOST jvQSDok+ODJewc7HadwemZlRx2QfPNckp5X43fF/cIrbEbHirRe7bJBv4nTdwB5f7/Nz +fhg== X-Gm-Message-State: APjAAAUhvpjs7WpgzfrpdWP1+n7SfZ8tpwbypBwPPUGWV+Wlr808Cnr6 E/6UjzdQCEvDelxboQHAOVSGjM865UA= X-Received: by 2002:a63:f64a:: with SMTP id u10mr18666101pgj.16.1576512024590; Mon, 16 Dec 2019 08:00:24 -0800 (PST) Received: from akuster-ThinkPad-T460s.mvista.com ([2601:202:4180:a5c0:e5c5:31c9:a010:f145]) by smtp.gmail.com with ESMTPSA id g6sm19568697pjl.25.2019.12.16.08.00.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Dec 2019 08:00:24 -0800 (PST) From: Armin Kuster To: openembedded-core@lists.openembedded.org Date: Mon, 16 Dec 2019 08:00:03 -0800 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: Subject: [OE-core] [thud 13/18] cve-update-db-native: clean up proxy handling X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: openembedded-core-bounces@lists.openembedded.org Errors-To: openembedded-core-bounces@lists.openembedded.org From: Ross Burton urllib handles adding proxy handlers if the proxies are set in the environment, so call bb.utils.export_proxies() to do that and remove the manual setup. (From OE-Core rev: 6b73004668b3b71c9c38814b79fbb58c893ed434) Signed-off-by: Ross Burton Signed-off-by: Richard Purdie Signed-off-by: Armin Kuster --- meta/recipes-core/meta/cve-update-db-native.bb | 31 +++++--------------------- 1 file changed, 5 insertions(+), 26 deletions(-) -- 2.7.4 -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core diff --git a/meta/recipes-core/meta/cve-update-db-native.bb b/meta/recipes-core/meta/cve-update-db-native.bb index 08b18f0..db1d69a 100644 --- a/meta/recipes-core/meta/cve-update-db-native.bb +++ b/meta/recipes-core/meta/cve-update-db-native.bb @@ -21,10 +21,12 @@ python do_populate_cve_db() { """ Update NVD database with json data feed """ - + import bb.utils import sqlite3, urllib, urllib.parse, shutil, gzip from datetime import date + bb.utils.export_proxies(d) + BASE_URL = "https://nvd.nist.gov/feeds/json/cve/1.0/nvdcve-1.0-" YEAR_START = 2002 @@ -40,16 +42,6 @@ python do_populate_cve_db() { except OSError: pass - proxy = d.getVar("https_proxy") - if proxy: - # instantiate an opener but do not install it as the global - # opener unless if we're really sure it's applicable for all - # urllib requests - proxy_handler = urllib.request.ProxyHandler({'https': proxy}) - proxy_opener = urllib.request.build_opener(proxy_handler) - else: - proxy_opener = None - cve_f = open(os.path.join(d.getVar("TMPDIR"), 'cve_check'), 'a') if not os.path.isdir(db_dir): @@ -67,15 +59,7 @@ python do_populate_cve_db() { json_url = year_url + ".json.gz" # Retrieve meta last modified date - - response = None - - if proxy_opener: - response = proxy_opener.open(meta_url) - else: - req = urllib.request.Request(meta_url) - response = urllib.request.urlopen(req) - + response = urllib.request.urlopen(meta_url) if response: for l in response.read().decode("utf-8").splitlines(): key, value = l.split(":", 1) @@ -95,12 +79,7 @@ python do_populate_cve_db() { # Update db with current year json file try: - if proxy_opener: - response = proxy_opener.open(json_url) - else: - req = urllib.request.Request(json_url) - response = urllib.request.urlopen(req) - + response = urllib.request.urlopen(json_url) if response: update_db(c, gzip.decompress(response.read()).decode('utf-8')) c.execute("insert or replace into META values (?, ?)", [year, last_modified])