Skip to content

Commit 3bb0479

Browse files
b31ngd3vb31ngd3v
andauthored
fix: mismatch between cvedb.cve_count and nvd_api.total_results (#1670)
Co-authored-by: b31ngd3v <[email protected]>
1 parent 03b58d4 commit 3bb0479

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

cve_bin_tool/nvd_api.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,18 @@ async def nvd_count_metadata(session):
8383
cve_count[key["name"]] = int(key["count"])
8484
return cve_count
8585

86+
@staticmethod
87+
def get_reject_count(fetched_data: Dict) -> int:
88+
"""Returns total rejected CVE count"""
89+
all_cve_list = fetched_data["result"]["CVE_Items"]
90+
reject_count = 0
91+
for cve_item in all_cve_list:
92+
if cve_item["cve"]["description"]["description_data"][0][
93+
"value"
94+
].startswith("** REJECT **"):
95+
reject_count += 1
96+
return reject_count
97+
8698
async def get_nvd_params(
8799
self,
88100
time_of_last_update: Union[datetime, None] = None,
@@ -169,7 +181,10 @@ async def load_nvd_request(self, start_index):
169181

170182
if start_index == 0:
171183
# Update total results in case there is discrepancy between NVD dashboard and API
172-
self.total_results = fetched_data["totalResults"]
184+
reject_count = self.get_reject_count(fetched_data)
185+
self.total_results = (
186+
fetched_data["totalResults"] - reject_count
187+
)
173188
self.all_cve_entries.extend(fetched_data["result"]["CVE_Items"])
174189

175190
elif response.status == 503:

0 commit comments

Comments
 (0)