fix nil sysDescr crashing vendor identification

String.contains?/2 crashes on nil input. default nil sysDescr
and sysObjectID to empty string in find_vendor_match.
This commit is contained in:
Graham McIntire 2026-02-11 12:28:58 -06:00
parent c9f154f8cd
commit 1a31fd00b6
No known key found for this signature in database

View file

@ -1346,6 +1346,9 @@ defmodule Towerops.Snmp.Profiles.Base do
end
defp find_vendor_match(sys_descr, sys_object_id) do
sys_descr = sys_descr || ""
sys_object_id = sys_object_id || ""
Enum.find_value(@vendor_patterns, fn {descr_patterns, oid_patterns, manufacturer, extractor} ->
descr_match = descr_patterns != [] and String.contains?(sys_descr, descr_patterns)
oid_match = oid_patterns != [] and String.contains?(sys_object_id, oid_patterns)