osquery_perf: add Windows-specific disk encryption query handling. - #44998
Conversation
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 withprotection_statusandconversion_status. - Update
processQueryto routedisk_encryption_windowsto 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.
WalkthroughThe osquery performance test agent now routes disk encryption queries per operating system. A new 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cmd/osquery-perf/agent.go (1)
2686-2699: ⚡ Quick winConsider 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. ExtenddiskEncryptionWindows()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
📒 Files selected for processing (1)
cmd/osquery-perf/agent.go
Related issue: Resolves #43130
Checklist for submitter
Testing
Summary by CodeRabbit
Release Notes