From 752717301e6f342ff9f835c52496d22ae3fdb3b6 Mon Sep 17 00:00:00 2001 From: zinduolis Date: Mon, 4 Nov 2024 15:56:25 +1000 Subject: [PATCH 01/18] Upgrade activerecord to 7.2 and refactor code for new version --- Gemfile | 2 +- Gemfile.lock | 37 ++++++++++--------- beef | 5 ++- .../autorun_engine/autorun_engine_spec.rb | 4 +- .../handlers/browser_details_handler_spec.rb | 6 ++- spec/beef/extensions/requester_spec.rb | 4 +- .../websocket_hooked_browser_spec.rb | 6 ++- .../modules/debug/test_beef_debugs_spec.rb | 5 ++- spec/spec_helper.rb | 9 +++-- 9 files changed, 44 insertions(+), 34 deletions(-) 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 From 4043f46b08e2b0f1f81c8ab68339a9a5bbec43c2 Mon Sep 17 00:00:00 2001 From: zinduolis Date: Mon, 4 Nov 2024 18:27:17 +1000 Subject: [PATCH 02/18] Add current version of ruby for automated testing --- .github/workflows/github_actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github_actions.yml b/.github/workflows/github_actions.yml index f0c01959c..25b1402cc 100644 --- a/.github/workflows/github_actions.yml +++ b/.github/workflows/github_actions.yml @@ -42,7 +42,7 @@ jobs: - name: 'Setting up Ruby' uses: ruby/setup-ruby@v1 with: - ruby-version: 3.0.3 # Not needed with a .ruby-version file + ruby-version: 3.2.2 # Not needed with a .ruby-version file - name: 'Update and Install Dependencies' run: | From 45b61e9b5c3bbaf1aae4e4f84f27ffe664dd8fe8 Mon Sep 17 00:00:00 2001 From: zinduolis Date: Mon, 4 Nov 2024 18:43:33 +1000 Subject: [PATCH 03/18] Remove version from gh action --- .github/workflows/github_actions.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/github_actions.yml b/.github/workflows/github_actions.yml index 25b1402cc..14cb1d965 100644 --- a/.github/workflows/github_actions.yml +++ b/.github/workflows/github_actions.yml @@ -41,8 +41,7 @@ jobs: - name: 'Setting up Ruby' uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.2.2 # Not needed with a .ruby-version file + # ruby-version will be picked up with the .ruby-version file - name: 'Update and Install Dependencies' run: | From 2ce3ad755fd74ee5317874798db653c0e3009942 Mon Sep 17 00:00:00 2001 From: zinduolis Date: Mon, 4 Nov 2024 19:11:23 +1000 Subject: [PATCH 04/18] Update checkout action to the current version --- .github/workflows/github_actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github_actions.yml b/.github/workflows/github_actions.yml index 14cb1d965..aa310dba0 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@v2 + uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} fetch-depth: 2 From bb7e145c327f12547995b87c97ec62c8524c7bc3 Mon Sep 17 00:00:00 2001 From: zinduolis Date: Tue, 5 Nov 2024 19:58:39 +1000 Subject: [PATCH 05/18] Update gh action to run of workflow code in PR --- .github/workflows/github_actions.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github_actions.yml b/.github/workflows/github_actions.yml index aa310dba0..f80215b51 100644 --- a/.github/workflows/github_actions.yml +++ b/.github/workflows/github_actions.yml @@ -1,7 +1,7 @@ name: 'BrowserStack Test' on: - pull_request_target: + pull_request: branches: [ master ] jobs: @@ -41,7 +41,7 @@ jobs: - name: 'Setting up Ruby' uses: ruby/setup-ruby@v1 - # ruby-version will be picked up with the .ruby-version file + # ruby-version will be picked up with the .ruby-version file - name: 'Update and Install Dependencies' run: | From e1a4716ed075b801712126570b9f68622f1a5258 Mon Sep 17 00:00:00 2001 From: zinduolis Date: Tue, 5 Nov 2024 20:09:15 +1000 Subject: [PATCH 06/18] Revert gh action update --- .github/workflows/github_actions.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/github_actions.yml b/.github/workflows/github_actions.yml index f80215b51..25b1402cc 100644 --- a/.github/workflows/github_actions.yml +++ b/.github/workflows/github_actions.yml @@ -1,7 +1,7 @@ name: 'BrowserStack Test' on: - pull_request: + pull_request_target: branches: [ master ] jobs: @@ -34,14 +34,15 @@ 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 - name: 'Setting up Ruby' uses: ruby/setup-ruby@v1 - # ruby-version will be picked up with the .ruby-version file + with: + ruby-version: 3.2.2 # Not needed with a .ruby-version file - name: 'Update and Install Dependencies' run: | From 29db262453cf9e9b4ec00c1f6fab0edb04c0ae19 Mon Sep 17 00:00:00 2001 From: zinduolis Date: Tue, 5 Nov 2024 20:11:21 +1000 Subject: [PATCH 07/18] Revert one more gh action change --- .github/workflows/github_actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github_actions.yml b/.github/workflows/github_actions.yml index 25b1402cc..f0c01959c 100644 --- a/.github/workflows/github_actions.yml +++ b/.github/workflows/github_actions.yml @@ -42,7 +42,7 @@ jobs: - name: 'Setting up Ruby' uses: ruby/setup-ruby@v1 with: - ruby-version: 3.2.2 # Not needed with a .ruby-version file + ruby-version: 3.0.3 # Not needed with a .ruby-version file - name: 'Update and Install Dependencies' run: | From a62cb63d9c84a5d8b291bbb21a9aa266026574b2 Mon Sep 17 00:00:00 2001 From: zinduolis Date: Mon, 4 Nov 2024 15:56:25 +1000 Subject: [PATCH 08/18] Upgrade activerecord to 7.2 and refactor code for new version --- Gemfile | 2 +- Gemfile.lock | 37 ++++++++++--------- beef | 5 ++- .../autorun_engine/autorun_engine_spec.rb | 4 +- .../handlers/browser_details_handler_spec.rb | 6 ++- spec/beef/extensions/requester_spec.rb | 4 +- .../websocket_hooked_browser_spec.rb | 6 ++- .../modules/debug/test_beef_debugs_spec.rb | 5 ++- spec/spec_helper.rb | 9 +++-- 9 files changed, 44 insertions(+), 34 deletions(-) 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 From ce528f1f4e4265d0684c94b48e795ce56a6aed4b Mon Sep 17 00:00:00 2001 From: zinduolis Date: Tue, 5 Nov 2024 19:58:39 +1000 Subject: [PATCH 09/18] Update gh action to run of workflow code in PR --- .github/workflows/github_actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github_actions.yml b/.github/workflows/github_actions.yml index db5b808e2..4d32f1602 100644 --- a/.github/workflows/github_actions.yml +++ b/.github/workflows/github_actions.yml @@ -1,7 +1,7 @@ name: 'BrowserStack Test' on: - pull_request_target: + pull_request: branches: [ master ] jobs: From 15c091e91ec4d7ae3f60d64eace74f5e869c89ce Mon Sep 17 00:00:00 2001 From: zinduolis Date: Tue, 5 Nov 2024 20:09:15 +1000 Subject: [PATCH 10/18] Revert gh action update --- .github/workflows/github_actions.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github_actions.yml b/.github/workflows/github_actions.yml index 4d32f1602..7365335cc 100644 --- a/.github/workflows/github_actions.yml +++ b/.github/workflows/github_actions.yml @@ -1,7 +1,7 @@ name: 'BrowserStack Test' on: - pull_request: + pull_request_target: branches: [ master ] jobs: @@ -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 From 752ab1c27ac99a4333943d739ea5b01a5eff5880 Mon Sep 17 00:00:00 2001 From: zinduolis Date: Tue, 5 Nov 2024 20:11:21 +1000 Subject: [PATCH 11/18] Revert one more gh action change --- .github/workflows/github_actions.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github_actions.yml b/.github/workflows/github_actions.yml index 7365335cc..b36d2aab1 100644 --- a/.github/workflows/github_actions.yml +++ b/.github/workflows/github_actions.yml @@ -1,7 +1,7 @@ name: 'BrowserStack Test' on: - pull_request_target: + pull_request: branches: [ master ] jobs: @@ -34,7 +34,7 @@ jobs: local-identifier: random - name: 'Checkout the repository' - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} fetch-depth: 2 @@ -42,6 +42,8 @@ jobs: - name: 'Setting up Ruby' uses: ruby/setup-ruby@v1 # Ruby version is defined in .ruby-version file + with: + ruby-version: 3.0.3 # Not needed with a .ruby-version file - name: 'Update and Install Dependencies' run: | From 5bd0752deba0dff4774e1ef4f4ab5f0b10904706 Mon Sep 17 00:00:00 2001 From: zinduolis Date: Wed, 6 Nov 2024 14:41:57 +1000 Subject: [PATCH 12/18] Resolving merge conflicts --- .github/workflows/github_actions.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/github_actions.yml b/.github/workflows/github_actions.yml index b36d2aab1..db5b808e2 100644 --- a/.github/workflows/github_actions.yml +++ b/.github/workflows/github_actions.yml @@ -1,7 +1,7 @@ name: 'BrowserStack Test' on: - pull_request: + pull_request_target: branches: [ master ] jobs: @@ -42,8 +42,6 @@ jobs: - name: 'Setting up Ruby' uses: ruby/setup-ruby@v1 # Ruby version is defined in .ruby-version file - with: - ruby-version: 3.0.3 # Not needed with a .ruby-version file - name: 'Update and Install Dependencies' run: | From 23b8e891ad4d5b7a88a10c231733a82c573d2871 Mon Sep 17 00:00:00 2001 From: zinduolis Date: Mon, 4 Nov 2024 18:27:17 +1000 Subject: [PATCH 13/18] Add current version of ruby for automated testing --- .github/workflows/github_actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github_actions.yml b/.github/workflows/github_actions.yml index b36d2aab1..15cee031d 100644 --- a/.github/workflows/github_actions.yml +++ b/.github/workflows/github_actions.yml @@ -43,7 +43,7 @@ jobs: uses: ruby/setup-ruby@v1 # Ruby version is defined in .ruby-version file with: - ruby-version: 3.0.3 # Not needed with a .ruby-version file + ruby-version: 3.2.2 # Not needed with a .ruby-version file - name: 'Update and Install Dependencies' run: | From 32ad62fa7741a0b6413735f871edc219659e6016 Mon Sep 17 00:00:00 2001 From: zinduolis Date: Mon, 4 Nov 2024 18:43:33 +1000 Subject: [PATCH 14/18] Remove version from gh action --- .github/workflows/github_actions.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/github_actions.yml b/.github/workflows/github_actions.yml index 15cee031d..1e4ab26b6 100644 --- a/.github/workflows/github_actions.yml +++ b/.github/workflows/github_actions.yml @@ -41,9 +41,7 @@ jobs: - name: 'Setting up Ruby' uses: ruby/setup-ruby@v1 - # Ruby version is defined in .ruby-version file - with: - ruby-version: 3.2.2 # Not needed with a .ruby-version file + # ruby-version will be picked up with the .ruby-version file - name: 'Update and Install Dependencies' run: | From b80b0ff9b1d56c0f7f2b3fc75246e7d8823ee209 Mon Sep 17 00:00:00 2001 From: zinduolis Date: Tue, 5 Nov 2024 19:58:39 +1000 Subject: [PATCH 15/18] Update gh action to run of workflow code in PR --- .github/workflows/github_actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github_actions.yml b/.github/workflows/github_actions.yml index 1e4ab26b6..f80215b51 100644 --- a/.github/workflows/github_actions.yml +++ b/.github/workflows/github_actions.yml @@ -41,7 +41,7 @@ jobs: - name: 'Setting up Ruby' uses: ruby/setup-ruby@v1 - # ruby-version will be picked up with the .ruby-version file + # ruby-version will be picked up with the .ruby-version file - name: 'Update and Install Dependencies' run: | From f7b052572e186c06eebefb59d136209e5dce7ac5 Mon Sep 17 00:00:00 2001 From: zinduolis Date: Tue, 5 Nov 2024 20:09:15 +1000 Subject: [PATCH 16/18] Revert gh action update --- .github/workflows/github_actions.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/github_actions.yml b/.github/workflows/github_actions.yml index f80215b51..25b1402cc 100644 --- a/.github/workflows/github_actions.yml +++ b/.github/workflows/github_actions.yml @@ -1,7 +1,7 @@ name: 'BrowserStack Test' on: - pull_request: + pull_request_target: branches: [ master ] jobs: @@ -34,14 +34,15 @@ 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 - name: 'Setting up Ruby' uses: ruby/setup-ruby@v1 - # ruby-version will be picked up with the .ruby-version file + with: + ruby-version: 3.2.2 # Not needed with a .ruby-version file - name: 'Update and Install Dependencies' run: | From fb211c2d58564c1b73841767670bc3ffd83198d6 Mon Sep 17 00:00:00 2001 From: zinduolis Date: Tue, 5 Nov 2024 20:11:21 +1000 Subject: [PATCH 17/18] Revert one more gh action change --- .github/workflows/github_actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github_actions.yml b/.github/workflows/github_actions.yml index 25b1402cc..f0c01959c 100644 --- a/.github/workflows/github_actions.yml +++ b/.github/workflows/github_actions.yml @@ -42,7 +42,7 @@ jobs: - name: 'Setting up Ruby' uses: ruby/setup-ruby@v1 with: - ruby-version: 3.2.2 # Not needed with a .ruby-version file + ruby-version: 3.0.3 # Not needed with a .ruby-version file - name: 'Update and Install Dependencies' run: | From 5205c3353525c1f9644f4b1bb926bc35d739874c Mon Sep 17 00:00:00 2001 From: zinduolis Date: Wed, 6 Nov 2024 14:41:57 +1000 Subject: [PATCH 18/18] Resolving merge conflicts --- .github/workflows/github_actions.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/github_actions.yml b/.github/workflows/github_actions.yml index f0c01959c..bb01686b9 100644 --- a/.github/workflows/github_actions.yml +++ b/.github/workflows/github_actions.yml @@ -41,8 +41,12 @@ jobs: - name: 'Setting up Ruby' uses: ruby/setup-ruby@v1 +<<<<<<< HEAD with: ruby-version: 3.0.3 # Not needed with a .ruby-version file +======= + # Ruby version is defined in .ruby-version file +>>>>>>> 5bd0752d (Resolving merge conflicts) - name: 'Update and Install Dependencies' run: |