Skip to content

osquery_perf: add Windows-specific disk encryption query handling. - #44998

Merged
getvictor merged 1 commit into
mainfrom
victor/43130-osquery-perf
May 8, 2026
Merged

osquery_perf: add Windows-specific disk encryption query handling.#44998
getvictor merged 1 commit into
mainfrom
victor/43130-osquery-perf

Conversation

@getvictor

@getvictor getvictor commented May 8, 2026

Copy link
Copy Markdown
Member

Related issue: Resolves #43130

Checklist for submitter

Testing

  • QA'd all new/changed functionality manually

Summary by CodeRabbit

Release Notes

  • Improvements
    • Disk encryption status reporting now models results separately for each operating system
    • Windows systems provide enhanced BitLocker protection and conversion status information

@getvictor getvictor changed the title Add Windows-specific disk encryption query handling to agent logic. osquery_perf: add Windows-specific disk encryption query handling. May 8, 2026
@codecov

codecov Bot commented May 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.74%. Comparing base (0dc7a66) to head (6f67731).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/osquery-perf/agent.go 0.00% 17 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #44998      +/-   ##
==========================================
- Coverage   66.75%   66.74%   -0.01%     
==========================================
  Files        2694     2694              
  Lines      217246   217262      +16     
  Branches    10160    10160              
==========================================
- Hits       145017   145011       -6     
- Misses      59078    59096      +18     
- Partials    13151    13155       +4     
Flag Coverage Δ
backend 68.61% <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.

@getvictor
getvictor marked this pull request as ready for review May 8, 2026 03:02
@getvictor
getvictor requested a review from a team as a code owner May 8, 2026 03:02
Copilot AI review requested due to automatic review settings May 8, 2026 03:02

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

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

Updates the osquery-perf agent’s simulated query results so the Windows disk-encryption detail query matches Fleet’s current disk_encryption_windows osquery query shape (which returns BitLocker protection_status and conversion_status).

Changes:

  • Add diskEncryptionWindows() to generate Windows-specific disk encryption result rows with protection_status and conversion_status.
  • Update processQuery to route disk_encryption_windows to the new Windows-specific generator instead of the macOS-style “SELECT 1” result.

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

@coderabbitai

coderabbitai Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The osquery performance test agent now routes disk encryption queries per operating system. A new diskEncryptionWindows() method generates Windows BitLocker-specific response fields (protection_status and conversion_status), while the existing diskEncryption() method handles Darwin. The processQuery dispatcher now splits disk_encryption_darwin and disk_encryption_windows into separate code paths instead of routing both to a single handler.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is incomplete; it lacks details about changes, testing approach, and most required checklist items. Add detailed explanation of changes (disk encryption query routing, new Windows handler), expand testing details, and complete relevant checklist sections.
Linked Issues check ⚠️ Warning The PR only addresses osquery-perf mock query handling while issue #43130 requires comprehensive server-side ingestion and database changes. Verify all objectives from issue #43130 are met: directIngestDiskEncryptionWindows implementation, bitlocker_protection_status column migration, and status logic updates.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding Windows-specific disk encryption query handling to osquery-perf.
Out of Scope Changes check ✅ Passed Changes are limited to agent.go mock query handling, which is in scope for the osquery-perf test tool.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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 victor/43130-osquery-perf

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.

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

2686-2699: ⚡ Quick win

Consider simulating the "action required" BitLocker state for more complete load test coverage.

The server-side code handles a third meaningful state beyond the current two: disk fully encrypted but protection turned off (protection_status=Off + conversion_status=FullyEncrypted). This state triggers the new "Action required" UI surface. Extend diskEncryptionWindows() to simulate all three states so load tests exercise that code path.

♻️ Proposed extension
 func (a *agent) diskEncryptionWindows() []map[string]string {
-	// 50% of results have encryption enabled
-	a.DiskEncryptionEnabled = rand.Intn(2) == 1
-	if a.DiskEncryptionEnabled {
-		return []map[string]string{{
-			"protection_status": strconv.Itoa(fleet.BitLockerProtectionStatusOn),
-			"conversion_status": strconv.Itoa(fleet.BitLockerConversionStatusFullyEncrypted),
-		}}
+	// Distribute across three realistic states:
+	//   0-49%  → encrypted + protection on  (normal/verified)
+	//  50-74%  → not encrypted + protection off  (not encrypted)
+	//  75-99%  → encrypted + protection off  (action required)
+	switch rand.Intn(4) {
+	case 0, 1: // 50% - encrypted, protection on
+		a.DiskEncryptionEnabled = true
+		return []map[string]string{{
+			"protection_status": strconv.Itoa(fleet.BitLockerProtectionStatusOn),
+			"conversion_status": strconv.Itoa(fleet.BitLockerConversionStatusFullyEncrypted),
+		}}
+	case 2: // 25% - not encrypted
+		a.DiskEncryptionEnabled = false
+		return []map[string]string{{
+			"protection_status": strconv.Itoa(fleet.BitLockerProtectionStatusOff),
+			"conversion_status": strconv.Itoa(fleet.BitLockerConversionStatusFullyDecrypted),
+		}}
+	default: // 25% - encrypted but protection off → "action required"
+		a.DiskEncryptionEnabled = true
+		return []map[string]string{{
+			"protection_status": strconv.Itoa(fleet.BitLockerProtectionStatusOff),
+			"conversion_status": strconv.Itoa(fleet.BitLockerConversionStatusFullyEncrypted),
+		}}
 	}
-	return []map[string]string{{
-		"protection_status": strconv.Itoa(fleet.BitLockerProtectionStatusOff),
-		"conversion_status": strconv.Itoa(fleet.BitLockerConversionStatusFullyDecrypted),
-	}}
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/osquery-perf/agent.go` around lines 2686 - 2699, diskEncryptionWindows
currently only returns two BitLocker states; update the function to simulate all
three meaningful server-side states (1) protection on + fully encrypted, (2)
protection off + fully decrypted, and (3) protection off + fully encrypted (the
"Action required" case). Change the random selection to pick among three
outcomes, return the corresponding map entries using
fleet.BitLockerProtectionStatusOn/Off and
fleet.BitLockerConversionStatusFullyEncrypted/FullyDecrypted, and set
a.DiskEncryptionEnabled to reflect whether disk protection is effectively
enabled for that chosen state (true for protection on, false otherwise) so the
load test exercises the new UI path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@cmd/osquery-perf/agent.go`:
- Around line 2686-2699: diskEncryptionWindows currently only returns two
BitLocker states; update the function to simulate all three meaningful
server-side states (1) protection on + fully encrypted, (2) protection off +
fully decrypted, and (3) protection off + fully encrypted (the "Action required"
case). Change the random selection to pick among three outcomes, return the
corresponding map entries using fleet.BitLockerProtectionStatusOn/Off and
fleet.BitLockerConversionStatusFullyEncrypted/FullyDecrypted, and set
a.DiskEncryptionEnabled to reflect whether disk protection is effectively
enabled for that chosen state (true for protection on, false otherwise) so the
load test exercises the new UI path.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b17b89d4-0c30-4548-863c-6adfe3644ea3

📥 Commits

Reviewing files that changed from the base of the PR and between 0dc7a66 and 6f67731.

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

@getvictor
getvictor merged commit 7012e70 into main May 8, 2026
57 checks passed
@getvictor
getvictor deleted the victor/43130-osquery-perf branch May 8, 2026 14:21
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.

3 participants