Class: Msf::OptInt

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

Overview

Integer option.

Instance Attribute Summary

Attributes inherited from OptBase

#advanced, #default, #desc, #enums, #evasion, #name, #owner, #required

Instance Method Summary collapse

Methods inherited from OptBase

#advanced?, #display_value, #empty_required_value?, #evasion?, #initialize, #required?, #type?

Constructor Details

This class inherits a constructor from Msf::OptBase

Instance Method Details

#normalize(value) ⇒ Object


449
450
451
452
453
454
455
# File 'lib/msf/core/option_container.rb', line 449

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

#typeObject


445
446
447
# File 'lib/msf/core/option_container.rb', line 445

def type
  return 'integer'
end

#valid?(value) ⇒ Boolean


457
458
459
460
461
462
463
464
465
466
# File 'lib/msf/core/option_container.rb', line 457

def valid?(value)
  return super if !required? and value.to_s.empty?
  return false if empty_required_value?(value)

  if value and not value.to_s.match(/^0x[0-9a-fA-F]+$|^-?\d+$/)
    return false
  end

  return super
end