Skip to content

Loading…

Add print_warning() #899

Closed
wants to merge 1 commit into from

3 participants

@wchen-r7

So we've been kind of using print_debug() as warning messages... we should have a real print_warning().

Related to pull request #891

Test case:
http://pastebin.com/B7swyJPv

@jlee-r7 jlee-r7 pushed a commit that closed this pull request
James Lee Merge branch 'rapid7' into wchen-r7-print_warning
[Closes #899]
ffa4373
@jlee-r7 jlee-r7 closed this in ffa4373
@jlee-r7 jlee-r7 pushed a commit that referenced this pull request
James Lee Merge branch 'wchen-r7-print_warning' into rapid7
[Closes #899]
ed3f87b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 13, 2012
  1. @sinn3r

    Add print_warning()

    sinn3r committed
View
11 lib/msf/core/exploit/http/server.rb
@@ -80,6 +80,12 @@ def print_error(msg='')
def print_debug(msg='')
(cli) ? super("#{cli.peerhost.ljust(16)} #{self.shortname} - #{msg}") : super
end
+ #
+ # :category: print_* overrides
+ # Prepends client and module name if inside a thread with a #cli
+ def print_warning(msg='')
+ (cli) ? super("#{cli.peerhost.ljust(16)} #{self.shortname} - #{msg}") : super
+ end
# :category: print_* overrides
# Prepends client and module name if inside a thread with a #cli
@@ -101,6 +107,11 @@ def vprint_error(msg='')
def vprint_debug(msg='')
(cli) ? super("#{cli.peerhost.ljust(16)} #{self.shortname} - #{msg}") : super
end
+ # :category: print_* overrides
+ # Prepends client and module name if inside a thread with a #cli
+ def vprint_warning(msg='')
+ (cli) ? super("#{cli.peerhost.ljust(16)} #{self.shortname} - #{msg}") : super
+ end
#
View
8 lib/msf/core/module.rb
@@ -208,6 +208,10 @@ def print_good(msg='')
super(print_prefix + msg)
end
+ def print_warning(msg='')
+ super(print_prefix + msg)
+ end
+
#
# Overwrite the Subscriber print_line to do custom prefixes
@@ -241,6 +245,10 @@ def vprint_line(msg)
def vprint_debug(msg)
print_debug(msg) if datastore['VERBOSE'] || framework.datastore['VERBOSE']
end
+ # Verbose version of #print_warning
+ def vprint_warning(msg)
+ print_warning(msg) if datastore['VERBOSE'] || framework.datastore['VERBOSE']
+ end
#
# Returns the module's framework full reference name. This is the
View
8 lib/msf/core/plugin.rb
@@ -141,6 +141,14 @@ def print_line(msg='')
end
#
+ # Prints a warning
+ #
+ def print_warning(msg='')
+ output.print_warning(msg) if (output)
+ end
+
+
+ #
# Prints a message with no decoration.
#
def print(msg='')
View
4 lib/rex/io/bidirectional_pipe.rb
@@ -98,6 +98,10 @@ def print_status(msg='')
print_line('[*] ' + msg)
end
+ def print_warning(msg='')
+ print_warning('[!] ' + msg)
+ end
+
#
# Wrappers for the pipe_input methods
#
View
1 lib/rex/script/base.rb
@@ -9,6 +9,7 @@ def print_line(msg); end
def print_status(msg); end
def print_good(msg); end
def print_error(msg); end
+ def print_warning(msg); end
end
attr_accessor :client, :framework, :path, :error, :args
View
6 lib/rex/ui/output.rb
@@ -46,6 +46,12 @@ def print_line(msg='')
end
#
+ # Prints a warning
+ #
+ def print_warning(msg='')
+ end
+
+ #
# Prints a message with no decoration.
#
def print(msg='')
View
10 lib/rex/ui/subscriber.rb
@@ -67,6 +67,16 @@ def print_debug(msg='')
end
#
+ # Wraps user_output.print_warning
+ #
+ def print_warning(msg='')
+ if (user_output)
+ print_blank_line if user_output.prompting?
+ user_output.print_warning(msg)
+ end
+ end
+
+ #
# Wraps user_output.print
#
def print(msg='')
View
7 lib/rex/ui/text/dispatcher_shell.rb
@@ -82,6 +82,13 @@ def print_good(msg = '')
end
#
+ # Wraps shell.print_warning
+ #
+ def print_warning(msg = '')
+ shell.print_warning(msg)
+ end
+
+ #
# Wraps shell.print
#
def print(msg = '')
View
4 lib/rex/ui/text/output.rb
@@ -67,6 +67,10 @@ def print_line(msg = '')
print(msg + "\n")
end
+ def print_warning(msg = '')
+ print_line("%bld%yel[!]%clr #{msg}")
+ end
+
def print(msg = '')
print_raw(substitute_colors(msg))
end
View
10 lib/rex/ui/text/shell.rb
@@ -304,6 +304,16 @@ def print_line(msg='')
end
#
+ # Prints a warning message to the output handle.
+ #
+ def print_warning(msg='')
+ return if (disable_output == true)
+
+ self.on_print_proc.call(msg) if self.on_print_proc
+ log_output(output.print_warning(msg))
+ end
+
+ #
# Prints a raw message to the output handle.
#
def print(msg='')
Something went wrong with that request. Please try again.