Skip to content

Commit cd45c77

Browse files
committed
Fix a few database leaks
All database access should be wrapped in with_connection blocks. To avoid breaking git blame with a bunch of whitespace, I outdented the with_connection blocks as seems to be common in db.rb. [Story #55586616]
1 parent c070067 commit cd45c77

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/msf/core/db.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,6 +1512,7 @@ def report_auth_info(opts={})
15121512
raise ArgumentError.new("Invalid address or object for :host (#{opts[:host].inspect})")
15131513
end
15141514

1515+
::ActiveRecord::Base.connection_pool.with_connection {
15151516
host = opts.delete(:host)
15161517
ptype = opts.delete(:type) || "password"
15171518
token = [opts.delete(:user), opts.delete(:pass)]
@@ -1623,6 +1624,7 @@ def report_auth_info(opts={})
16231624
end
16241625

16251626
ret[:cred] = cred
1627+
}
16261628
end
16271629

16281630
alias :report_cred :report_auth_info
@@ -1922,8 +1924,10 @@ def report_vuln_details(vuln, details)
19221924
# Note that this *can* update data across workspaces
19231925
#
19241926
def update_vuln_details(details)
1927+
::ActiveRecord::Base.connection_pool.with_connection {
19251928
criteria = details.delete(:key) || {}
19261929
::Mdm::VulnDetail.update(key, details)
1930+
}
19271931
end
19281932

19291933
#

0 commit comments

Comments
 (0)