Skip to content

Commit f9da836

Browse files
authored
Merge pull request #558 from tardyp/client_session
DebianVersionAPI: automatic support for proxy
2 parents a0a733a + e3375b5 commit f9da836

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ environment variable with::
219219

220220
export GH_TOKEN=yourgithubtoken
221221

222+
If you are running behind a proxy, you will need to setup the standard ``https_proxy`` variable.
223+
224+
export https_proxy=https?://<proxy>:<port>
222225

223226
See `GitHub docs
224227
<https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token>`_

vulnerabilities/package_managers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ async def fetch(self, pkg, session):
7676
raise NotImplementedError
7777

7878

79-
def client_session():
80-
return ClientSession(raise_for_status=True, trust_env=True)
79+
def client_session(**kwargs):
80+
# trust_env is important so that https_proxy environment variable is used
81+
# in proxy protected environments
82+
return ClientSession(raise_for_status=True, trust_env=True, **kwargs)
8183

8284

8385
class LaunchpadVersionAPI(VersionAPI):
@@ -221,9 +223,7 @@ class DebianVersionAPI(VersionAPI):
221223
async def load_api(self, pkg_set):
222224
# Need to set the headers, because the Debian API upgrades
223225
# the connection to HTTP 2.0
224-
async with ClientSession(
225-
raise_for_status=True, headers={"Connection": "keep-alive"}
226-
) as session:
226+
async with client_session(headers={"Connection": "keep-alive"}) as session:
227227
await asyncio.gather(
228228
*[self.fetch(pkg, session) for pkg in pkg_set if pkg not in self.cache]
229229
)

0 commit comments

Comments
 (0)