Skip to content

fix(agent): match bitdefender before defender in providerFromName (#2075) - #2085

Merged
ToddHebebrand merged 1 commit into
mainfrom
fix/2075-bitdefender-provider
Jun 30, 2026
Merged

fix(agent): match bitdefender before defender in providerFromName (#2075)#2085
ToddHebebrand merged 1 commit into
mainfrom
fix/2075-bitdefender-provider

Conversation

@ToddHebebrand

Copy link
Copy Markdown
Collaborator

Summary

providerFromName in agent/internal/security/status.go is a first-match substring switch. The defender case preceded the bitdefender case, and "bitdefender" contains the substring "defender", so any Windows Security Center product whose display name contains "Bitdefender" normalized to windows_defender instead of bitdefender — the bitdefender arm was effectively dead code for real Bitdefender names.

This reorders the switch so the more specific bitdefender match wins, mirroring the elastic-before-defender approach. AV coverage counting was unaffected (both are non-other with RTP); this fixes the provider/vendor mislabeling on the security dashboard.

Changes

  • Reorder bitdefender case before defender in providerFromName.
  • Add agent/internal/security/status_provider_test.go with a table-driven TestProviderFromName that locks in the ordering. The two bitdefender cases fail against the old ordering (verified: providerFromName("Bitdefender") = "windows_defender") and pass with the fix.

Testing

  • go test -race ./internal/security/... — green.
  • Confirmed the new test is non-vacuous by reverting the ordering: the bitdefender subtests fail with the exact misclassification described in the issue.

Note

PR #2068 (Elastic Defend, fix/2018-elastic-defend-av) also edits this switch and introduces a status_provider_test.go. #2068 is not yet merged to main, so this branched off fresh origin/main (neither the elastic case nor the test file present). The two inserts are independent; whichever merges second will need a trivial rebase to combine both cases and the test tables.

Closes #2075

🤖 Generated with Claude Code

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 30, 2026

Copy link
Copy Markdown

Deploying breeze with  Cloudflare Pages  Cloudflare Pages

Latest commit: 75ba8bf
Status:⚡️  Build in progress...

View logs

@ToddHebebrand

Copy link
Copy Markdown
Collaborator Author

Review run: /pr-review-toolkit:review-pr (code-reviewer + pr-test-analyzer — the two applicable to a Go switch-reorder + new table-driven test).
Findings: 0 outstanding. The reorder is the correct fix for the substring-precedence hazard and the new test locks in the ordering.
Tests: go test -race ./internal/security/... green. Confirmed non-vacuous — reverting to the old defender-before-bitdefender ordering fails the two bitdefender subtests with providerFromName("Bitdefender") = "windows_defender", exactly the misclassification in the issue.
Note: PR #2068 (Elastic Defend) also edits this switch and introduces status_provider_test.go; it was not yet merged when this branched off fresh origin/main. The two inserts are independent — a trivial rebase merges both cases and test tables whenever the second one lands.
Status: review-clean, awaiting maintainer merge.

)

providerFromName is a first-match substring switch. The `defender` case
preceded the `bitdefender` case, and "bitdefender" contains the substring
"defender", so any Bitdefender display name from Windows Security Center
normalized to "windows_defender" — the `bitdefender` arm was dead code for
real Bitdefender names. Reorder so the more specific match wins, mirroring
the elastic-before-defender fix.

Adds status_provider_test.go locking in the ordering so a future reorder
can't silently reintroduce the misclassification.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ToddHebebrand
ToddHebebrand force-pushed the fix/2075-bitdefender-provider branch from fe6a4b6 to 75ba8bf Compare June 30, 2026 14:44
@ToddHebebrand
ToddHebebrand merged commit 4134444 into main Jun 30, 2026
26 of 27 checks passed
@ToddHebebrand
ToddHebebrand deleted the fix/2075-bitdefender-provider branch June 30, 2026 14:45
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.

[Agent] providerFromName misclassifies Bitdefender as Microsoft Defender (substring-precedence bug)

1 participant