Class: Metasploit::Framework::ParsedOptions::Base
- Inherits:
-
Object
- Object
- Metasploit::Framework::ParsedOptions::Base
- Defined in:
- lib/metasploit/framework/parsed_options/base.rb
Overview
Options parsed from the command line that can be used to change the ‘Metasploit::Framework::Application.config` and `Rails.env`
Constant Summary collapse
- DEFAULT_ENVIRONMENT =
msfconsole boots in production mode instead of the normal rails default of development.
'production'
Instance Attribute Summary collapse
-
#positional ⇒ Object
readonly
Attributes.
Instance Method Summary collapse
-
#configure(application) ⇒ void
Translates #options to the ‘application`’s config.
-
#environment! ⇒ void
Sets the ‘RAILS_ENV` environment variable.
-
#initialize(arguments = ARGV) ⇒ Base
constructor
Instance Methods.
-
#options ⇒ ActiveSupport::OrderedOptions
Options parsed from.
Constructor Details
#initialize(arguments = ARGV) ⇒ Base
Instance Methods
41 42 43 44 45 46 47 48 49 |
# File 'lib/metasploit/framework/parsed_options/base.rb', line 41 def initialize(arguments=ARGV) begin @positional = option_parser.parse(arguments) rescue OptionParser::InvalidOption puts "ERROR: Invalid command line option provided." puts option_parser exit(1) end end |
Instance Attribute Details
#positional ⇒ Object (readonly)
Attributes
35 36 37 |
# File 'lib/metasploit/framework/parsed_options/base.rb', line 35 def positional @positional end |
Instance Method Details
#configure(application) ⇒ void
This method returns an undefined value.
Translates #options to the ‘application`’s config
55 56 57 |
# File 'lib/metasploit/framework/parsed_options/base.rb', line 55 def configure(application) application.config['config/database'] = .database.config end |
#environment! ⇒ void
This method returns an undefined value.
Sets the ‘RAILS_ENV` environment variable.
-
If the -E/–environment option is given, then its value is used.
-
The default value, ‘production’, is used.
65 66 67 68 69 70 71 |
# File 'lib/metasploit/framework/parsed_options/base.rb', line 65 def environment! if defined?(Rails) && Rails.instance_variable_defined?(:@_env) && Rails.env != .environment raise "#{self.class}##{__method__} called too late to set RAILS_ENV: Rails.env already memoized" end ENV['RAILS_ENV'] = .environment end |
#options ⇒ ActiveSupport::OrderedOptions
Options parsed from
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/metasploit/framework/parsed_options/base.rb', line 76 def unless @options = ActiveSupport::OrderedOptions.new .database = ActiveSupport::OrderedOptions.new .database.config = Metasploit::Framework::Database.configurations_pathname.try(:to_path) .database.disable = false .database.migrations_paths = [] # If RAILS_ENV is set, then it will be used, but if RAILS_ENV is set and the --environment option is given, then # --environment value will be used to reset ENV[RAILS_ENV]. .environment = ENV['RAILS_ENV'] || DEFAULT_ENVIRONMENT .framework = ActiveSupport::OrderedOptions.new .framework.config = nil .modules = ActiveSupport::OrderedOptions.new .modules.defer_loads = nil .modules.path = nil @options = end @options end |