Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a convenience redirect to ecosystems.txt #1967

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ Between the data served in OSV and the data converted to OSV the following ecosy
- AlmaLinux
- Alpine
- Android
- Bitnami
- crates.io
- Debian GNU/Linux
- Git ([including C/C++](https://osv.dev/blog/posts/introducing-broad-c-c++-support/))
- GitHub Actions
- Go
- Haskell
Expand All @@ -85,6 +87,7 @@ Between the data served in OSV and the data converted to OSV the following ecosy
- R (CRAN and Bioconductor)
- Rocky Linux
- RubyGems
- SwiftURL

## Data dumps

Expand Down
13 changes: 9 additions & 4 deletions gcp/appengine/frontend_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ def docs():
return redirect('https://google.github.io/osv.dev')


@blueprint.route('/ecosystems')
def ecosystems():
return redirect('https://osv-vulnerabilities.storage.googleapis.com/ecosystems.txt') # pylint: disable=line-too-long


_LIST_ARGS = ['q', 'ecosystem', 'page']


Expand Down Expand Up @@ -302,10 +307,10 @@ def add_source_info(bug, response):
response['source'] = source_repo.link + source_path
response['source_link'] = response['source']
if source_repo.human_link:
ecosystems = bug.ecosystem
bug_ecosystems = bug.ecosystem
bug_id = bug.id()
response['human_source_link'] = render_template_string(
source_repo.human_link, ECOSYSTEMS=ecosystems, BUG_ID=bug_id)
source_repo.human_link, ECOSYSTEMS=bug_ecosystems, BUG_ID=bug_id)


def _commit_to_link(repo_url, commit):
Expand Down Expand Up @@ -346,8 +351,8 @@ def osv_get_ecosystem_counts_cached():
def osv_get_ecosystem_counts() -> dict[str, int]:
"""Get count of vulnerabilities per ecosystem."""
counts = {}
ecosystems = osv_get_ecosystems()
for ecosystem in ecosystems:
ecosystem_names = osv_get_ecosystems()
for ecosystem in ecosystem_names:
if ':' in ecosystem:
# Count by the base ecosystem index. Otherwise we'll overcount as a
# single entry may refer to multiple sub-ecosystems.
Expand Down