Skip to content

Add RHEL 8/9/10 simulated hosts to osquery-perf - #44453

Merged
mostlikelee merged 4 commits into
mainfrom
claude/compassionate-galileo-88fc4e
Apr 30, 2026
Merged

Add RHEL 8/9/10 simulated hosts to osquery-perf#44453
mostlikelee merged 4 commits into
mainfrom
claude/compassionate-galileo-88fc4e

Conversation

@mostlikelee

@mostlikelee mostlikelee commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Related issue: Resolves #44452

Summary

Adds three new host templates (rhel_8, rhel_9, rhel_10) plus matching RPM kernel fixtures so osquery-perf can load-test Fleet's RHEL OSV vulnerability scanning path.

  • New templates report platform=rhel, name="Red Hat Enterprise Linux", and major.minor.patch versions (8.10.0, 9.4.0, 10.0.0) — what Fleet's OSV analyzer keys on.
  • New per-major kernel JSON fixtures carry RPM name / version / release, covering kernel package variants (kernel, kernel-core, kernel-modules, kernel-debug-core, ...) so the analyzer's kernel-package mapping is exercised.
  • selectKernels is unified across distros to take []map[string]string; Ubuntu's existing string-format JSON is converted at load time so its on-disk fixture is unchanged.
  • software_linux switch gains a case "rhel": branch that reuses the existing software DB (softwareDB.Ubuntu filtered to rpm_packages once via sync.Once). When the DB is absent, RHEL agents emit kernels + per-host installed software only.
  • Built-in label memberships flipped appropriately (Red Hat + Linux on; Ubuntu/CentOS off).

Checklist for submitter

Testing

  • Added/updated automated tests — N/A, osquery-perf is dev tooling with no test suite (go test ./cmd/osquery-perf/... → ? no test files)
  • QA'd all new/changed functionality manually

Summary by CodeRabbit

  • New Features

    • Added RHEL 8/9/10 support for simulated/osquery agent workloads, including enrollment and fleet detail query templates.
    • Enhanced kernel tracking: kernels now include name, version, and source and support multi-distro preselection and embedded kernel fixtures.
    • Per-host software indexing to include preselected kernels plus installed packages.
  • Bug Fixes

    • Software DB loading now logs a warning and falls back to embedded data instead of failing.

Adds three new host templates (rhel_8, rhel_9, rhel_10) plus matching
RPM kernel fixtures so osquery-perf can load-test Fleet's RHEL OSV
vulnerability scanning. RHEL agents report platform=rhel, realistic
major.minor.patch versions, RPM kernel packages with version+release
fields, and (when --software_db_path is set) RPM software from the
existing software library.
Verified template fields against `orbit shell` on a Red-Hat-family host:

- platform_like: "rhel" (not "rhel fedora")
- codename: "" — osquery does not extract codename for RHEL family;
  the codename instead lives inside the version string
- version: "Red Hat Enterprise Linux release X.Y (Codename)" — full
  human-readable line from /etc/os-release VERSION
- osquery_info.build_distro: "centos7" — reflects the osquery binary's
  build distro, not the host (matches real output)
- os_unix_like now reports `extra` field
- hardware_vendor/model: plausible Dell PowerEdge values
- rpm_packages kernel entries now carry vendor "Red Hat, Inc." and
  arch "x86_64" matching real RHEL output
Running osquery-perf from the repo root previously crashed because the
default --software_db_path is a relative path that only resolves from
cmd/osquery-perf/. macOS, Windows, and Ubuntu all have embedded fallback
fixtures, and RHEL kernels are embedded too — the DB only adds non-kernel
RPM/DEB variety. Downgrade the load failure to a warning and continue
with the embedded fixtures.
@codecov

codecov Bot commented Apr 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 108 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.74%. Comparing base (07e4e7a) to head (8cc1018).
⚠️ Report is 41 commits behind head on main.

Files with missing lines Patch % Lines
cmd/osquery-perf/agent.go 0.00% 108 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #44453      +/-   ##
==========================================
- Coverage   66.75%   66.74%   -0.01%     
==========================================
  Files        2633     2635       +2     
  Lines      211741   212046     +305     
  Branches     9543     9543              
==========================================
+ Hits       141349   141540     +191     
- Misses      57548    57650     +102     
- Partials    12844    12856      +12     
Flag Coverage Δ
backend 68.52% <0.00%> (-0.01%) ⬇️

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.

@mostlikelee
mostlikelee marked this pull request as ready for review April 30, 2026 16:01
@mostlikelee
mostlikelee requested a review from a team as a code owner April 30, 2026 16:01
Copilot AI review requested due to automatic review settings April 30, 2026 16:01

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

@coderabbitai

coderabbitai Bot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Reworks cmd/osquery-perf/agent.go to replace Ubuntu-only deb kernel handling with structured kernel records and multi-distro support (RHEL 8/9/10). Adds embedded RHEL kernel fixtures and new template files for RHEL 8/9/10 enrollment and Fleet query responses. Kernel loaders now emit maps of {name, version, source}, selectKernels accepts and deep-copies these entries, and software_linux handling gains an RHEL path that filters rows with Source == "rpm_packages", builds per-agent cached software indices, and appends selected kernels and host software. Software DB load failures now warn and fall back to embedded data.

Possibly related PRs

  • fleetdm/fleet PR 35756: Adds/extends use of a software database and per-agent cached software indices similar to the DB-backed software selection changes in this PR.
  • fleetdm/fleet PR 34889: Refactors kernel-loading/selection in cmd/osquery-perf/agent.go and embeds kernel manifests, paralleling the kernel selection redesign here.
  • fleetdm/fleet PR 39749: Introduces kernel-only scanning and KernelsOnly filtering for RPM/kernel entries, closely related to the new rpm_packages handling and RHEL kernel preselection.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 44.44% 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
Title check ✅ Passed The PR title clearly and directly summarizes the main change: adding RHEL 8/9/10 simulated host support to osquery-perf.
Description check ✅ Passed The PR description provides a related issue reference, clear summary of changes, implementation details, testing approach, and key rationale for the changes. All major sections are covered.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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 claude/compassionate-galileo-88fc4e

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
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

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

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
cmd/osquery-perf/agent.go (1)

640-641: Use TrimSuffix for exact suffix removal.

Line 640 uses strings.TrimRight(templates.Name(), ".tmpl"), which trims any trailing runes in that set rather than an exact suffix. For example, this would incorrectly remove trailing characters from template names like "foo.t" or "foo.tm". Use TrimSuffix to remove the exact ".tmpl" suffix.

Proposed fix
-	templateBase := strings.TrimRight(templates.Name(), ".tmpl")
+	templateBase := strings.TrimSuffix(templates.Name(), ".tmpl")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmd/osquery-perf/agent.go` around lines 640 - 641, The code uses
strings.TrimRight(templates.Name(), ".tmpl") which removes any of the rune
characters '.' 't' 'm' 'p' from the end instead of the exact suffix; update the
logic that builds templateBase (where templates.Name() is used) to use
strings.TrimSuffix(templates.Name(), ".tmpl") so the ".tmpl" suffix is removed
exactly before calling strings.Cut to derive agentOS and osVariant.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@cmd/osquery-perf/agent.go`:
- Around line 640-641: The code uses strings.TrimRight(templates.Name(),
".tmpl") which removes any of the rune characters '.' 't' 'm' 'p' from the end
instead of the exact suffix; update the logic that builds templateBase (where
templates.Name() is used) to use strings.TrimSuffix(templates.Name(), ".tmpl")
so the ".tmpl" suffix is removed exactly before calling strings.Cut to derive
agentOS and osVariant.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 959af88d-a1e6-417e-968a-8a4f8f2e8a10

📥 Commits

Reviewing files that changed from the base of the PR and between 6db10ee and 0f03084.

⛔ Files ignored due to path filters (1)
  • cmd/osquery-perf/README.md is excluded by !**/*.md
📒 Files selected for processing (7)
  • cmd/osquery-perf/agent.go
  • cmd/osquery-perf/rhel_10-kernels.json
  • cmd/osquery-perf/rhel_10.tmpl
  • cmd/osquery-perf/rhel_8-kernels.json
  • cmd/osquery-perf/rhel_8.tmpl
  • cmd/osquery-perf/rhel_9-kernels.json
  • cmd/osquery-perf/rhel_9.tmpl

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

Adds RHEL 8/9/10 simulated hosts to cmd/osquery-perf so it can load-test Fleet’s RHEL OSV vulnerability scanning path with realistic RPM kernel fixtures and platform metadata.

Changes:

  • Added RHEL 8/9/10 osquery-perf host templates and per-major RPM kernel fixture JSON files.
  • Updated agent.go to support RPM kernel fixtures, unify kernel selection across distros, and add an rhel branch in software_linux.
  • Updated osquery-perf README with RHEL template usage notes and software DB fallback behavior.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
cmd/osquery-perf/agent.go Adds embedded RHEL kernel fixtures, RPM kernel/software handling, unified kernel selection input type, and non-fatal software DB load fallback.
cmd/osquery-perf/README.md Documents supported Linux templates (including RHEL) and optional software DB behavior.
cmd/osquery-perf/rhel_8.tmpl New RHEL 8 host template (platform/labels/kernel_version).
cmd/osquery-perf/rhel_9.tmpl New RHEL 9 host template (platform/labels/kernel_version).
cmd/osquery-perf/rhel_10.tmpl New RHEL 10 host template (platform/labels/kernel_version).
cmd/osquery-perf/rhel_8-kernels.json New RPM kernel fixture list for RHEL 8.
cmd/osquery-perf/rhel_9-kernels.json New RPM kernel fixture list for RHEL 9.
cmd/osquery-perf/rhel_10-kernels.json New RPM kernel fixture list for RHEL 10.

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

Comment thread cmd/osquery-perf/agent.go Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
cmd/osquery-perf/agent.go (1)

3293-3293: 💤 Low value

Consider adding a brief comment explaining the "ubuntu" reuse.

Using RandomSoftwareCount("ubuntu") for RHEL works (since the RPM pool is filtered from softwareDB.Ubuntu), but a short inline comment would clarify this intentional reuse for future maintainers.

-				count := min(softwaredb.RandomSoftwareCount("ubuntu"), len(rpmPool))
+				// Reuse Ubuntu's count distribution since RPM pool is filtered from softwareDB.Ubuntu
+				count := min(softwaredb.RandomSoftwareCount("ubuntu"), len(rpmPool))
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmd/osquery-perf/agent.go` at line 3293, Add a short inline comment above the
count calculation explaining why RandomSoftwareCount("ubuntu") is reused for
RHEL: note that rpmPool is already filtered from softwareDB.Ubuntu so the ubuntu
key intentionally provides the desired distribution; reference the variables and
functions involved (RandomSoftwareCount, rpmPool, softwareDB.Ubuntu) so future
maintainers understand the reuse.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@cmd/osquery-perf/agent.go`:
- Line 3293: Add a short inline comment above the count calculation explaining
why RandomSoftwareCount("ubuntu") is reused for RHEL: note that rpmPool is
already filtered from softwareDB.Ubuntu so the ubuntu key intentionally provides
the desired distribution; reference the variables and functions involved
(RandomSoftwareCount, rpmPool, softwareDB.Ubuntu) so future maintainers
understand the reuse.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 629ea06c-e6a4-44c7-8490-97a54e7b4f00

📥 Commits

Reviewing files that changed from the base of the PR and between 0f03084 and 8cc1018.

📒 Files selected for processing (1)
  • cmd/osquery-perf/agent.go

@mostlikelee
mostlikelee merged commit 13cec63 into main Apr 30, 2026
57 of 60 checks passed
@mostlikelee
mostlikelee deleted the claude/compassionate-galileo-88fc4e branch April 30, 2026 17:01
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.

Add RHEL osquery-perf support

3 participants