Class: Msf::OptRegexp
Overview
Regexp option
Instance Attribute Summary
Attributes inherited from OptBase
#advanced, #aliases, #conditions, #default, #desc, #enums, #evasion, #fallbacks, #max_length, #name, #owner, #regex, #required
Instance Method Summary collapse
- #display_value(value) ⇒ Object
- #normalize(value) ⇒ Object
- #type ⇒ Object
- #valid?(value, check_empty: true) ⇒ Boolean
Methods inherited from OptBase
#advanced?, #empty_required_value?, #evasion?, #initialize, #invalid_value_length?, #required?, #type?, #validate_on_assignment?
Constructor Details
This class inherits a constructor from Msf::OptBase
Instance Method Details
#display_value(value) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/msf/core/opt_regexp.rb', line 38 def display_value(value) if value.kind_of?(Regexp) return value.source elsif value.kind_of?(String) return display_value(normalize(value)) end super end |
#normalize(value) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/msf/core/opt_regexp.rb', line 30 def normalize(value) if value.nil? || value.kind_of?(Regexp) value else Regexp.compile(value.to_s) end end |
#type ⇒ Object
11 12 13 |
# File 'lib/msf/core/opt_regexp.rb', line 11 def type return 'regexp' end |
#valid?(value, check_empty: true) ⇒ Boolean
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/msf/core/opt_regexp.rb', line 15 def valid?(value, check_empty: true) if check_empty && empty_required_value?(value) return false elsif value.nil? return true end begin Regexp.compile(value) return super rescue RegexpError, TypeError return false end end |