Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/msf/core/module/deprecated.rb
Views: 11784
# -*- coding: binary -*-12module Msf::Module::Deprecated34# Additional class methods for deprecated modules5module ClassMethods6attr_accessor :deprecation_date7attr_accessor :deprecated_names8attr_accessor :deprecation_reason910# Mark this module as deprecated11#12# Any time this module is run it will print warnings to that effect.13#14# @param date [Date,#to_s] The date on which this module will15# be removed16# @param reason [String] A description reason for this module being deprecated17# @return [void]18def deprecated(date = nil, reason = nil)19self.deprecation_date = date20self.deprecation_reason = reason2122# NOTE: fullname isn't set until a module has been added to a set, which is after it is evaluated23add_warning do24details = [25"*%red" + "The module #{fullname} is deprecated!".center(88) + "%clr*",26]27details << "*" + "This module will be removed on or about #{date}".center(88) + "*" if date28details << "*#{reason.center(88)}*" if reason.present?2930details31end32end3334# Mark this module as moved from another location. This adds an alias to35# the module so that it can still be used by its old name and will print a36# warning informing the use of the new name.37#38# @param from [String] the previous `fullname` of the module39def moved_from(from)40self.deprecated_names << from4142if const_defined?(:Aliases)43const_get(:Aliases).append from44else45const_set(:Aliases, [from])46end4748# NOTE: aliases are not set until after initialization, so might as well49# use the block form of alert here too.50add_warning do51if fullname == from52[ "*%red" + "The module #{fullname} has been moved!".center(88) + "%clr*",53"*" + "You are using #{realname}".center(88) + "*" ]54end55end56end57end5859# Extends with {ClassMethods}60def self.included(base)61base.extend(ClassMethods)62base.deprecated_names = []63end64end656667