Class: Msf::OptInt

Inherits:
OptBase show all
Defined in:
lib/msf/core/opt_int.rb

Overview

Integer option.

Direct Known Subclasses

OptPort

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

Methods inherited from OptBase

#advanced?, #display_value, #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

#normalize(value) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/msf/core/opt_int.rb', line 14

def normalize(value)
  if value.to_s.match(/^0x[a-fA-F\d]+$/)
    value.to_i(16)
  elsif value.present?
    value.to_i
  end
end

#typeObject



10
11
12
# File 'lib/msf/core/opt_int.rb', line 10

def type
  'integer'
end

#valid?(value, check_empty: true) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
26
# File 'lib/msf/core/opt_int.rb', line 22

def valid?(value, check_empty: true)
  return false if check_empty && empty_required_value?(value)
  return false if value.present? && !value.to_s.match(/^0x[0-9a-fA-F]+$|^-?\d+$/)
  super
end