Skip to content

Commit c7933c6

Browse files
committed
enable aiohttp client to trust environement for proxy
Signed-off-by: Pierre Tardy <pierre.tardy@renault.com>
1 parent 3688d89 commit c7933c6

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

vulnerabilities/package_managers.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,15 @@ def __init__(self, cache: Mapping[str, Set[str]] = None):
3939
def get(self, package_name: str) -> Set[str]:
4040
return self.cache.get(package_name, set())
4141

42+
def client_session():
43+
return ClientSession(raise_for_status=True, trust_env=True)
4244

4345
class LaunchpadVersionAPI(VersionAPI):
4446

4547
package_type = "deb"
4648

4749
async def load_api(self, pkg_set):
48-
async with ClientSession(raise_for_status=True) as session:
50+
async with client_session() as session:
4951
await asyncio.gather(
5052
*[self.set_api(pkg, session) for pkg in pkg_set if pkg not in self.cache]
5153
)
@@ -82,7 +84,7 @@ class PypiVersionAPI(VersionAPI):
8284
package_type = "pypi"
8385

8486
async def load_api(self, pkg_set):
85-
async with ClientSession(raise_for_status=True) as session:
87+
async with client_session() as session:
8688
await asyncio.gather(
8789
*[self.fetch(pkg, session) for pkg in pkg_set if pkg not in self.cache]
8890
)
@@ -106,7 +108,7 @@ class CratesVersionAPI(VersionAPI):
106108
package_type = "cargo"
107109

108110
async def load_api(self, pkg_set):
109-
async with ClientSession(raise_for_status=True) as session:
111+
async with client_session() as session:
110112
await asyncio.gather(
111113
*[self.fetch(pkg, session) for pkg in pkg_set if pkg not in self.cache]
112114
)
@@ -127,7 +129,7 @@ class RubyVersionAPI(VersionAPI):
127129
package_type = "gem"
128130

129131
async def load_api(self, pkg_set):
130-
async with ClientSession(raise_for_status=True) as session:
132+
async with client_session() as session:
131133
await asyncio.gather(
132134
*[self.fetch(pkg, session) for pkg in pkg_set if pkg not in self.cache]
133135
)
@@ -151,7 +153,7 @@ class NpmVersionAPI(VersionAPI):
151153
package_type = "npm"
152154

153155
async def load_api(self, pkg_set):
154-
async with ClientSession(raise_for_status=True) as session:
156+
async with client_session() as session:
155157
await asyncio.gather(
156158
*[self.fetch(pkg, session) for pkg in pkg_set if pkg not in self.cache]
157159
)
@@ -211,7 +213,7 @@ class MavenVersionAPI(VersionAPI):
211213
package_type = "maven"
212214

213215
async def load_api(self, pkg_set):
214-
async with ClientSession(raise_for_status=True) as session:
216+
async with client_session() as session:
215217
await asyncio.gather(
216218
*[self.fetch(pkg, session) for pkg in pkg_set if pkg not in self.cache]
217219
)
@@ -267,7 +269,7 @@ class NugetVersionAPI(VersionAPI):
267269
package_type = "nuget"
268270

269271
async def load_api(self, pkg_set):
270-
async with ClientSession(raise_for_status=True) as session:
272+
async with client_session() as session:
271273
await asyncio.gather(
272274
*[self.fetch(pkg, session) for pkg in pkg_set if pkg not in self.cache]
273275
)
@@ -305,7 +307,7 @@ class ComposerVersionAPI(VersionAPI):
305307
package_type = "composer"
306308

307309
async def load_api(self, pkg_set):
308-
async with ClientSession(raise_for_status=True) as session:
310+
async with client_session() as session:
309311
await asyncio.gather(
310312
*[self.fetch(pkg, session) for pkg in pkg_set if pkg not in self.cache]
311313
)
@@ -343,7 +345,7 @@ class GitHubTagsAPI(VersionAPI):
343345
package_type = "github"
344346

345347
async def load_api(self, repo_set):
346-
async with ClientSession(raise_for_status=True) as session:
348+
async with client_session() as session:
347349
await asyncio.gather(
348350
*[
349351
self.fetch(owner_repo.lower(), session)
@@ -363,7 +365,7 @@ async def fetch(self, owner_repo: str, session) -> None:
363365

364366
class HexVersionAPI(VersionAPI):
365367
async def load_api(self, pkg_set):
366-
async with ClientSession(raise_for_status=True) as session:
368+
async with client_session() as session:
367369
await asyncio.gather(
368370
*[self.fetch(pkg, session) for pkg in pkg_set if pkg not in self.cache]
369371
)

0 commit comments

Comments
 (0)