Improve fixed version daemon - #2830
Open
Hubtrick-Git wants to merge 8 commits into
Open
Conversation
… fast update using copy and staging table, also implemented idead for batch purl matching
…t, filter before preloading tables, make preloads customizable for different use cases
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Suppressed comments (3)
vulndb/scan/purl_comparer.go:105
- GetAffectedComponentsBatch is exported but returns []*candidate where candidate is an unexported type. This makes the public API awkward for callers (they can’t name the type) and typically triggers lint/vet warnings. Consider exporting the type (e.g., Candidate) or returning an exported result type instead.
// wrapper for calling resolve candidates itself with multiple purls
func (comparer *PurlComparer) GetAffectedComponentsBatch(ctx context.Context, purls []packageurl.PackageURL) ([]*candidate, error) {
return comparer.resolveCandidates(ctx, purls)
}
daemons/fixed_version_daemon.go:66
- FetchVulnsToUpdate starts a tracing span but never ends it, which can leak spans and skew tracing data. Add a deferred span.End().
ctx, span := daemonTracer.Start(ctx, "daemon.fixed-versions.FetchVulnsToUpdate")
var fixedVersionJobs []fixedVersionJob
daemons/fixed_version_daemon.go:110
- The deferred rollback block logs "successfully rolled back transaction" based on the outer err variable, so it can log a rollback even after a successful commit. It also shadows err inside the Rollback call, making the intent unclear. Prefer checking the rollback error explicitly and avoid logging a rollback on success.
if err := tx.Rollback(ctx); err != nil && err != pgx.ErrTxClosed {
slog.Error("fatal could not rollback updating transaction, database state possibly inconsistent", "error", err)
}
if err == nil {
slog.Info("successfully rolled back transaction")
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.
Fixed Version Daemon
Changed the approach from a iterative approach processing 1 vuln at a time, to an aggregated processing. More concretely:
Purl Comparer Improvements
In Order to make the fixed version daemon faster, I also made some performance improvements regarding the affected components matching logic:
Disclaimer
When testing against the main database it seems like no vulns need to be updated. After intensively searching for a bug I could not find one. It seems like that the underlying data is just up to date.