Skip to content

Commit e3465e0

Browse files
terrikopdxjohnny
authored andcommitted
Backport nvd scraping patch
1 parent 1036ed2 commit e3465e0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cve_bin_tool/cvedb.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ class CVEDB(object):
150150
FEED = "https://nvd.nist.gov/vuln/data-feeds"
151151
LOGGER = LOGGER.getChild("CVEDB")
152152
NVDCVE_FILENAME_TEMPLATE = "nvdcve-1.1-{}.json.gz"
153-
META_REGEX = re.compile(r"https:\/\/.*\/json\/.*-[0-9]*\.[0-9]*-[0-9]*\.meta")
153+
META_LINK = "https://nvd.nist.gov"
154+
META_REGEX = re.compile(r"\/feeds\/json\/.*-[0-9]*\.[0-9]*-[0-9]*\.meta")
154155
RANGE_UNSET = ""
155156

156157
def __init__(self, verify=True, feed=None, cachedir=None):
@@ -169,11 +170,12 @@ def nist_scrape(self, feed):
169170
with contextlib.closing(request.urlopen(feed)) as response:
170171
page = response.read().decode()
171172
jsonmetalinks = self.META_REGEX.findall(page)
173+
full_links = [f"{self.META_LINK}{path}" for path in jsonmetalinks]
172174
pool = multiprocessing.Pool()
173175
try:
174176
metadata = dict(
175177
pool.map(
176-
functools.partial(log_traceback, getmeta), tuple(jsonmetalinks)
178+
functools.partial(log_traceback, getmeta), tuple(full_links)
177179
)
178180
)
179181
pool.close()

0 commit comments

Comments
 (0)