Repository navigation
Record parser-reported manifest kind in on-demand snapshots - #318
Merged
Merged
Conversation
`list --commit` on a commit with no stored snapshot calls
IndexCommitSnapshot, which converts each analyzer.Change to a
database.SnapshotInfo and hands the batch to StoreSnapshot. SnapshotInfo
had no Kind field, so the analyzer's Kind was dropped, and
StoreSnapshot guessed at manifests.kind:
kind := "manifest"
if s.Integrity != "" {
kind = "lockfile"
}
That is wrong for any lockfile format without per-entry hashes
(Gemfile.lock without CHECKSUMS, Cargo.lock v1/v2, mix.lock, older
yarn.lock) and wrong the other way for a manifest that carries an
integrity value. The full-index path via BatchWriter.ensureManifests
already writes the parser's kind, so the two paths disagreed and
whichever inserted the manifests row first won.
Add Kind to SnapshotInfo, populate it in IndexCommitSnapshot, and write
it directly in StoreSnapshot. The vulns test that seeded snapshots via
StoreSnapshot now sets Kind explicitly since the vuln query filters on
m.kind = 'lockfile'.
There was a problem hiding this comment.
Pull request overview
This PR fixes a mismatch between the full-index path and the on-demand list --commit indexing path by ensuring the parser-reported manifest kind (manifest vs lockfile) is persisted into manifests.kind instead of being inferred from snapshot integrity data.
Changes:
- Add
Kindtodatabase.SnapshotInfoand populate it inRepository.IndexCommitSnapshot. - Update
DB.StoreSnapshotto writemanifests.kindfromSnapshotInfo.Kind(removing the integrity-based heuristic). - Add a regression test covering a lockfile format without per-entry hashes (Gemfile.lock without CHECKSUMS) and update an existing vuln test to set Kind explicitly.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/git/query.go | Threads analyzer Change.Kind into SnapshotInfo for on-demand snapshot indexing. |
| internal/git/query_test.go | New regression test asserting on-demand indexing records correct manifests.kind for Gemfile vs Gemfile.lock. |
| internal/database/queries.go | Removes integrity-based kind guessing; inserts manifest rows using SnapshotInfo.Kind. |
| internal/database/batch_writer.go | Extends SnapshotInfo with a Kind field to support the on-demand snapshot path. |
| cmd/vulns_test.go | Updates test snapshots to set Kind explicitly after heuristic removal. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
list --commiton a commit with no stored snapshot callsIndexCommitSnapshot, which converts eachanalyzer.Changeto adatabase.SnapshotInfoand hands the batch toStoreSnapshot.SnapshotInfohad noKindfield, so the analyzer's kind was dropped, andStoreSnapshotguessed atmanifests.kind:That is wrong for any lockfile format without per-entry hashes (
Gemfile.lockwithoutCHECKSUMS,Cargo.lockv1/v2,mix.lock, olderyarn.lock) and wrong the other way for a manifest that carries an integrity value. The full-index path viaBatchWriter.ensureManifestsalready writes the parser's kind, so the two paths disagreed and whichever inserted themanifestsrow first won.diff --kind lockfile(#301) and the vuln query both filter on this column.Add
KindtoSnapshotInfo, populate it inIndexCommitSnapshot, and write it directly inStoreSnapshot.TestGetVulnsAtCommitAppliesEcosystemConfignow setsKindexplicitly since it was relying on the removed heuristic.Existing databases where
list --commitcreated amanifestsrow beforeinitwill keep the wrongkinduntil reindexed; both write paths skip when the row already exists.