Change: Fix endless loop in NVDApi #1073
Open
+33
−28
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
This PR fixes the endless loop of requests.
Note: The diff looks more complicated than it is. It's actually just changing indentation + inverting an if-clause + the actual fix. I recommend checking the commits separately.
Why
Because we should stop requesting results when there aren't any more available.
You can reproduce the issue with:
It is expected that this will send two requests: One returning 2.000 results and another one returning 1.625 results.
Pontos however keeps sending requests, because
self._downloaded_result
(2.000 + 1.625) <self._current_request_results
(247.625), even though the API doesn't return any more:How
Tested using the Python snippet above and using CVE DB Updater of vt-cve-library.
References
Checklist