From c493ccfc0641e7820c7eae62844587198924540a Mon Sep 17 00:00:00 2001 From: Matt Buck Date: Fri, 19 Dec 2014 11:37:23 -0600 Subject: [PATCH] Define the Rails version constraint in a library constant --- lib/metasploit/framework/rails_version_constraint.rb | 11 +++++++++++ metasploit-framework-db.gemspec | 6 ++---- metasploit-framework-full.gemspec | 2 ++ metasploit-framework.gemspec | 7 +++---- 4 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 lib/metasploit/framework/rails_version_constraint.rb diff --git a/lib/metasploit/framework/rails_version_constraint.rb b/lib/metasploit/framework/rails_version_constraint.rb new file mode 100644 index 0000000000..cdcb7e3113 --- /dev/null +++ b/lib/metasploit/framework/rails_version_constraint.rb @@ -0,0 +1,11 @@ +# Records the Bundler-style dependency constraint for the version of Rails to be +# used with the Metasploit Framework and Metasploit Pro. +module Metasploit + module Framework + module RailsVersionConstraint + # The Metasploit ecosystem is not ready for Rails 4 as it uses features of + # Rails 3.X that are removed in Rails 4. + RAILS_VERSION = '< 4.0.0' + end + end +end \ No newline at end of file diff --git a/metasploit-framework-db.gemspec b/metasploit-framework-db.gemspec index 5b25185e58..86acf809bb 100644 --- a/metasploit-framework-db.gemspec +++ b/metasploit-framework-db.gemspec @@ -12,6 +12,7 @@ end $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'metasploit/framework/version' +require 'metasploit/framework/rails_version_constraint' Gem::Specification.new do |spec| spec.name = 'metasploit-framework-db' @@ -26,10 +27,7 @@ Gem::Specification.new do |spec| # no files, just dependencies spec.files = [] - # The Metasploit ecosystem is not ready for Rails 4 as it uses features of Rails 3.X that are removed in Rails 4. - rails_version_constraint = '< 4.0.0' - - spec.add_runtime_dependency 'activerecord', rails_version_constraint + spec.add_runtime_dependency 'activerecord', Metasploit::Framework::RailsVersionConstraint::RAILS_VERSION # Metasploit::Credential database models spec.add_runtime_dependency 'metasploit-credential', '~> 0.13.8' # Database models shared between framework and Pro. diff --git a/metasploit-framework-full.gemspec b/metasploit-framework-full.gemspec index 7f93ad5c52..5d8809bb18 100644 --- a/metasploit-framework-full.gemspec +++ b/metasploit-framework-full.gemspec @@ -12,6 +12,7 @@ end $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'metasploit/framework/version' +require 'metasploit/framework/rails_version_constraint' Gem::Specification.new do |spec| spec.name = 'metasploit-framework-full' @@ -28,6 +29,7 @@ Gem::Specification.new do |spec| metasploit_framework_version_constraint = "= #{spec.version}" + spec.add_runtime_dependency 'rails', Metasploit::Framework::RailsVersionConstraint::RAILS_VERSION spec.add_runtime_dependency 'metasploit-framework', metasploit_framework_version_constraint spec.add_runtime_dependency 'metasploit-framework-db', metasploit_framework_version_constraint spec.add_runtime_dependency 'metasploit-framework-pcap', metasploit_framework_version_constraint diff --git a/metasploit-framework.gemspec b/metasploit-framework.gemspec index f83ecfdd05..854f715c9d 100644 --- a/metasploit-framework.gemspec +++ b/metasploit-framework.gemspec @@ -12,6 +12,7 @@ end $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'metasploit/framework/version' +require 'metasploit/framework/rails_version_constraint' Gem::Specification.new do |spec| spec.name = 'metasploit-framework' @@ -46,13 +47,11 @@ Gem::Specification.new do |spec| spec.test_files = spec.files.grep(%r{^spec/}) spec.require_paths = ["lib"] - # The Metasploit ecosystem is not ready for Rails 4 as it uses features of Rails 3.X that are removed in Rails 4. - rails_version_constraint = '< 4.0.0' # Need 3+ for ActiveSupport::Concern - spec.add_runtime_dependency 'activesupport', '>= 3.0.0', rails_version_constraint + spec.add_runtime_dependency 'activesupport', '>= 3.0.0', Metasploit::Framework::RailsVersionConstraint::RAILS_VERSION # Needed for config.action_view for view plugin compatibility for Pro - spec.add_runtime_dependency 'actionpack', rails_version_constraint + spec.add_runtime_dependency 'actionpack', Metasploit::Framework::RailsVersionConstraint::RAILS_VERSION # Needed for some admin modules (cfme_manageiq_evm_pass_reset.rb) spec.add_runtime_dependency 'bcrypt' # Needed for Javascript obfuscation