client: fix shadow bug in cache index retrieval

The bug results in potentially empty index being returned. When index is
stale for more than 2 hours, a new index is fetched remotely. If the
remote server says there were no changes in the meantime, the cached
index is returned, which can be empty due to shadowing.

Change-Id: I2267d936d21096c574d1c88f6c83ccc916c6c78f
Reviewed-on: https://go-review.googlesource.com/c/vulndb/+/349189
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2 files changed
tree: f37ea11ba69f112ac32bb1dd9070e28a973d2c44
  1. client/
  2. cmd/
  3. deploy/
  4. osv/
  5. report/
  6. reports/
  7. AUTHORS
  8. CONTRIBUTING.md
  9. CONTRIBUTORS
  10. format.md
  11. go.mod
  12. go.sum
  13. LICENSE
  14. lint_test.go
  15. new-vuln.sh
  16. PATENTS
  17. README.md
  18. template
  19. triaged-cve-list
README.md

The Go Vulnerability Database golang.org/x/vulndb

This repository is a prototype of the Go Vulnerability Database. Read the Draft Design.

Neither the code, nor the data, nor the existence of this repository is to be considered stable until an approved proposal.

Important: vulnerability entries in this repository are represented in an internal, unstable format that can and will change without notice.

Consuming database entries

Database clients must not rely on the contents of this repository. Instead, they can access the tree of JSON entries rooted at

https://storage.googleapis.com/go-vulndb/

An index.json file maps module paths to last modified timestamps (link).

For each module, a NAME.json file contains a list of vulnerability entries (example).

Note that this path and format are provisional and likely to change until an approved proposal.

Packages

Some of these packages can probably be coalesced, but for now are easier to work on in a more segmented fashion.

  • report provides a package for parsing and linting TOML reports
  • osv provides a package for generating OSV-style JSON vulnerability entries from a report.Report
  • client contains a client for accessing HTTP/fs based vulnerability databases, as well as a minimal caching implementation
  • cmd/gendb provides a tool for converting TOML reports into JSON database
  • cmd/genhtml provides a tool for converting TOML reports into a HTML website
  • cmd/linter provides a tool for linting individual reports
  • cmd/report2cve provides a tool for converting TOML reports into JSON CVEs

License

Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.

Database entries available at https://storage.googleapis.com/go-vulndb/ are distributed under the terms of the CC-BY 4.0 license.