Skip to content

Commit

Permalink
feat: support non-enumerated ecosystem version queries on prod instan…
Browse files Browse the repository at this point in the history
…ce (#2530)

Issue: #2401
Enable API queries for specific versions in non-enumerated ecosystems
(Rocky Linux, AlmaLinux, Chainguard, and Wolfi) on the production
instance. This change will not affect queries for other ecosystems.
  • Loading branch information
hogo6002 authored Aug 29, 2024
1 parent f214055 commit 2ebc210
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 5 deletions.
7 changes: 2 additions & 5 deletions gcp/api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1185,10 +1185,9 @@ def query_by_version(context: QueryContext,

ecosystem_info = ecosystems.get(ecosystem)
is_semver = ecosystem_info and ecosystem_info.is_semver
supports_ordering = ecosystem_info and ecosystem_info.supports_ordering
supports_comparing = ecosystem_info and ecosystem_info.supports_comparing

bugs = []
project = get_gcp_project()
if ecosystem:
if is_semver:
# Ecosystem supports semver only.
Expand All @@ -1202,10 +1201,8 @@ def query_by_version(context: QueryContext,
for bug in new_bugs:
if bug not in bugs:
bugs.append(bug)

elif project == 'oss-vdb-test' and supports_ordering:
elif supports_comparing:
# Query for non-enumerated ecosystems.

bugs = yield _query_by_comparing_versions(context, query, ecosystem,
version)
else:
Expand Down
4 changes: 4 additions & 0 deletions osv/ecosystems/alma_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ def enumerate_versions(self,
last_affected=None,
limits=None):
raise NotImplementedError('Ecosystem helper does not support enumeration')

@property
def supports_comparing(self):
return True
4 changes: 4 additions & 0 deletions osv/ecosystems/chainguard.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ def enumerate_versions(self,
last_affected=None,
limits=None):
raise NotImplementedError('Ecosystem helper does not support enumeration')

@property
def supports_comparing(self):
return True
6 changes: 6 additions & 0 deletions osv/ecosystems/helper_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ def is_semver(self):
def supports_ordering(self):
return True

@property
def supports_comparing(self):
"""Determines whether to use affected version range comparison
for API queries."""
return False


class OrderingUnsupportedEcosystem(Ecosystem):
"""Placeholder ecosystem helper for unimplemented ecosystems."""
Expand Down
4 changes: 4 additions & 0 deletions osv/ecosystems/rocky_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ def enumerate_versions(self,
last_affected=None,
limits=None):
raise NotImplementedError('Ecosystem helper does not support enumeration')

@property
def supports_comparing(self):
return True
4 changes: 4 additions & 0 deletions osv/ecosystems/wolfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ def enumerate_versions(self,
last_affected=None,
limits=None):
raise NotImplementedError('Ecosystem helper does not support enumeration')

@property
def supports_comparing(self):
return True

0 comments on commit 2ebc210

Please sign in to comment.