Skip to content

Conversation

@G-Rath
Copy link
Owner

@G-Rath G-Rath commented Aug 27, 2025

This introduces a new "smart" database for zips provided by osv.dev that uses the modified_id.csv file 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.zip for 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

@G-Rath G-Rath changed the base branch from main to scalibr/use-extractors August 27, 2025 02:34
@G-Rath G-Rath requested a review from Copilot August 27, 2025 02:35

This comment was marked as outdated.

Repository owner deleted a comment from Copilot AI Aug 27, 2025
@G-Rath G-Rath requested a review from Copilot August 27, 2025 02:44

This comment was marked as outdated.

@G-Rath G-Rath requested a review from Copilot August 27, 2025 02:59

This comment was marked as outdated.

@G-Rath G-Rath requested a review from Copilot August 27, 2025 03:04

This comment was marked as outdated.

@G-Rath G-Rath force-pushed the scalibr/use-extractors branch 5 times, most recently from 05588d9 to 8d4bea2 Compare September 2, 2025 21:43
@G-Rath G-Rath force-pushed the new-smart-db branch 2 times, most recently from ef16782 to a66d469 Compare September 3, 2025 01:57
@G-Rath G-Rath requested a review from Copilot September 3, 2025 01:58

This comment was marked as outdated.

Copy link

Copilot AI left a 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 SmartDB type 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-smart flag

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.

Comment on lines +233 to +241
body, err = io.ReadAll(resp.Body)

if err != nil {
return err
}

err = db.cacheFile(id+".json", body)

return err
Copy link

Copilot AI Sep 3, 2025

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 }.

Copilot uses AI. Check for mistakes.
Comment on lines +231 to +234
var body []byte

body, err = io.ReadAll(resp.Body)

Copy link

Copilot AI Sep 3, 2025

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.

Suggested change
var body []byte
body, err = io.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)

Copilot uses AI. Check for mistakes.
@G-Rath G-Rath force-pushed the scalibr/use-extractors branch 2 times, most recently from 7ac62bd to 2858bd8 Compare September 21, 2025 22:54
@G-Rath G-Rath force-pushed the scalibr/use-extractors branch from 2858bd8 to 0b63266 Compare September 21, 2025 23:03
@G-Rath G-Rath force-pushed the new-smart-db branch 2 times, most recently from 82d7ffc to 54da9dd Compare September 21, 2025 23:12
@G-Rath G-Rath force-pushed the scalibr/use-extractors branch 6 times, most recently from f5babd9 to d5a7cc0 Compare December 2, 2025 22:56
@G-Rath G-Rath force-pushed the scalibr/use-extractors branch from d5a7cc0 to 1862eee Compare December 9, 2025 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants