From f275a3be3f6f830687529bd8a1ab024caf5fdae8 Mon Sep 17 00:00:00 2001 From: "pixee-b1171e79b0e16eb5[bot]" <170462952+pixee-b1171e79b0e16eb5[bot]@users.noreply.github.com> Date: Thu, 18 Jul 2024 03:08:48 +0000 Subject: [PATCH] Sandbox URL Creation --- introduction/playground/A6/soln.py | 6 +++--- introduction/playground/A6/utility.py | 28 +++++++++++++-------------- requirements.txt | 1 + 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/introduction/playground/A6/soln.py b/introduction/playground/A6/soln.py index 694ac357..34e1461d 100644 --- a/introduction/playground/A6/soln.py +++ b/introduction/playground/A6/soln.py @@ -1,14 +1,14 @@ -import requests +from security import safe_requests def check_vuln(list_of_modules)->list: vulns = [] for i in list_of_modules: k = i.split("==") url = f"https://pypi.org/pypi/{k[0]}/{k[1]}/json" - response = requests.get(url) + response = safe_requests.get(url) response.raise_for_status() info = response.json() existing_vuln = info['vulnerabilities'] if len(existing_vuln) > 0: vulns.append(existing_vuln) - return vulns \ No newline at end of file + return vulns diff --git a/introduction/playground/A6/utility.py b/introduction/playground/A6/utility.py index dd8694e6..34e1461d 100644 --- a/introduction/playground/A6/utility.py +++ b/introduction/playground/A6/utility.py @@ -1,14 +1,14 @@ -import requests - -def check_vuln(list_of_modules)->list: - vulns = [] - for i in list_of_modules: - k = i.split("==") - url = f"https://pypi.org/pypi/{k[0]}/{k[1]}/json" - response = requests.get(url) - response.raise_for_status() - info = response.json() - existing_vuln = info['vulnerabilities'] - if len(existing_vuln) > 0: - vulns.append(existing_vuln) - return vulns \ No newline at end of file +from security import safe_requests + +def check_vuln(list_of_modules)->list: + vulns = [] + for i in list_of_modules: + k = i.split("==") + url = f"https://pypi.org/pypi/{k[0]}/{k[1]}/json" + response = safe_requests.get(url) + response.raise_for_status() + info = response.json() + existing_vuln = info['vulnerabilities'] + if len(existing_vuln) > 0: + vulns.append(existing_vuln) + return vulns diff --git a/requirements.txt b/requirements.txt index ac10cef8..8405c571 100644 --- a/requirements.txt +++ b/requirements.txt @@ -34,3 +34,4 @@ zipp==3.8.0 security==1.2.1 \ --hash=sha256:4ca5f8cfc6b836e2192a84bb5a28b72c17f3cd1abbfe3281f917394c6e6c9238 --hash=sha256:0a9dc7b457330e6d0f92bdae3603fecb85394beefad0fd3b5058758a58781ded +security==1.3.0