|
35 | 35 | DISK_LOCATION_DEFAULT = os.path.join(os.path.expanduser("~"), ".cache", "cve-bin-tool")
|
36 | 36 | DBNAME = "cve.db"
|
37 | 37 | OLD_CACHE_DIR = os.path.join(os.path.expanduser("~"), ".cache", "cvedb")
|
38 |
| -# Workaround for issue #1081 |
39 |
| -RATE_LIMITER = asyncio.BoundedSemaphore(2) |
40 | 38 |
|
41 | 39 |
|
42 | 40 | class CVEDB:
|
@@ -132,9 +130,9 @@ async def cache_update(self, session, url, sha, chunk_size=16 * 1024):
|
132 | 130 | self.LOGGER.debug(f"Correct SHA for {filename}")
|
133 | 131 | return
|
134 | 132 | self.LOGGER.debug(f"Updating CVE cache for {filename}")
|
135 |
| - async with RATE_LIMITER: |
136 |
| - async with session.get(url) as response: |
137 |
| - gzip_data = await response.read() |
| 133 | + |
| 134 | + async with session.get(url) as response: |
| 135 | + gzip_data = await response.read() |
138 | 136 | json_data = gzip.decompress(gzip_data)
|
139 | 137 | gotsha = hashlib.sha256(json_data).hexdigest().upper()
|
140 | 138 | async with FileIO(filepath, "wb") as filepath_handle:
|
@@ -193,7 +191,8 @@ async def refresh(self):
|
193 | 191 | self.LOGGER.info("Checking if there is a newer version.")
|
194 | 192 | check_latest_version()
|
195 | 193 | if not self.session:
|
196 |
| - self.session = aiohttp.ClientSession(trust_env=True) |
| 194 | + connector = aiohttp.TCPConnector(limit_per_host=19) |
| 195 | + self.session = aiohttp.ClientSession(connector=connector, trust_env=True) |
197 | 196 | self.LOGGER.info("Downloading CVE data...")
|
198 | 197 | nvd_metadata, curl_metadata = await asyncio.gather(
|
199 | 198 | self.nist_scrape(self.session), self.get_curl_versions(self.session)
|
|
0 commit comments