Class: Msf::OptionGroup
- Inherits:
-
Object
- Object
- Msf::OptionGroup
- Defined in:
- lib/msf/core/option_group.rb
Instance Attribute Summary collapse
-
#description ⇒ String
Description to be displayed to the user.
-
#name ⇒ String
Name for the group.
-
#option_names ⇒ Array<String>
List of datastore option names.
-
#required_options ⇒ Array<String>
List of options that if present must have a value set.
Instance Method Summary collapse
- #add_option(option_name) ⇒ Object
- #add_options(option_names) ⇒ Object
-
#initialize(name:, description:, option_names: [], required_options: []) ⇒ OptionGroup
constructor
A new instance of OptionGroup.
-
#validate(options, datastore) ⇒ Object
Validates that any registered and required options are set.
Constructor Details
#initialize(name:, description:, option_names: [], required_options: []) ⇒ OptionGroup
Returns a new instance of OptionGroup.
19 20 21 22 23 24 |
# File 'lib/msf/core/option_group.rb', line 19 def initialize(name:, description:, option_names: [], required_options: []) self.name = name self.description = description self.option_names = option_names self. = end |
Instance Attribute Details
#description ⇒ String
Returns Description to be displayed to the user.
9 10 11 |
# File 'lib/msf/core/option_group.rb', line 9 def description @description end |
#name ⇒ String
Returns Name for the group.
7 8 9 |
# File 'lib/msf/core/option_group.rb', line 7 def name @name end |
#option_names ⇒ Array<String>
Returns List of datastore option names.
11 12 13 |
# File 'lib/msf/core/option_group.rb', line 11 def option_names @option_names end |
#required_options ⇒ Array<String>
Returns List of options that if present must have a value set.
13 14 15 |
# File 'lib/msf/core/option_group.rb', line 13 def @required_options end |
Instance Method Details
#add_option(option_name) ⇒ Object
27 28 29 |
# File 'lib/msf/core/option_group.rb', line 27 def add_option(option_name) @option_names << option_name end |
#add_options(option_names) ⇒ Object
32 33 34 |
# File 'lib/msf/core/option_group.rb', line 32 def (option_names) @option_names.concat(option_names) end |
#validate(options, datastore) ⇒ Object
Validates that any registered and required options are set
40 41 42 43 44 45 46 47 48 |
# File 'lib/msf/core/option_group.rb', line 40 def validate(, datastore) issues = {} .each do |option_name| if [option_name] && !datastore[option_name] issues[option_name] = "#{option_name} must be specified" end end raise Msf::OptionValidateError.new(issues.keys.to_a, reasons: issues) unless issues.empty? end |