Skip to content

Commit 86eef3b

Browse files
authored
Merge pull request #411 from tardyp/aiohttpclient
enable aiohttp client to trust environement for proxy
2 parents 0b7dc3d + ca32550 commit 86eef3b

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

vulnerabilities/package_managers.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,16 @@ def get(self, package_name: str) -> Set[str]:
4040
return self.cache.get(package_name, set())
4141

4242

43+
def client_session():
44+
return ClientSession(raise_for_status=True, trust_env=True)
45+
46+
4347
class LaunchpadVersionAPI(VersionAPI):
4448

4549
package_type = "deb"
4650

4751
async def load_api(self, pkg_set):
48-
async with ClientSession(raise_for_status=True) as session:
52+
async with client_session() as session:
4953
await asyncio.gather(
5054
*[self.set_api(pkg, session) for pkg in pkg_set if pkg not in self.cache]
5155
)
@@ -82,7 +86,7 @@ class PypiVersionAPI(VersionAPI):
8286
package_type = "pypi"
8387

8488
async def load_api(self, pkg_set):
85-
async with ClientSession(raise_for_status=True) as session:
89+
async with client_session() as session:
8690
await asyncio.gather(
8791
*[self.fetch(pkg, session) for pkg in pkg_set if pkg not in self.cache]
8892
)
@@ -106,7 +110,7 @@ class CratesVersionAPI(VersionAPI):
106110
package_type = "cargo"
107111

108112
async def load_api(self, pkg_set):
109-
async with ClientSession(raise_for_status=True) as session:
113+
async with client_session() as session:
110114
await asyncio.gather(
111115
*[self.fetch(pkg, session) for pkg in pkg_set if pkg not in self.cache]
112116
)
@@ -127,7 +131,7 @@ class RubyVersionAPI(VersionAPI):
127131
package_type = "gem"
128132

129133
async def load_api(self, pkg_set):
130-
async with ClientSession(raise_for_status=True) as session:
134+
async with client_session() as session:
131135
await asyncio.gather(
132136
*[self.fetch(pkg, session) for pkg in pkg_set if pkg not in self.cache]
133137
)
@@ -151,7 +155,7 @@ class NpmVersionAPI(VersionAPI):
151155
package_type = "npm"
152156

153157
async def load_api(self, pkg_set):
154-
async with ClientSession(raise_for_status=True) as session:
158+
async with client_session() as session:
155159
await asyncio.gather(
156160
*[self.fetch(pkg, session) for pkg in pkg_set if pkg not in self.cache]
157161
)
@@ -211,7 +215,7 @@ class MavenVersionAPI(VersionAPI):
211215
package_type = "maven"
212216

213217
async def load_api(self, pkg_set):
214-
async with ClientSession(raise_for_status=True) as session:
218+
async with client_session() as session:
215219
await asyncio.gather(
216220
*[self.fetch(pkg, session) for pkg in pkg_set if pkg not in self.cache]
217221
)
@@ -267,7 +271,7 @@ class NugetVersionAPI(VersionAPI):
267271
package_type = "nuget"
268272

269273
async def load_api(self, pkg_set):
270-
async with ClientSession(raise_for_status=True) as session:
274+
async with client_session() as session:
271275
await asyncio.gather(
272276
*[self.fetch(pkg, session) for pkg in pkg_set if pkg not in self.cache]
273277
)
@@ -305,7 +309,7 @@ class ComposerVersionAPI(VersionAPI):
305309
package_type = "composer"
306310

307311
async def load_api(self, pkg_set):
308-
async with ClientSession(raise_for_status=True) as session:
312+
async with client_session() as session:
309313
await asyncio.gather(
310314
*[self.fetch(pkg, session) for pkg in pkg_set if pkg not in self.cache]
311315
)
@@ -343,7 +347,7 @@ class GitHubTagsAPI(VersionAPI):
343347
package_type = "github"
344348

345349
async def load_api(self, repo_set):
346-
async with ClientSession(raise_for_status=True) as session:
350+
async with client_session() as session:
347351
await asyncio.gather(
348352
*[
349353
self.fetch(owner_repo.lower(), session)
@@ -363,7 +367,7 @@ async def fetch(self, owner_repo: str, session) -> None:
363367

364368
class HexVersionAPI(VersionAPI):
365369
async def load_api(self, pkg_set):
366-
async with ClientSession(raise_for_status=True) as session:
370+
async with client_session() as session:
367371
await asyncio.gather(
368372
*[self.fetch(pkg, session) for pkg in pkg_set if pkg not in self.cache]
369373
)

0 commit comments

Comments
 (0)