Skip to content

Commit

Permalink
fix (API): add enumeration version check (#2452)
Browse files Browse the repository at this point in the history
- Added affected version check for the new API query approach.
- Removed some logs that were added previously for testing purposes.
  • Loading branch information
hogo6002 authored Aug 6, 2024
1 parent fc256ba commit 5044867
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions gcp/api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1065,17 +1065,9 @@ def query_by_version(context: QueryContext,
# Query for non-enumerated ecosystems.
bugs, next_page_token = yield _query_by_comparing_versions(
context, query, ecosystem, version)
logging.info(
'[_query_by_comparing_versions] Package %s '
'at version %s has total %d bugs in %s', package_name or purl,
version, len(bugs), ecosystem)
else:
bugs, next_page_token = yield _query_by_generic_version(
context, query, package_name, ecosystem, purl, version)
logging.info(
'[_query_by_generic_version] Package %s '
'at version %s has total %d bugs in %s', package_name or purl,
version, len(bugs), ecosystem)

else:
logging.warning("Package query without ecosystem specified")
Expand Down Expand Up @@ -1267,7 +1259,11 @@ def _is_affected(ecosystem: str, version: str,
if affected:
return True

return False
# OSV allows users to add affected versions
# that are not covered by affected ranges.
# TODO(gongh@): Move this check before the version range check
# after performance analysis.
return version in affected_package.versions


def main():
Expand Down

0 comments on commit 5044867

Please sign in to comment.