Module: Msf::Module::Deprecated::ClassMethods

Defined in:
lib/msf/core/module/deprecated.rb

Overview

Additional class methods for deprecated modules

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#deprecated_namesObject

Returns the value of attribute deprecated_names


8
9
10
# File 'lib/msf/core/module/deprecated.rb', line 8

def deprecated_names
  @deprecated_names
end

#deprecation_dateObject

Returns the value of attribute deprecation_date


7
8
9
# File 'lib/msf/core/module/deprecated.rb', line 7

def deprecation_date
  @deprecation_date
end

#deprecation_reasonObject

Returns the value of attribute deprecation_reason


9
10
11
# File 'lib/msf/core/module/deprecated.rb', line 9

def deprecation_reason
  @deprecation_reason
end

Instance Method Details

#deprecated(date, reason = nil) ⇒ void

This method returns an undefined value.

Mark this module as deprecated

Any time this module is run it will print warnings to that effect.

Parameters:

  • date (Date, #to_s)

    The date on which this module will be removed

  • reason (String) (defaults to: nil)

    A description reason for this module being deprecated


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/msf/core/module/deprecated.rb', line 19

def deprecated(date, reason = nil)
  self.deprecation_date = date
  self.deprecation_reason = reason

  # NOTE: fullname isn't set until a module has been added to a set, which is after it is evaluated
  add_warning do
    details = [
      "*%red" + "The module #{fullname} is deprecated!".center(88) + "%clr*",
      "*" + "This module will be removed on or about #{date}".center(88) + "*"
    ]
    details << "*#{reason.center(88)}*" if reason.present?

    details
  end
end

#moved_from(from) ⇒ Object

Mark this module as moved from another location. This adds an alias to the module so that it can still be used by its old name and will print a warning informing the use of the new name.

Parameters:

  • from (String)

    the previous `fullname` of the module


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/msf/core/module/deprecated.rb', line 40

def moved_from(from)
  self.deprecated_names << from

  if const_defined?(:Aliases)
    const_get(:Aliases).append from
  else
    const_set(:Aliases, [from])
  end

  # NOTE: aliases are not set until after initialization, so might as well
  # use the block form of alert here too.
  add_warning do
    if fullname == from
      [ "*%red" + "The module #{fullname} has been moved!".center(88) + "%clr*",
        "*" + "You are using #{realname}".center(88) + "*" ]
    end
  end
end