Skip to content

Only collect data about tracked CVEs - #45247

Merged
sgress454 merged 2 commits into
mainfrom
sgress454/charts-optimization
May 12, 2026
Merged

Only collect data about tracked CVEs#45247
sgress454 merged 2 commits into
mainfrom
sgress454/charts-optimization

Conversation

@sgress454

@sgress454 sgress454 commented May 12, 2026

Copy link
Copy Markdown
Contributor

Related issue: Resolves #45163

Details

Limits CVE data collection to only those CVEs which we report on in the chart. This is a performance optimization necessitated by the large amount of data that bigger fleets may generate. The plan is to implement a data compression strategy so that we can go back to collecting full CVE data soon.

Checklist for submitter

If some of the following don't apply, delete the relevant line.

  • Changes file added for user-visible changes in changes/, orbit/changes/ or ee/fleetd-chrome/changes.
    See Changes files for more information.
    n/a, unreleased

  • Input data is properly validated, SELECT * is avoided, SQL injection is prevented (using placeholders for values in statements), JS inline code is prevented especially for url redirects, and untrusted data interpolated into shell scripts/commands is validated against shell metacharacters.

Testing

  • Added/updated automated tests
  • QA'd all new/changed functionality manually
    • Ran some collection jobs and verified that only tracked CVEs were represented in "open" rows.
    • Ran load test w/ new code

For unreleased bug fixes in a release candidate, one of:

  • Confirmed that the fix is not expected to adversely impact load test results
    should improve results!
  • Alerted the release DRI if additional load testing is needed

Summary by CodeRabbit

  • Enhancements
    • CVE vulnerability tracking is now scoped to a curated set of critical vulnerabilities, improving the relevance of security impact data displayed across your systems.

Review Change Stack

Copilot AI review requested due to automatic review settings May 12, 2026 16:28
@sgress454
sgress454 requested a review from a team as a code owner May 12, 2026 16:28

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

Comment thread server/chart/api/chart.go
// titles, unioned with all critical OS vulnerabilities. Used by the CVE
// collector to scope collection to only the CVEs the chart actually
// renders. See TODO in the mysql implementation.
TrackedCriticalCVEs(ctx context.Context) ([]string, error)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method already exists, it's just being added to the Chart bounded-context's datastore interface.

@coderabbitai

coderabbitai Bot commented May 12, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

This PR scopes CVE vulnerability dataset collection to a curated set of critical CVEs to improve performance under large datasets. The DatasetStore interface is updated with a TrackedCriticalCVEs method returning the critical CVE IDs and AffectedHostIDsByCVE now accepts an explicit CVE filter. The MySQL datastore implements the new contract by filtering queries when CVEs are provided and returning early for empty input. The CVEDataset.Collect method retrieves the tracked critical set and passes it to the host lookup, replacing the previous unconstrained query. Tests verify the tracked CVEs are forwarded correctly and that snapshot semantics are maintained even when the tracked set is empty.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR successfully addresses the linked issue #45163 by implementing CVE tracking scoping to reduce dataset size and improve dashboard performance; all code changes align with resolving the timeout problem.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing CVE collection filtering: interface updates, implementation changes to apply CVE filtering, and corresponding test updates. No unrelated modifications detected.
Title check ✅ Passed The title 'Only collect data about tracked CVEs' clearly and concisely summarizes the main change: the PR limits CVE data collection to only tracked CVEs as a performance optimization, which aligns with all modified files implementing this scoping behavior.
Description check ✅ Passed PR description provides context and rationale but is missing several template items like database migration checks, testing details, and GitOps considerations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sgress454/charts-optimization

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves vulnerability dashboard performance by limiting CVE chart data collection to only the curated/“tracked” critical CVEs that the chart API already scopes to, instead of collecting host impact bitmaps for every CVE affecting any host.

Changes:

  • Updated the chart datastore interfaces and MySQL implementation so AffectedHostIDsByCVE accepts an explicit cves allowlist and short-circuits on an empty set.
  • Updated CVEDataset collection to fetch TrackedCriticalCVEs and collect only those CVEs, while still writing empty snapshots to close stale rows.
  • Added/updated unit tests to verify forwarding of the tracked CVE set and correct behavior when the tracked set is empty.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
server/chart/internal/types/chart.go Updates internal datastore interface for CVE host grouping to accept an explicit CVE allowlist.
server/chart/internal/service/service_test.go Extends collector tests to ensure tracked CVEs are forwarded and empty tracked sets still write snapshots.
server/chart/internal/mysql/charts.go Implements CVE allowlist filtering in the MySQL query and adds early return for empty lists.
server/chart/datasets.go Scopes CVE dataset collection to TrackedCriticalCVEs and preserves snapshot semantics on empty input.
server/chart/api/chart.go Extends DatasetStore with TrackedCriticalCVEs and updates CVE collection API contract.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sgress454 sgress454 changed the title only collect data about tracked CVEs Only collect data about tracked CVEs May 12, 2026
@codecov

codecov Bot commented May 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 10.52632% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.84%. Comparing base (89517cc) to head (f571efe).
⚠️ Report is 54 commits behind head on main.

Files with missing lines Patch % Lines
server/chart/internal/mysql/charts.go 0.00% 15 Missing ⚠️
server/chart/datasets.go 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #45247      +/-   ##
==========================================
+ Coverage   66.81%   66.84%   +0.03%     
==========================================
  Files        2722     2723       +1     
  Lines      218994   219036      +42     
  Branches    10754    10754              
==========================================
+ Hits       146311   146424     +113     
+ Misses      59517    59445      -72     
- Partials    13166    13167       +1     
Flag Coverage Δ
backend 68.71% <10.52%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.


var swArgs, osArgs []any
swWhere := []string{"sc.cve IN (?)"}
osWhere := []string{"osv.cve IN (?)"}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't have to worry about limiting these IN clauses right? I can't remember the max that we hit on mysql, but I think we will be safe here correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wondered the same. Our parameter limit for prepared statements is 65k. Based on the dataset we use in load test (which is based on customer data) there were 832 CVEs matching the criteria, so we've got tons of headroom there.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much smaller than I imagined. Seems like a non-issue.

@sgress454
sgress454 merged commit 24e5baf into main May 12, 2026
57 checks passed
@sgress454
sgress454 deleted the sgress454/charts-optimization branch May 12, 2026 22:58
sgress454 added a commit that referenced this pull request May 13, 2026
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.

Vulnerability dashboard will timeout with larger dataset

3 participants