feat(advisories): add advisories init to create an empty offline database#847
Open
ELHart05 wants to merge 2 commits into
Open
feat(advisories): add advisories init to create an empty offline database#847ELHart05 wants to merge 2 commits into
advisories init to create an empty offline database#847ELHart05 wants to merge 2 commits into
Conversation
…tabase Air-gapped users who cannot reach OSV to run `advisories sync` had no supported way to get a correctly-shaped advisory database. This adds `cve-lite advisories init [--output <path>]`, which writes an empty SQLite database with the current schema and no data. Users populate it from their own sources and scan with `--offline-db`, exactly as outlined in the issue thread. The command refuses to overwrite an existing file, so a populated database is never clobbered. It reuses the existing LocalAdvisoryDatabase schema and path resolution, so the file is identical in shape to one produced by `advisories sync`. Closes OWASP#695
… in tests
Importing the advisories-init module statically from index.ts pulled
getDefaultAdvisoryDbPath into index's static import graph, which broke
named-export linking under the cache-busting
`import('../src/index.ts?test=...')` that cli-integration.test.ts uses.
Load the module on demand inside the handler, the same way the overrides
command is loaded, so it links against a fully evaluated osv-sync at call
time. Runtime behavior is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
cve-lite advisories init [--output <path>], which creates an empty local advisory database with the current schema and no data. It is meant for air-gapped users who cannot runadvisories syncbecause outbound access to OSV is blocked: they runinit, populate the database from their own sources with any SQLite client, and scan with--offline-db.Why this change
Issue #695: in an air-gapped or SSL-inspected corporate environment,
advisories synccannot reach OSV, so there was no supported way to get a database with the shape the scanner expects. In the thread you proposed exactly this command ("a newcve-lite advisories initcommand that creates an empty SQLite DB with the correct schema and no data"), and the reporter confirmed it fits their use case. This implements that.What changed
advisories initsubcommand, parsed alongsideadvisories syncand sharing its--outputoption (defaults to the standard advisory DB path).initAdvisoryDatabase()insrc/cli/advisories-init.tsopens a writableLocalAdvisoryDatabase, which runs the existingCREATE TABLE IF NOT EXISTSschema, then closes it. No new schema and no import pipeline.Validation
npm run build(stricttsc) passes.initAdvisoryDatabasecreates a readable, empty, correctly-shaped database and throws on an existing file;parseArgsrecognizesadvisories initand its--output. The test-hygiene pretest gate passes.advisories init --output x.dbcreates the file and prints next steps; re-running errors;--offline-db x.dbthen scans a project against the empty database and reports no findings without any network calls.User-facing impact
Does this change:
Adds a new
advisories initcommand; it does not change scanning, output formatting, or JSON output.Notes
When you scan with a freshly initialized (or self-populated) database, the offline freshness check still prints "no recorded sync timestamp. Re-run
cve-lite advisories sync", because the metadata row is empty. That advice is a little off for a user-managed database. I kept it out of this PR to stay focused, but happy to refine that message in a follow-up if you would like.Closes #695