Skip to content

Commit f9b902c

Browse files
author
Tod Beardsley
committed
Land rapid7#3681, restore rake and rspec functionality
Since this is a more complete fix than rapid7#3678 and rapid7#3679, this merge closes rapid7#3678 and closes rapid7#3679. Lets see if that magic syntax works!
2 parents f0f5772 + cef4ddf commit f9b902c

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

lib/metasploit/framework/require.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,31 @@ def self.optionally(name, without_warning)
3434
end
3535
end
3636

37+
# Tries to `require 'active_record/railtie'` to define the activerecord Rails initializers and rake tasks.
38+
#
39+
# @example Optionally requiring 'active_record/railtie'
40+
# require 'metasploit/framework/require'
41+
#
42+
# class MyClass
43+
# def setup
44+
# if database_enabled
45+
# Metasploit::Framework::Require.optionally_active_record_railtie
46+
# end
47+
# end
48+
# end
49+
#
50+
# @return [void]
51+
def self.optionally_active_record_railtie
52+
if ::File.exist?(Rails.application.config.paths['config/database'].first)
53+
optionally(
54+
'active_record/railtie',
55+
'activerecord not in the bundle, so database support will be disabled.'
56+
)
57+
else
58+
warn 'Could not find database.yml, so database support will be disabled.'
59+
end
60+
end
61+
3762
# Tries to `require 'metasploit/credential/creation'` and include it in the `including_module`.
3863
#
3964
# @param including_module [Module] `Class` or `Module` that wants to `include Metasploit::Credential::Creation`.

msfconsole

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
#!/usr/bin/env ruby
22
# -*- coding: binary -*-
33
#
4-
# $Id$
5-
#
64
# This user interface provides users with a command console interface to the
75
# framework.
86
#
9-
# $Revision$
10-
#
117

128
#
139
# Standard Library
@@ -20,7 +16,7 @@ require 'pathname'
2016
#
2117

2218
# @see https://github.com/rails/rails/blob/v3.2.17/railties/lib/rails/generators/rails/app/templates/script/rails#L3-L5
23-
require Pathname.new(__FILE__).expand_path.parent.join('config', 'boot')
19+
require Pathname.new(__FILE__).realpath.expand_path.parent.join('config', 'boot')
2420
require 'metasploit/framework/command/console'
2521

2622
Metasploit::Framework::Command::Console.start

0 commit comments

Comments
 (0)