Module: Arachni::UI::Output
- Included in:
- Anemone::Core, Anemone::HTTP, Anemone::Page, ComponentManager, Framework, HTTP, Module::Manager, Module::Output, Plugin::Formatter, RPC::XML::Server::Dispatcher, RPC::XML::Server::Instance, Report::Base, Spider, CLI, DispatcherMonitor, XMLRPC
- Defined in:
- lib/ui/cli/output.rb,
lib/rpc/xml/server/output.rb
Overview
XML-RPC deamon Output module
It basically classifies and buffers all system messages until it’s time to flush the buffer and send them over the wire.
@author: Tasos “Zapotek” Laskos
<tasos.laskos@gmail.com>
<zapotek@segfault.gr>
@version: 0.1
Constant Summary collapse
- @@verbose =
verbosity flag
if it’s on verbose messages will be enabled
false- @@debug =
debug flag
if it’s on debugging messages will be enabled
false- @@only_positives =
only_positives flag
if it’s on status messages will be disabled
false- @@mute =
false- @@reroute_to_file =
false
Instance Method Summary collapse
- #buffer(msg) ⇒ Object
-
#debug! ⇒ void
Sets the @@debug flag to true.
-
#debug? ⇒ Bool
Returns the @@debug flag.
-
#flush_buffer ⇒ Array<Hash>
Empties the output buffer and returns all messages.
- #mute! ⇒ Object
- #muted? ⇒ Boolean
-
#only_positives! ⇒ void
Sets the @@only_positives flag to true.
-
#only_positives? ⇒ Bool
Returns the @@only_positives flag.
-
#print_debug(str = '') ⇒ void
Prints a debugging message.
-
#print_debug_backtrace(e = nil) ⇒ void
Prints the backtrace of an exception.
-
#print_debug_pp(obj = nil) ⇒ void
Pretty prints an object, used for debugging, needs some improvement but it’ll do for now.
-
#print_error(str = '') ⇒ void
Prints an error message.
- #print_error_backtrace(e = nil) ⇒ Object
-
#print_info(str = '') ⇒ void
Prints an info message.
-
#print_line(str = '') ⇒ void
Prints a line of message.
-
#print_ok(str = '') ⇒ void
Prints a good message, something that went very very right, like the discovery of a vulnerability.
-
#print_status(str = '') ⇒ void
Prints a status message.
-
#print_verbose(str = '') ⇒ void
Prints a verbose message.
- #reroute_to_file(file) ⇒ Object
- #reroute_to_file? ⇒ Boolean
- #unmute! ⇒ Object
-
#verbose! ⇒ void
Sets the @@verbose flag to true.
-
#verbose? ⇒ Bool
Returns the @@verbose flag.
Instance Method Details
#buffer(msg) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/rpc/xml/server/output.rb', line 60 def buffer( msg ) if file = @@reroute_to_file File.open( file, 'a+' ) { |f| type = msg.keys[0] str = msg.values[0] next if str.empty? f.write( "[#{Time.now.asctime}] [#{type}] #{str}\n" ) } else @@buffer << msg end end |
#debug! ⇒ void
This method returns an undefined value.
Sets the @@debug flag to true
207 208 209 |
# File 'lib/ui/cli/output.rb', line 207 def debug! @@debug = true end |
#debug? ⇒ Bool
Returns the @@debug flag
217 218 219 |
# File 'lib/ui/cli/output.rb', line 217 def debug? @@debug end |
#flush_buffer ⇒ Array<Hash>
Empties the output buffer and returns all messages.
Messages are classified by their type.
54 55 56 57 58 |
# File 'lib/rpc/xml/server/output.rb', line 54 def flush_buffer buf = @@buffer.dup @@buffer.clear return buf end |
#mute! ⇒ Object
241 242 243 |
# File 'lib/ui/cli/output.rb', line 241 def mute! @@mute = true end |
#muted? ⇒ Boolean
250 251 252 |
# File 'lib/ui/cli/output.rb', line 250 def muted? @@mute end |
#only_positives! ⇒ void
This method returns an undefined value.
Sets the @@only_positives flag to true
227 228 229 |
# File 'lib/ui/cli/output.rb', line 227 def only_positives! @@only_positives = true end |
#only_positives? ⇒ Bool
Returns the @@only_positives flag
237 238 239 |
# File 'lib/ui/cli/output.rb', line 237 def only_positives? @@only_positives end |
#print_debug(str = '') ⇒ void
109 110 111 112 |
# File 'lib/ui/cli/output.rb', line 109 def print_debug( str = '' ) if !@@debug then return end print_color( '[!]', 36, str, $stderr ) end |
#print_debug_backtrace(e = nil) ⇒ void
140 141 142 143 |
# File 'lib/ui/cli/output.rb', line 140 def print_debug_backtrace( e = nil ) if !@@debug then return end e.backtrace.each{ |line| print_debug( line ) } end |
#print_debug_pp(obj = nil) ⇒ void
This method returns an undefined value.
Pretty prints an object, used for debugging, needs some improvement but it’ll do for now
Obeys @@debug
125 126 127 128 |
# File 'lib/ui/cli/output.rb', line 125 def print_debug_pp( obj = nil ) if !@@debug then return end pp obj end |
#print_error(str = '') ⇒ void
This method returns an undefined value.
Prints an error message
It ignores all flags, error messages will be output under all circumstances.
53 54 55 |
# File 'lib/ui/cli/output.rb', line 53 def print_error( str = '' ) print_color( '[-]', 31, str, $stderr ) end |
#print_error_backtrace(e = nil) ⇒ Object
145 146 147 |
# File 'lib/ui/cli/output.rb', line 145 def print_error_backtrace( e = nil ) e.backtrace.each{ |line| print_error( line ) } end |
#print_info(str = '') ⇒ void
82 83 84 85 |
# File 'lib/ui/cli/output.rb', line 82 def print_info( str = '' ) if @@only_positives then return end print_color( '[~]', 30, str ) end |
#print_line(str = '') ⇒ void
175 176 177 178 179 |
# File 'lib/ui/cli/output.rb', line 175 def print_line( str = '' ) if @@only_positives then return end return if muted? puts str end |
#print_ok(str = '') ⇒ void
This method returns an undefined value.
Prints a good message, something that went very very right, like the discovery of a vulnerability
Disregards all flags.
95 96 97 |
# File 'lib/ui/cli/output.rb', line 95 def print_ok( str = '' ) print_color( '[+]', 32, str ) end |
#print_status(str = '') ⇒ void
67 68 69 70 |
# File 'lib/ui/cli/output.rb', line 67 def print_status( str = '' ) if @@only_positives then return end print_color( '[*]', 34, str ) end |
#print_verbose(str = '') ⇒ void
160 161 162 163 |
# File 'lib/ui/cli/output.rb', line 160 def print_verbose( str = '' ) if !@@verbose then return end print_color( '[v]', 37, str ) end |
#reroute_to_file(file) ⇒ Object
272 273 274 |
# File 'lib/rpc/xml/server/output.rb', line 272 def reroute_to_file( file ) @@reroute_to_file = file end |
#reroute_to_file? ⇒ Boolean
276 277 278 |
# File 'lib/rpc/xml/server/output.rb', line 276 def reroute_to_file? @@reroute_to_file end |
#unmute! ⇒ Object
245 246 247 |
# File 'lib/ui/cli/output.rb', line 245 def unmute! @@mute = false end |
#verbose! ⇒ void
This method returns an undefined value.
Sets the @@verbose flag to true
187 188 189 |
# File 'lib/ui/cli/output.rb', line 187 def verbose! @@verbose = true end |
#verbose? ⇒ Bool
Returns the @@verbose flag
197 198 199 |
# File 'lib/ui/cli/output.rb', line 197 def verbose? @@verbose end |