Skip to content

Commit e5a7c38

Browse files
committed
Merges rapid7#1728, makes some gems optional for bundler
Verified that pcap, db, and test can be skipped now, should make Zero_Chaos happy.
2 parents 15e2ceb + e3ab2e9 commit e5a7c38

File tree

3 files changed

+39
-23
lines changed

3 files changed

+39
-23
lines changed

Gemfile

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,28 @@ source 'http://rubygems.org'
22

33
# Need 3+ for ActiveSupport::Concern
44
gem 'activesupport', '>= 3.0.0'
5-
# Needed for Msf::DbManager
6-
gem 'activerecord'
75
# Needed for some admin modules (scrutinizer_add_user.rb)
86
gem 'json'
9-
# Database models shared between framework and Pro.
10-
gem 'metasploit_data_models', '~> 0.6.14'
117
# Needed by msfgui and other rpc components
128
gem 'msgpack'
139
# Needed by anemone crawler
1410
gem 'nokogiri'
15-
# Needed for module caching in Mdm::ModuleDetails
16-
gem 'pg', '>= 0.11'
1711
# Needed by anemone crawler
1812
gem 'robots'
19-
# For sniffer and raw socket modules
20-
gem 'pcaprub'
13+
14+
group :db do
15+
# Needed for Msf::DbManager
16+
gem 'activerecord'
17+
# Database models shared between framework and Pro.
18+
gem 'metasploit_data_models', '~> 0.6.14'
19+
# Needed for module caching in Mdm::ModuleDetails
20+
gem 'pg', '>= 0.11'
21+
end
22+
23+
group :pcap do
24+
# For sniffer and raw socket modules
25+
gem 'pcaprub'
26+
end
2127

2228
group :development do
2329
# Markdown formatting for yard

Rakefile

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
require 'bundler/setup'
22

3-
require 'metasploit_data_models'
4-
53
pathname = Pathname.new(__FILE__)
64
root = pathname.parent
75

@@ -18,6 +16,8 @@ $LOAD_PATH.unshift(lib_pathname.to_s)
1816
rakefile_glob = root.join('lib', 'tasks', '**', '*.rake').to_path
1917

2018
Dir.glob(rakefile_glob) do |rakefile|
19+
# Skip database tasks, will load them later if MDM is present
20+
next if rakefile =~ /database\.rake$/
2121
load rakefile
2222
end
2323

@@ -36,6 +36,28 @@ else
3636
task :default => :spec
3737
end
3838

39+
begin
40+
require 'metasploit_data_models'
41+
rescue LoadError
42+
puts "metasploit_data_models not in bundle, so can't set up db tasks. " \
43+
"To run database tasks, ensure to install the db bundler group."
44+
45+
print_without = true
46+
else
47+
load 'lib/tasks/database.rake'
48+
metasploit_data_models_task_glob = MetasploitDataModels.root.join(
49+
'lib',
50+
'tasks',
51+
'**',
52+
'*.rake'
53+
).to_s
54+
# include tasks from metasplioit_data_models, such as `rake yard`.
55+
# metasploit-framework specific yard options are in .yardopts
56+
Dir.glob(metasploit_data_models_task_glob) do |path|
57+
load path
58+
end
59+
end
60+
3961
begin
4062
require 'yard'
4163
rescue LoadError
@@ -45,18 +67,6 @@ rescue LoadError
4567
print_without = true
4668
end
4769

48-
metasploit_data_models_task_glob = MetasploitDataModels.root.join(
49-
'lib',
50-
'tasks',
51-
'**',
52-
'*.rake'
53-
).to_s
54-
55-
# include tasks from metasplioit_data_models, such as `rake yard`.
56-
# metasploit-framework specific yard options are in .yardopts
57-
Dir.glob(metasploit_data_models_task_glob) do |path|
58-
load path
59-
end
6070

6171
if print_without
6272
puts "Bundle currently installed " \

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'rubygems'
22
require 'bundler'
3-
Bundler.require(:default, :test)
3+
Bundler.require(:default, :test, :db)
44

55
# add project lib directory to load path
66
spec_pathname = Pathname.new(__FILE__).dirname

0 commit comments

Comments
 (0)