2014-08-17 22:31:53 +00:00
|
|
|
# -*- coding: binary -*-
|
2013-01-03 01:14:44 +00:00
|
|
|
|
|
|
|
module Msf::Module::Deprecated
|
|
|
|
|
2013-08-30 21:28:33 +00:00
|
|
|
# Additional class methods for deprecated modules
|
|
|
|
module ClassMethods
|
|
|
|
# Mark this module as deprecated
|
|
|
|
#
|
|
|
|
# Any time this module is run it will print warnings to that effect.
|
|
|
|
#
|
|
|
|
# @param deprecation_date [Date,#to_s] The date on which this module will
|
|
|
|
# be removed
|
|
|
|
# @param replacement_module [String] The name of a module that users
|
|
|
|
# should be using instead of this deprecated one
|
|
|
|
# @return [void]
|
|
|
|
def deprecated(deprecation_date=nil, replacement_module=nil)
|
|
|
|
# Yes, class instance variables.
|
|
|
|
@replacement_module = replacement_module
|
|
|
|
@deprecation_date = deprecation_date
|
|
|
|
end
|
|
|
|
|
|
|
|
# The name of a module that users should be using instead of this
|
|
|
|
# deprecated one
|
|
|
|
#
|
|
|
|
# @return [String,nil]
|
|
|
|
# @see ClassMethods#deprecated
|
|
|
|
def replacement_module; @replacement_module; end
|
|
|
|
|
|
|
|
# The date on which this module will be removed
|
|
|
|
#
|
|
|
|
# @return [Date,nil]
|
|
|
|
# @see ClassMethods#deprecated
|
|
|
|
def deprecation_date; @deprecation_date; end
|
|
|
|
end
|
|
|
|
|
|
|
|
# (see ClassMethods#replacement_module)
|
2014-04-24 03:03:02 +00:00
|
|
|
def replacement_module
|
|
|
|
if self.class.instance_variable_defined?(:@replacement_module)
|
|
|
|
return self.class.replacement_module
|
|
|
|
elsif self.class.const_defined?(:DEPRECATION_REPLACEMENT)
|
|
|
|
return self.class.const_get(:DEPRECATION_REPLACEMENT)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-08-30 21:28:33 +00:00
|
|
|
# (see ClassMethods#deprecation_date)
|
2014-04-24 03:03:02 +00:00
|
|
|
def deprecation_date
|
|
|
|
if self.class.instance_variable_defined?(:@deprecation_date)
|
|
|
|
return self.class.deprecation_date
|
|
|
|
elsif self.class.const_defined?(:DEPRECATION_DATE)
|
|
|
|
return self.class.const_get(:DEPRECATION_DATE)
|
|
|
|
end
|
|
|
|
end
|
2013-08-30 21:28:33 +00:00
|
|
|
|
|
|
|
# Extends with {ClassMethods}
|
|
|
|
def self.included(base)
|
|
|
|
base.extend(ClassMethods)
|
|
|
|
end
|
|
|
|
|
2014-04-24 03:03:02 +00:00
|
|
|
# Print the module deprecation information
|
|
|
|
#
|
|
|
|
# @return [void]
|
|
|
|
def print_deprecation_warning
|
2013-08-30 21:28:33 +00:00
|
|
|
print_warning("*"*72)
|
2014-04-24 03:03:02 +00:00
|
|
|
print_warning("*%red"+"The module #{refname} is deprecated!".center(70)+"%clr*")
|
2013-08-30 21:28:33 +00:00
|
|
|
if deprecation_date
|
|
|
|
print_warning("*"+"It will be removed on or about #{deprecation_date}".center(70)+"*")
|
|
|
|
end
|
|
|
|
if replacement_module
|
|
|
|
print_warning("*"+"Use #{replacement_module} instead".center(70)+"*")
|
|
|
|
end
|
|
|
|
print_warning("*"*72)
|
2014-04-24 03:03:02 +00:00
|
|
|
end
|
|
|
|
|
2014-06-06 22:04:40 +00:00
|
|
|
def init_ui(input = nil, output = nil)
|
|
|
|
super(input, output)
|
|
|
|
print_deprecation_warning
|
2014-06-10 18:56:19 +00:00
|
|
|
@you_have_been_warned = true
|
2014-06-06 22:04:40 +00:00
|
|
|
end
|
|
|
|
|
2014-04-24 03:03:02 +00:00
|
|
|
def generate
|
|
|
|
print_deprecation_warning
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def setup
|
2014-06-10 18:56:19 +00:00
|
|
|
print_deprecation_warning unless @you_have_been_warned
|
2013-08-30 21:28:33 +00:00
|
|
|
super
|
|
|
|
end
|
2013-01-03 01:14:44 +00:00
|
|
|
|
|
|
|
end
|