Skip to content

Commit d987693

Browse files
committed
Merges 'feature/rake-db'
Implements rake db tasks for Metasploit Framework. Woot! Verified all steps listed in rapid7#1592 as well. [Closes rapid7#1592]
2 parents 0c0d150 + 0f6b053 commit d987693

File tree

9 files changed

+831
-2
lines changed

9 files changed

+831
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
.yardoc
77
# Mac OS X files
88
.DS_Store
9+
# database config for testing
10+
config/database.yml
911
# simplecov coverage data
1012
coverage
1113
data/meterpreter/ext_server_pivot.dll

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ language: ruby
22
before_install:
33
- sudo apt-get update -qq
44
- sudo apt-get install -qq libpcap-dev
5+
before_script:
6+
- cp config/database.yml.travis config/database.yml
7+
- rake db:create
8+
- rake db:migrate
59

610
rvm:
711
#- '1.8.7'

Rakefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@ require 'bundler/setup'
22

33
require 'metasploit_data_models'
44

5+
#
6+
# load rake files like a rails engine
7+
#
8+
9+
pathname = Pathname.new(__FILE__)
10+
root = pathname.parent
11+
rakefile_glob = root.join('lib', 'tasks', '**', '*.rake').to_path
12+
13+
Dir.glob(rakefile_glob) do |rakefile|
14+
load rakefile
15+
end
16+
517
print_without = false
618

719
begin
@@ -12,7 +24,7 @@ rescue LoadError
1224

1325
print_without = true
1426
else
15-
RSpec::Core::RakeTask.new(:spec)
27+
RSpec::Core::RakeTask.new(:spec => 'db:test:prepare')
1628

1729
task :default => :spec
1830
end

config/database.yml.example

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Please only use postgresql bound to a TCP port.
2+
development: &pgsql
3+
adapter: postgresql
4+
database: metasploit_framework_development
5+
username: metasploit_framework_development
6+
password: __________________________________
7+
host: localhost
8+
port: 5432
9+
pool: 5
10+
timeout: 5
11+
12+
# Warning: The database defined as "test" will be erased and
13+
# re-generated from your development database when you run "rake".
14+
# Do not set this db to the same as development or production.
15+
#
16+
# Note also, sqlite3 is totally unsupported by Metasploit now.
17+
test:
18+
<<: *pgsql
19+
database: metasploit_framework_test
20+
username: metasploit_framework_test
21+
password: ___________________________

config/database.yml.travis

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# @note This file is only for use in travis-ci. If you need to make a
2+
# config/database.yml for running rake, rake spec, or rspec locally, please
3+
# customize `conifg/database.yml.example`
4+
#
5+
# @example Customizing config/database.yml.example
6+
# cp config/database.yml.example config/database.yml
7+
# # update password fields for each environment's user
8+
9+
# Using the postgres user locally without a host and port is the supported
10+
# configuration from Travis-CI
11+
#
12+
# @see http://about.travis-ci.org/docs/user/database-setup/#PostgreSQL
13+
development: &pgsql
14+
adapter: postgresql
15+
database: metasploit_framework_development
16+
username: postgres
17+
pool: 5
18+
timeout: 5
19+
20+
# Warning: The database defined as "test" will be erased and
21+
# re-generated from your development database when you run "rake".
22+
# Do not set this db to the same as development or production.
23+
#
24+
# Note also, sqlite3 is totally unsupported by Metasploit now.
25+
test:
26+
<<: *pgsql
27+
database: metasploit_framework_test

0 commit comments

Comments
 (0)