Skip to content

Commit

Permalink
to update cve-search api url (#10)
Browse files Browse the repository at this point in the history
* to change unit test to pytest

* to update cve-search api url

* to fix unit test failure
  • Loading branch information
wyougithub authored Sep 19, 2022
1 parent 0bf39cd commit 6c8e2ed
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions openwebvulndb/common/cve.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def load_mapping(self, *args, **kwargs):
def read_file(self, file_name):
with open(file_name, "r") as fp:
data = json.load(fp)
for entry in data:
for entry in data.get('results'):
self.read_one(entry)

async def read_api(self, url):
Expand All @@ -74,7 +74,7 @@ async def read_api(self, url):

async def read_one_from_api(self, cve_id):
try:
url = "https://cve.circl.lu/api/cve/" + cve_id
url = "https://cvepremium.circl.lu/api/cve/" + cve_id
async with self.session.get(url) as response:
entry = await response.json()
if entry is None:
Expand Down
2 changes: 1 addition & 1 deletion openwebvulndb/common/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async def consume(self, n):
if self.timeout_per_job is not None:
task = self.loop.create_task(coroutine(*args, **kwargs))
try:
with async_timeout.timeout(timeout=self.timeout_per_job):
with async_timeout.timeout(self.timeout_per_job):
await task
except asyncio.TimeoutError:
logger.warn("Job timed out in %s: %s, %s", self.name, args, kwargs)
Expand Down
2 changes: 1 addition & 1 deletion openwebvulndb/wordpress/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def load_cve(loop, cve_reader, input_file):
if input_file:
cve_reader.read_file(input_file)
else:
loop.run_until_complete(cve_reader.read_api("http://cve.circl.lu/api/search/wordpress/wordpress"))
loop.run_until_complete(cve_reader.read_api("http://cvepremium.circl.lu/api/search/wordpress/wordpress"))


def change_version_format(storage):
Expand Down
2 changes: 1 addition & 1 deletion tests/common_test/cve_reader_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ async def test_read_one_from_api(self):

await self.reader.read_one_from_api(entry.id)

self.reader.session.get.assert_called_once_with("https://cve.circl.lu/api/cve/" + entry.id)
self.reader.session.get.assert_called_once_with("https://cvepremium.circl.lu/api/cve/" + entry.id)
# Make sure the cve entry has been converted to the usual format for the vulnerable configuration.
self.reader.read_one.assert_called_once_with(
{"id": "CVE-2017-1234", "cvss": 4.3,
Expand Down

0 comments on commit 6c8e2ed

Please sign in to comment.