Skip to content

Commit

Permalink
WIP: Use SQLite ustead of PostgreSQL (CI test)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdelafuente-r7 committed Jan 31, 2025
1 parent 64be670 commit dc6fd5a
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 98 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ jobs:
run: |
cp config/database.yml.github_actions config/database.yml
bundle exec rake --version
bundle exec rake db:create
bundle exec rake db:migrate
bundle exec rake db:reset
# fail build if db/schema.rb update is not committed
git diff --exit-code db/schema.rb
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ source 'https://rubygems.org'
# spec.add_runtime_dependency '<name>', [<version requirements>]
gemspec name: 'metasploit-framework'

gem 'sqlite3'

# separate from test as simplecov is not run on travis-ci
group :coverage do
# code coverage for tests
Expand Down
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ DEPENDENCIES
rubocop
ruby-prof (= 1.4.2)
simplecov (= 0.18.2)
sqlite3
test-prof
timecop
yard
Expand Down
11 changes: 5 additions & 6 deletions config/database.yml.github_actions
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
# cp config/database.yml.example config/database.yml
# # update password fields for each environment's user

development: &pgsql
adapter: postgresql
database: metasploit_framework_development
host: localhost
development: &sqlite
adapter: sqlite3
database: db/metasploit_framework_development
username: postgres
password: postgres
pool: 25
Expand All @@ -21,5 +20,5 @@ development: &pgsql
#
# Note also, sqlite3 is totally unsupported by Metasploit now.
test:
<<: *pgsql
database: metasploit_framework_test
<<: *sqlite
database: db/metasploit_framework_test
169 changes: 83 additions & 86 deletions db/schema.rb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/msf/core/db_manager/adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Msf::DBManager::Adapter
#

# The adapter to use to establish database connection.
ADAPTER = 'postgresql'
ADAPTER = 'sqlite3'

#
# Attributes
Expand Down
2 changes: 1 addition & 1 deletion lib/msf/core/db_manager/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def connect(opts={})
def create_db(opts)
begin
case opts["adapter"]
when 'postgresql'
when 'postgresql', 'sqlite3'
# Try to force a connection to be made to the database, if it succeeds
# then we know we don't need to create it :)
ApplicationRecord.establish_connection(opts)
Expand Down
4 changes: 2 additions & 2 deletions lib/msf/core/rpc/v10/rpc_db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1923,8 +1923,8 @@ def rpc_connect(xopts)
driver = self.framework.db.driver

case driver
when 'postgresql'
opts['adapter'] = 'postgresql'
when 'postgresql', 'sqlite3'
opts['adapter'] = driver
else
return { :result => 'failed' }
end
Expand Down

0 comments on commit dc6fd5a

Please sign in to comment.