Class: Msf::OptRegexp

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

Overview

Regexp 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?, #empty_required_value?, #evasion?, #initialize, #required?, #type?

Constructor Details

This class inherits a constructor from Msf::OptBase

Instance Method Details

#display_value(value) ⇒ Object


499
500
501
502
503
504
505
506
507
# File 'lib/msf/core/option_container.rb', line 499

def display_value(value)
  if value.kind_of?(Regexp)
    return value.source
  elsif value.kind_of?(String)
    return display_value(normalize(value))
  end

  return super
end

#normalize(value) ⇒ Object


494
495
496
497
# File 'lib/msf/core/option_container.rb', line 494

def normalize(value)
  return nil if value.nil?
  return Regexp.compile(value)
end

#typeObject


475
476
477
# File 'lib/msf/core/option_container.rb', line 475

def type
  return 'regexp'
end

#valid?(value) ⇒ Boolean


479
480
481
482
483
484
485
486
487
488
489
490
491
492
# File 'lib/msf/core/option_container.rb', line 479

def valid?(value)
  unless super
    return false
  end
  return true if (not required? and value.nil?)

  begin
    Regexp.compile(value)

    return true
  rescue RegexpError, TypeError
    return false
  end
end