-
Notifications
You must be signed in to change notification settings - Fork 9
feat: introduce a smarter database for osv.dev zips #323
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
base: scalibr/use-extractors
Are you sure you want to change the base?
Conversation
05588d9 to
8d4bea2
Compare
ef16782 to
a66d469
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Introduces a new "smart" database for osv.dev zips that uses the modified_id.csv file for selective updates, combining the benefits of zip and directory-based databases for improved performance.
- Implements
SmartDBtype that uses CSV file to track modified advisories for incremental updates - Adds cache directory management with fallback from user cache directory to temp directory
- Integrates smart database option into CLI with
--be-smartflag
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/database/smart.go | New SmartDB implementation with CSV-based incremental updates |
| pkg/database/smart_test.go | Comprehensive test suite for SmartDB functionality |
| pkg/database/zip.go | Refactored cache directory handling and extracted setupCacheDirectory function |
| pkg/database/zip_test.go | Updated tests to use CacheDirectory config and added withSummary helper |
| pkg/database/config.go | Added CacheDirectory field and smart database type support |
| main.go | Added --be-smart CLI flag and SmartDB description logic |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| body, err = io.ReadAll(resp.Body) | ||
|
|
||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| err = db.cacheFile(id+".json", body) | ||
|
|
||
| return err |
Copilot
AI
Sep 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable declaration and assignment can be simplified by combining lines 232 and 234-236 into a single statement: body, err := io.ReadAll(resp.Body) and then if err != nil { return err }.
| var body []byte | ||
|
|
||
| body, err = io.ReadAll(resp.Body) | ||
|
|
Copilot
AI
Sep 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary variable pre-declaration. Use short variable declaration body, err := io.ReadAll(resp.Body) instead of declaring body as var body []byte and then assigning to it.
| var body []byte | |
| body, err = io.ReadAll(resp.Body) | |
| body, err := io.ReadAll(resp.Body) |
16d19bf to
440001b
Compare
7ac62bd to
2858bd8
Compare
2858bd8 to
0b63266
Compare
82d7ffc to
54da9dd
Compare
f5babd9 to
d5a7cc0
Compare
d5a7cc0 to
1862eee
Compare
This introduces a new "smart" database for zips provided by osv.dev that uses the
modified_id.csvfile stored in the ecosystems bucket to selectively update advisories, effectively combining the zip and directory based databases.If the database isn't available, then it will be initialized using the
all.zipfor the particular ecosystem, otherwise we will just download the advisories that have changed since the database was last modified.This should be at most as slow as the zip database, but hopefully most of the time be faster