Skip to content

Commit

Permalink
fix: mismatch between cvedb.cve_count and nvd_api.total_results (#1670)
Browse files Browse the repository at this point in the history
Co-authored-by: b31ngd3v <[email protected]>
  • Loading branch information
b31ngd3v and b31ngd3v authored May 19, 2022
1 parent 03b58d4 commit 3bb0479
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion cve_bin_tool/nvd_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ async def nvd_count_metadata(session):
cve_count[key["name"]] = int(key["count"])
return cve_count

@staticmethod
def get_reject_count(fetched_data: Dict) -> int:
"""Returns total rejected CVE count"""
all_cve_list = fetched_data["result"]["CVE_Items"]
reject_count = 0
for cve_item in all_cve_list:
if cve_item["cve"]["description"]["description_data"][0][
"value"
].startswith("** REJECT **"):
reject_count += 1
return reject_count

async def get_nvd_params(
self,
time_of_last_update: Union[datetime, None] = None,
Expand Down Expand Up @@ -169,7 +181,10 @@ async def load_nvd_request(self, start_index):

if start_index == 0:
# Update total results in case there is discrepancy between NVD dashboard and API
self.total_results = fetched_data["totalResults"]
reject_count = self.get_reject_count(fetched_data)
self.total_results = (
fetched_data["totalResults"] - reject_count
)
self.all_cve_entries.extend(fetched_data["result"]["CVE_Items"])

elif response.status == 503:
Expand Down

0 comments on commit 3bb0479

Please sign in to comment.