From patchwork Sun Nov 24 23:50:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Kuster X-Patchwork-Id: 180138 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp2443450ilf; Sun, 24 Nov 2019 15:51:43 -0800 (PST) X-Google-Smtp-Source: APXvYqwSXJVgni7iapNW31rz6PG9R9/mNegGIUgRcIbU1SsUuYkzg8aHJPKPYtxdC6TLgcj9y+zP X-Received: by 2002:a62:8748:: with SMTP id i69mr31397833pfe.224.1574639503608; Sun, 24 Nov 2019 15:51:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574639503; cv=none; d=google.com; s=arc-20160816; b=bmYqJ/+x6Xt/xOAEllmbujwGRBkklFej0esHDySnQd/UxdcqgewCHf53auP6boKrR3 t/1IcU+9kWnBXy9nWbFZGkIFYx6+Bm1gOCKyBhlew5+HxUe36zqL0700dklpZcs2HGus DdYGxpJNYIxVurdbTVJaani65k8JMss27KrHwD0moRILKiA5Q6GWZJgNgrPqEESErs9f HYTWB6ERAN+VgFs+0+aYTog2AEN+qgNO28qdvCmuiHKX3f27EI7k82PvOY5cF1xMQTw6 8NKjQE24qhyx3TR9zrEhLZBezzgIqZlY7qHyYQAmHvcWji2gV95rCz1d+o+QLztD+d07 E63w== 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=1USudQKJstZR156XthNhpqH69Odh9D+AUs5lGV5BISI=; b=RJxxOr0P6DBsw46Vt2R5lbqkYKlhx4pbgjnxnpz6UmRYRBWaqTjX9J66GjW65YRLfG P/3d/E031YS3yOHhQZ7WBwpqAOFku5fF6ZZi+aipIw0gBY5iewM12yfB9vLWlsuuiu4h tWeSZjQePPbhd9E9Ey79oBOg8bQg1IPlI5uwhajVMOmtDcBnbWMt3D3TyKzwVeiwJGmI 9/1OzwwOBbD2NTwGbyYh/wp/oXuRLMy7P66EkKeKTX3TI5ccWBRLoe6Bslz8JgjvWDHX LM/c4uQonhgXo97ZaqNgLGMgESQgMVVb6pq7eTw5rnsbtziEXw4fUNLogtvQnV7qMu+U gPqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=X6bPYZfF; 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 az2si5174383plb.120.2019.11.24.15.51.43; Sun, 24 Nov 2019 15:51:43 -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=X6bPYZfF; 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 AF6417FCCC; Sun, 24 Nov 2019 23:51:08 +0000 (UTC) X-Original-To: openembedded-core@lists.openembedded.org Delivered-To: openembedded-core@lists.openembedded.org Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by mail.openembedded.org (Postfix) with ESMTP id 3A9CA7FC14 for ; Sun, 24 Nov 2019 23:50:49 +0000 (UTC) Received: by mail-pl1-f177.google.com with SMTP id o9so5600981plk.6 for ; Sun, 24 Nov 2019 15:50:50 -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=PEW7uerEPvnNb3Y5lUOTrZ9R/Ta7CAony1NFCSRNZb4=; b=X6bPYZfF+eSzexiEIAqna540/MeOw6WLexic5Ye8cOsn0cpdzLREJCYgxJJtqaX5d5 XhrVVFdTfV8wIXFJMoyrx33vEKsfeXwZGTJwG9DLahlfqUXPBEPGoBlt/f2LQ6gfat9d NMtKFASR9TNBvR42uIfOMQcYLN9Qw7EMunGbJcYYIwr8uX16pWpINlqN8YVV7Pn2p9JN Y1y4NNRGyxYxKus72gyrFvprzaMkJyILKWK4YQTcl+2hqtEsiyBl/kCH+D1RLuLedmNE xmPPbL/2AS3KFBmupDs5KtpgjGrhrGVVaDZpax06fdzOCIRlFg/gj4GT7zBYGRV3aVt/ BWFA== 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=PEW7uerEPvnNb3Y5lUOTrZ9R/Ta7CAony1NFCSRNZb4=; b=WZYMxQ48pl4LCkG0JSzkPE8wkTjRRmMz/9CNoK61BKkT9cYEgji5zgZ61gKmRFVN88 YAINUUkHH54wozdgRsLv8n0ej+8hAwVPSJMipTl4+Z0/+btqvZRzyROOHAUXhvTQ/Bcc 21Kp5U5oxknWs7XLaVLa+OYWGuyOGGjXZwYiz8JXtHcmZZPDZvoluXKs7hHULUC235gh zQzX1IglZ4l/ZbZ99HIDjdvc9Q4AC7m+mlMgYwLZLegV9te6tQ8ReiqCjp9W2+mvwk8G 910meNfXC8tR0DjqQgfWHxf5BSxnGi9XWami6pn2C0BoPJX6L+1lKFlz5MqliYJCwp19 NjCQ== X-Gm-Message-State: APjAAAW14ymYFulvGv7yctY7twdin5d7ZnA0CvlZ47j/E4CpORR182aR LyMdFh9OGN5/rrJalDnPdhZw41pq X-Received: by 2002:a17:90a:aa8f:: with SMTP id l15mr35172101pjq.52.1574639450249; Sun, 24 Nov 2019 15:50:50 -0800 (PST) Received: from akuster-ThinkPad-T460s.hsd1.ca.comcast.net ([2601:202:4180:a5c0:69ac:e4d2:e89f:98da]) by smtp.gmail.com with ESMTPSA id q200sm5619783pfq.87.2019.11.24.15.50.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 24 Nov 2019 15:50:49 -0800 (PST) From: Armin Kuster To: openembedded-core@lists.openembedded.org Date: Sun, 24 Nov 2019 15:50:12 -0800 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: Subject: [OE-core] [zeus 07/35] 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: Anuj Mittal --- 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])