Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NVD is not working. #906

Closed
imsahil007 opened this issue Sep 20, 2020 · 7 comments · Fixed by #908
Closed

NVD is not working. #906

imsahil007 opened this issue Sep 20, 2020 · 7 comments · Fixed by #908
Milestone

Comments

@imsahil007
Copy link
Contributor

Every time I try to run tests for test/test_ci.py. The tests fail for curl with this assertion error.
I tried creating pulling a fresh copy of the repo. But the tests still failed.

I noticed that the tests are failing for codecov as well.

image

@terriko
Copy link
Contributor

terriko commented Sep 22, 2020

0 != 0, eh?
I'm heading out shortly for an appointment, but that's an interesting one. I'll try to get to it this afternoon.

@terriko
Copy link
Contributor

terriko commented Sep 22, 2020

I am indeed getting some tests failures locally, but more than just this one. It looks like I'm getting some nvd issues that are probably masking what's going on.

@imsahil007
Copy link
Contributor Author

imsahil007 commented Sep 23, 2020

I ran the tests again. Nothing seems to work right now. I tried scanning some binaries. You can see the output here

@imsahil007
Copy link
Contributor Author

image

@imsahil007 imsahil007 changed the title Tests for TestCLI.test_binary_curl_7_20_0 is failing NVD is not working. Sep 23, 2020
@anthonyharrison
Copy link
Contributor

@terriko @imsahil007 I have got to the bottom of this after a bit of digging around the cvedb.py module which has revealed that the problem is with the way the NVD page is being scrapped off the web. I don't know if the format of the URLs has changed recently but the feeds are now relative URLs (i.e. /feeds/....) rather than absolute URLs (https://nvd.nist.gov/feeds/...). Unfortunately the processing of the URLs assumes that they are absolute URLs so when the URLs are passed to the rountines which download the CVEs, as there are no URLs which have matched the regular expression, no data is retrieved.

A simple hack is to make the following change to the nist_scrape routine to make the meta_url absolute

async def nist_scrape(self, session):
    async with session.get(self.feed) as response:
        page = await response.text()
        json_meta_links = self.META_REGEX.findall(page)
        return dict(
            await asyncio.gather(
                *[self.getmeta(session, "https://nvd.nist.gov"+meta_url) for meta_url in json_meta_links]
            )
        )

The META_REGEX needs to also change to

META_REGEX = re.compile(r"/./json/.-[0-9].[0-9]-[0-9]*.meta")

@imsahil007
Copy link
Contributor Author

@terriko @imsahil007 I have got to the bottom of this after a bit of digging around the cvedb.py module which has revealed that the problem is with the way the NVD page is being scrapped off the web. I don't know if the format of the URLs has changed recently but the feeds are now relative URLs (i.e. /feeds/....) rather than absolute URLs (https://nvd.nist.gov/feeds/...). Unfortunately the processing of the URLs assumes that they are absolute URLs so when the URLs are passed to the rountines which download the CVEs, as there are no URLs which have matched the regular expression, no data is retrieved.

A simple hack is to make the following change to the nist_scrape routine to make the meta_url absolute

async def nist_scrape(self, session):
    async with session.get(self.feed) as response:
        page = await response.text()
        json_meta_links = self.META_REGEX.findall(page)
        return dict(
            await asyncio.gather(
                *[self.getmeta(session, "https://nvd.nist.gov"+meta_url) for meta_url in json_meta_links]
            )
        )

The META_REGEX needs to also change to

META_REGEX = re.compile(r"/./json/.-[0-9].[0-9]-[0-9]*.meta")

Yeah, I noticed that as well. Thanks for your input @anthonyharrison

@terriko
Copy link
Contributor

terriko commented Sep 30, 2020

Thank you! I got as far as seeing that nvd wasn't working at all, but hadn't had a chance to debug why. This is incredibly helpful.

@terriko terriko added this to the 2.0 milestone Sep 30, 2020
terriko pushed a commit that referenced this issue Oct 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants