diff --git a/.github/workflows/github_actions.yml b/.github/workflows/github_actions.yml index db5b808e2..7365335cc 100644 --- a/.github/workflows/github_actions.yml +++ b/.github/workflows/github_actions.yml @@ -34,7 +34,7 @@ jobs: local-identifier: random - name: 'Checkout the repository' - uses: actions/checkout@v4 + uses: actions/checkout@v2 with: ref: ${{ github.event.pull_request.head.sha }} fetch-depth: 2 diff --git a/Gemfile b/Gemfile index 2de308bd8..36dd65f50 100644 --- a/Gemfile +++ b/Gemfile @@ -21,7 +21,7 @@ gem 'term-ansicolor', :require => 'term/ansicolor' gem 'rubyzip', '~> 2.3' gem 'espeak-ruby', '~> 1.1.0' # Text-to-Voice gem 'rake', '~> 13.2' -gem 'activerecord', '~> 7.0' +gem 'activerecord', '~> 7.2' gem 'otr-activerecord', '~> 2.4.0' gem 'sqlite3', '~> 1.4' gem 'rubocop', '~> 1.68.0', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 6b6b4f3cf..8de314067 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,22 +1,24 @@ GEM remote: https://rubygems.org/ specs: - activemodel (7.1.4.2) - activesupport (= 7.1.4.2) - activerecord (7.1.4.2) - activemodel (= 7.1.4.2) - activesupport (= 7.1.4.2) + activemodel (7.2.2) + activesupport (= 7.2.2) + activerecord (7.2.2) + activemodel (= 7.2.2) + activesupport (= 7.2.2) timeout (>= 0.4.0) - activesupport (7.1.4.2) + activesupport (7.2.2) base64 + benchmark (>= 0.3) bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) + concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) - mutex_m - tzinfo (~> 2.0) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) ansi (1.5.0) @@ -32,6 +34,7 @@ GEM async-io (1.43.2) async base64 (0.2.0) + benchmark (0.3.0) bigdecimal (3.1.8) browserstack-local (1.4.3) byebug (11.1.3) @@ -102,13 +105,12 @@ GEM msgpack (1.7.3) mustermann (3.0.3) ruby2_keywords (~> 0.0.1) - mutex_m (0.2.0) net-protocol (0.2.2) timeout net-smtp (0.5.0) net-protocol netrc (0.11.0) - nio4r (2.7.3) + nio4r (2.7.4) nokogiri (1.16.7-aarch64-linux) racc (~> 1.4) nokogiri (1.16.7-arm-linux) @@ -126,7 +128,7 @@ GEM hashie-forbidden_attributes (~> 0.1) parallel (1.26.3) parseconfig (1.1.2) - parser (3.3.5.0) + parser (3.3.5.1) ast (~> 2.4.1) racc power_assert (2.0.4) @@ -168,7 +170,7 @@ GEM rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) rspec-mocks (~> 3.13.0) - rspec-core (3.13.1) + rspec-core (3.13.2) rspec-support (~> 3.13.0) rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) @@ -187,7 +189,7 @@ GEM rubocop-ast (>= 1.32.2, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.33.0) + rubocop-ast (1.33.1) parser (>= 3.3.1.0) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) @@ -195,6 +197,7 @@ GEM rushover (0.3.0) json rest-client + securerandom (0.3.1) selenium-webdriver (4.26.0) base64 (~> 0.2) logger (~> 1.4) @@ -241,7 +244,7 @@ GEM tilt (2.4.0) timeout (0.4.1) timers (4.3.5) - tins (1.35.0) + tins (1.37.0) bigdecimal sync tzinfo (2.0.6) @@ -249,7 +252,7 @@ GEM uglifier (4.2.1) execjs (>= 0.3.0, < 3) unicode-display_width (2.6.0) - webrick (1.8.2) + webrick (1.9.0) websocket (1.2.11) websocket-client-simple (0.6.1) event_emitter @@ -268,7 +271,7 @@ PLATFORMS x86_64-linux DEPENDENCIES - activerecord (~> 7.0) + activerecord (~> 7.2) ansi (~> 1.5) async (~> 1.32) async-dns (~> 1.3) diff --git a/beef b/beef index 7d8dd55b9..134127927 100755 --- a/beef +++ b/beef @@ -194,7 +194,6 @@ end # Connect to DB ActiveRecord::Base.logger = nil -OTR::ActiveRecord.migrations_paths = [File.join('core', 'main', 'ar-migrations')] OTR::ActiveRecord.configure_from_hash!(adapter:'sqlite3', database:db_file) # otr-activerecord require you to manually establish the connection with the following line #Also a check to confirm that the correct Gem version is installed to require it, likely easier for old systems. @@ -204,10 +203,12 @@ end # Migrate (if required) ActiveRecord::Migration.verbose = false # silence activerecord migration stdout messages -context = ActiveRecord::Migration.new.migration_context +ActiveRecord::Migrator.migrations_paths = [File.join('core', 'main', 'ar-migrations')] +context = ActiveRecord::MigrationContext.new(ActiveRecord::Migrator.migrations_paths) if context.needs_migration? ActiveRecord::Migrator.new(:up, context.migrations, context.schema_migration, context.internal_metadata).migrate end + # # @note Extensions may take a moment to load, thus we print out a please wait message # diff --git a/spec/beef/core/main/autorun_engine/autorun_engine_spec.rb b/spec/beef/core/main/autorun_engine/autorun_engine_spec.rb index f5b621c8c..38ba96a62 100644 --- a/spec/beef/core/main/autorun_engine/autorun_engine_spec.rb +++ b/spec/beef/core/main/autorun_engine/autorun_engine_spec.rb @@ -42,14 +42,14 @@ RSpec.describe 'AutoRunEngine Test', run_on_browserstack: true do # Load up DB and migrate if necessary ActiveRecord::Base.logger = nil - OTR::ActiveRecord.migrations_paths = [File.join('core', 'main', 'ar-migrations')] OTR::ActiveRecord.configure_from_hash!(adapter: 'sqlite3', database: db_file) # otr-activerecord require you to manually establish the connection with the following line #Also a check to confirm that the correct Gem version is installed to require it, likely easier for old systems. if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('1.4.2') OTR::ActiveRecord.establish_connection! end - context = ActiveRecord::Migration.new.migration_context + ActiveRecord::Migrator.migrations_paths = [File.join('core', 'main', 'ar-migrations')] + context = ActiveRecord::MigrationContext.new(ActiveRecord::Migrator.migrations_paths) ActiveRecord::Migrator.new(:up, context.migrations, context.schema_migration, context.internal_metadata).migrate if context.needs_migration? BeEF::Core::Migration.instance.update_db! diff --git a/spec/beef/core/main/handlers/browser_details_handler_spec.rb b/spec/beef/core/main/handlers/browser_details_handler_spec.rb index f47deec09..943f53f06 100644 --- a/spec/beef/core/main/handlers/browser_details_handler_spec.rb +++ b/spec/beef/core/main/handlers/browser_details_handler_spec.rb @@ -41,7 +41,6 @@ RSpec.describe 'Browser Details Handler', run_on_browserstack: true do # Load up DB and migrate if necessary ActiveRecord::Base.logger = nil - OTR::ActiveRecord.migrations_paths = [File.join('core', 'main', 'ar-migrations')] OTR::ActiveRecord.configure_from_hash!(adapter: 'sqlite3', database: db_file) # otr-activerecord require you to manually establish the connection with the following line #Also a check to confirm that the correct Gem version is installed to require it, likely easier for old systems. @@ -49,8 +48,11 @@ RSpec.describe 'Browser Details Handler', run_on_browserstack: true do OTR::ActiveRecord.establish_connection! end - context = ActiveRecord::Migration.new.migration_context + # Migrate (if required) + ActiveRecord::Migrator.migrations_paths = [File.join('core', 'main', 'ar-migrations')] + context = ActiveRecord::MigrationContext.new(ActiveRecord::Migrator.migrations_paths) ActiveRecord::Migrator.new(:up, context.migrations, context.schema_migration, context.internal_metadata).migrate if context.needs_migration? + BeEF::Core::Migration.instance.update_db! # Spawn HTTP Server diff --git a/spec/beef/extensions/requester_spec.rb b/spec/beef/extensions/requester_spec.rb index 4f4d7e929..652224774 100644 --- a/spec/beef/extensions/requester_spec.rb +++ b/spec/beef/extensions/requester_spec.rb @@ -34,12 +34,12 @@ RSpec.describe 'BeEF Extension Requester' do # Connect to DB ActiveRecord::Base.logger = nil - OTR::ActiveRecord.migrations_paths = [File.join('core', 'main', 'ar-migrations')] OTR::ActiveRecord.configure_from_hash!(adapter: 'sqlite3', database: 'beef.db') OTR::ActiveRecord.establish_connection! if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('1.4.2') # Migrate if required - context = ActiveRecord::Migration.new.migration_context + ActiveRecord::Migrator.migrations_paths = [File.join('core', 'main', 'ar-migrations')] + context = ActiveRecord::MigrationContext.new(ActiveRecord::Migrator.migrations_paths) ActiveRecord::Migrator.new(:up, context.migrations, context.schema_migration, context.internal_metadata).migrate if context.needs_migration? # Start HTTP hook server diff --git a/spec/beef/extensions/websocket_hooked_browser_spec.rb b/spec/beef/extensions/websocket_hooked_browser_spec.rb index 7abd8d97c..59354befc 100644 --- a/spec/beef/extensions/websocket_hooked_browser_spec.rb +++ b/spec/beef/extensions/websocket_hooked_browser_spec.rb @@ -41,15 +41,17 @@ RSpec.describe 'Browser hooking with Websockets', run_on_browserstack: true do end # Load up DB and migrate if necessary ActiveRecord::Base.logger = nil - OTR::ActiveRecord.migrations_paths = [File.join('core', 'main', 'ar-migrations')] OTR::ActiveRecord.configure_from_hash!(adapter: 'sqlite3', database: db_file) # otr-activerecord require you to manually establish the connection with the following line #Also a check to confirm that the correct Gem version is installed to require it, likely easier for old systems. if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('1.4.2') OTR::ActiveRecord.establish_connection! end - context = ActiveRecord::Migration.new.migration_context + + ActiveRecord::Migrator.migrations_paths = [File.join('core', 'main', 'ar-migrations')] + context = ActiveRecord::MigrationContext.new(ActiveRecord::Migrator.migrations_paths) ActiveRecord::Migrator.new(:up, context.migrations, context.schema_migration, context.internal_metadata).migrate if context.needs_migration? + BeEF::Core::Migration.instance.update_db! # Spawn HTTP Server print_info 'Starting HTTP Hook Server' diff --git a/spec/beef/modules/debug/test_beef_debugs_spec.rb b/spec/beef/modules/debug/test_beef_debugs_spec.rb index 1912d331c..c67ffc583 100644 --- a/spec/beef/modules/debug/test_beef_debugs_spec.rb +++ b/spec/beef/modules/debug/test_beef_debugs_spec.rb @@ -39,14 +39,15 @@ RSpec.describe 'BeEF Debug Command Modules:', run_on_browserstack: true do # Load up DB and migrate if necessary ActiveRecord::Base.logger = nil - OTR::ActiveRecord.migrations_paths = [File.join('core', 'main', 'ar-migrations')] OTR::ActiveRecord.configure_from_hash!(adapter: 'sqlite3', database: db_file) # otr-activerecord require you to manually establish the connection with the following line #Also a check to confirm that the correct Gem version is installed to require it, likely easier for old systems. if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('1.4.2') OTR::ActiveRecord.establish_connection! end - context = ActiveRecord::Migration.new.migration_context + + ActiveRecord::Migrator.migrations_paths = [File.join('core', 'main', 'ar-migrations')] + context = ActiveRecord::MigrationContext.new(ActiveRecord::Migrator.migrations_paths) ActiveRecord::Migrator.new(:up, context.migrations, context.schema_migration, context.internal_metadata).migrate if context.needs_migration? BeEF::Core::Migration.instance.update_db! diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 750a63867..56e3edf46 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -50,7 +50,6 @@ CONFIG['key'] = ENV['BROWSERSTACK_ACCESS_KEY'] || '' ## DB config ActiveRecord::Base.logger = nil -OTR::ActiveRecord.migrations_paths = [File.join('core', 'main', 'ar-migrations')] OTR::ActiveRecord.configure_from_hash!(adapter: 'sqlite3', database: ':memory:') # otr-activerecord requires manually establishing the connection with the following line @@ -62,7 +61,8 @@ ActiveRecord::Schema.verbose = false # Migrate (if required) ActiveRecord::Migration.verbose = false # silence activerecord migration stdout messages -context = ActiveRecord::Migration.new.migration_context +ActiveRecord::Migrator.migrations_paths = [File.join('core', 'main', 'ar-migrations')] +context = ActiveRecord::MigrationContext.new(ActiveRecord::Migrator.migrations_paths) if context.needs_migration? ActiveRecord::Migrator.new(:up, context.migrations, context.schema_migration, context.internal_metadata).migrate end @@ -160,7 +160,6 @@ require 'socket' # Load up DB and migrate if necessary ActiveRecord::Base.logger = nil - OTR::ActiveRecord.migrations_paths = [File.join('core', 'main', 'ar-migrations')] OTR::ActiveRecord.configure_from_hash!(adapter:'sqlite3', database: db_file) # otr-activerecord require you to manually establish the connection with the following line #Also a check to confirm that the correct Gem version is installed to require it, likely easier for old systems. @@ -170,10 +169,12 @@ require 'socket' # Migrate (if required) ActiveRecord::Migration.verbose = false # silence activerecord migration stdout messages - context = ActiveRecord::Migration.new.migration_context + ActiveRecord::Migrator.migrations_paths = [File.join('core', 'main', 'ar-migrations')] + context = ActiveRecord::MigrationContext.new(ActiveRecord::Migrator.migrations_paths) if context.needs_migration? ActiveRecord::Migrator.new(:up, context.migrations, context.schema_migration, context.internal_metadata).migrate end + BeEF::Core::Migration.instance.update_db! # Spawn HTTP Server