From 54404150202b2c3320e92d2a5c9bf0b6f4e2b06a Mon Sep 17 00:00:00 2001 From: Jeffrey Martin Date: Wed, 9 Dec 2020 15:46:27 -0600 Subject: [PATCH] force active record object load In some cases when `empty?` returns true `first` will fail to get db connection --- lib/msf/core/db_manager/vuln.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/msf/core/db_manager/vuln.rb b/lib/msf/core/db_manager/vuln.rb index d6ccc160c931..80e79869054b 100644 --- a/lib/msf/core/db_manager/vuln.rb +++ b/lib/msf/core/db_manager/vuln.rb @@ -31,7 +31,7 @@ def find_vuln_by_details(details_map, host, service=nil) vuln = nil if service - other_vulns = service.vulns.includes(:vuln_details).where(crit) + other_vulns = service.vulns.includes(:vuln_details).where(crit).to_a vuln = other_vulns.empty? ? nil : other_vulns.first end @@ -40,7 +40,7 @@ def find_vuln_by_details(details_map, host, service=nil) # Prevent matches against other services crit["vulns.service_id"] = nil if service - other_vulns = host.vulns.includes(:vuln_details).where(crit) + other_vulns = host.vulns.includes(:vuln_details).where(crit).to_a other_vulns.empty? ? nil : other_vulns.first end