fix(agent): match bitdefender before defender in providerFromName (#2075) - #2085
Conversation
|
Review run: /pr-review-toolkit:review-pr (code-reviewer + pr-test-analyzer — the two applicable to a Go switch-reorder + new table-driven test). |
) 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>
fe6a4b6 to
75ba8bf
Compare
Summary
providerFromNameinagent/internal/security/status.gois a first-match substringswitch. Thedefendercase preceded thebitdefendercase, and"bitdefender"contains the substring"defender", so any Windows Security Center product whose display name contains "Bitdefender" normalized towindows_defenderinstead ofbitdefender— thebitdefenderarm was effectively dead code for real Bitdefender names.This reorders the switch so the more specific
bitdefendermatch wins, mirroring the elastic-before-defender approach. AV coverage counting was unaffected (both are non-otherwith RTP); this fixes the provider/vendor mislabeling on the security dashboard.Changes
bitdefendercase beforedefenderinproviderFromName.agent/internal/security/status_provider_test.gowith a table-drivenTestProviderFromNamethat 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.Note
PR #2068 (Elastic Defend,
fix/2018-elastic-defend-av) also edits this switch and introduces astatus_provider_test.go. #2068 is not yet merged to main, so this branched off freshorigin/main(neither theelasticcase 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