Module: Arachni::UI::Output
- Extended by:
- Output
- Included in:
- Component::Manager, Framework, Module::Output, Parser, Platform::Manager, Platform::Manager, Plugin::Formatter, RPC::Server::Dispatcher, RPC::Server::Dispatcher::Node, RPC::Server::Instance, Report::Base, Session, Spider, CLI, CLI::RPC::DispatcherMonitor, CLI::RPC::Instance, CLI::RPC::Local, CLI::RPC::Remote, Output, Arachni::URI, Arachni::URI
- Defined in:
- lib/arachni/ui/cli/output.rb,
lib/arachni/ui/foo/output.rb,
lib/arachni/rpc/server/output.rb
Overview
RPC Output module
It basically classifies and buffers all system messages until it’s time to flush the buffer and send them over the wire.
Class Method Summary collapse
Instance Method Summary collapse
-
#debug? ⇒ Bool
Returns the @@debug flag.
- #debug_off ⇒ Object
-
#debug_on ⇒ void
(also: #debug)
Sets the @@debug flag to true.
- #disable_only_positives ⇒ Object
- #error_logfile ⇒ Object
-
#flush_buffer ⇒ Array<Hash>
Empties the output buffer and returns all messages.
- #log_error(str = '') ⇒ Object
- #mute ⇒ Object
- #muted? ⇒ Boolean
-
#only_positives ⇒ void
Sets the @@only_positives flag to true.
-
#only_positives? ⇒ Bool
Returns the @@only_positives flag.
-
#print_bad(str = '') ⇒ Object
Same as print_error but the message won’t be printed to stderr.
-
#print_debug(str = '') ⇒ Object
Prints a debugging message.
-
#print_debug_backtrace ⇒ Object
Prints the backtrace of an exception.
-
#print_debug_pp ⇒ Object
Pretty prints an object, used for debugging, needs some improvement but it’ll do for now.
-
#print_error(str = '') ⇒ Object
Prints an error message.
- #print_error_backtrace(e) ⇒ Object
-
#print_info(str = '') ⇒ Object
Prints an info message.
-
#print_line(str = '') ⇒ Object
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 = '') ⇒ Object
Prints a status message.
-
#print_verbose(str = '') ⇒ Object
Prints a verbose message.
- #reroute_to_file(file) ⇒ Object
- #reroute_to_file? ⇒ Boolean
- #set_buffer_cap(cap) ⇒ Object
- #set_error_logfile(logfile) ⇒ Object
- #uncap_buffer ⇒ Object
- #unmute ⇒ Object
-
#verbose ⇒ void
Sets the @@verbose flag to true.
-
#verbose? ⇒ Bool
Returns the @@verbose flag.
Class Method Details
.old_reset_output_options ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/arachni/rpc/server/output.rb', line 35 def self. # verbosity flag # # if it's on verbose messages will be enabled @@verbose = false # debug flag # # if it's on debugging messages will be enabled @@debug = false @@mute = false # only_positives flag # # if it's on status messages will be disabled @@only_positives = false @@reroute_to_file = false @@opened = false @@error_logfile = 'error.log' end |
.reset_output_options ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/arachni/ui/cli/output.rb', line 31 def self. # verbosity flag # # if it's on verbose messages will be enabled @@verbose = false # debug flag # # if it's on debugging messages will be enabled @@debug = false @@mute = false # only_positives flag # # if it's on status messages will be disabled @@only_positives = false @@reroute_to_file = false @@opened = false @@error_logfile = 'error.log' end |
Instance Method Details
#debug? ⇒ Bool
Returns the @@debug flag
286 287 288 |
# File 'lib/arachni/ui/cli/output.rb', line 286 def debug? @@debug end |
#debug_off ⇒ Object
276 277 278 |
# File 'lib/arachni/ui/cli/output.rb', line 276 def debug_off @@debug = false end |
#debug_on ⇒ void Also known as: debug
This method returns an undefined value.
Sets the @@debug flag to true
271 272 273 |
# File 'lib/arachni/ui/cli/output.rb', line 271 def debug_on @@debug = true end |
#disable_only_positives ⇒ Object
300 301 302 |
# File 'lib/arachni/ui/cli/output.rb', line 300 def disable_only_positives @@only_positives = false end |
#error_logfile ⇒ Object
62 63 64 |
# File 'lib/arachni/ui/cli/output.rb', line 62 def error_logfile @@error_logfile end |
#flush_buffer ⇒ Array<Hash>
Empties the output buffer and returns all messages.
Messages are classified by their type.
53 54 55 56 57 |
# File 'lib/arachni/rpc/server/output.rb', line 53 def flush_buffer buf = @@output_buffer.dup @@output_buffer.clear buf end |
#log_error(str = '') ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/arachni/ui/cli/output.rb', line 78 def log_error( str = '' ) File.open( @@error_logfile, 'a' ) do |f| if !@@opened f.puts f.puts "#{Time.now} " + ( "-" * 80 ) begin h = {} ENV.each { |k, v| h[k] = v } f.puts 'ENV:' f.puts h.to_yaml f.puts "-" * 80 f.puts 'OPTIONS:' f.puts Arachni::Options.instance.to_yaml rescue end f.puts "-" * 80 end print_color( "[#{Time.now}]", 31, str, f, true ) end @@opened = true end |
#mute ⇒ Object
314 315 316 |
# File 'lib/arachni/ui/cli/output.rb', line 314 def mute @@mute = true end |
#muted? ⇒ Boolean
322 323 324 |
# File 'lib/arachni/ui/cli/output.rb', line 322 def muted? @@mute end |
#only_positives ⇒ void
This method returns an undefined value.
Sets the @@only_positives flag to true
296 297 298 |
# File 'lib/arachni/ui/cli/output.rb', line 296 def only_positives @@only_positives = true end |
#only_positives? ⇒ Bool
Returns the @@only_positives flag
310 311 312 |
# File 'lib/arachni/ui/cli/output.rb', line 310 def only_positives? @@only_positives end |
#print_bad(str = '') ⇒ Object
Same as print_error but the message won’t be printed to stderr.
Used mainly to draw attention to something that didn’t behave as expected rather than display an actual error.
113 114 115 116 |
# File 'lib/arachni/ui/cli/output.rb', line 113 def print_bad( str = '', unmute = false ) return if muted? && !unmute print_color( '[-]', 31, str, $stdout, unmute ) end |
#print_debug(str = '') ⇒ Object
Prints a debugging message
Obeys @@debug
170 171 172 173 |
# File 'lib/arachni/ui/cli/output.rb', line 170 def print_debug( str = '', unmute = false ) return if !debug? print_color( '[!]', 36, str, $stderr, unmute ) end |
#print_debug_backtrace ⇒ Object
Prints the backtrace of an exception
Obeys @@debug
199 200 201 202 |
# File 'lib/arachni/ui/cli/output.rb', line 199 def print_debug_backtrace( e ) return if !debug? e.backtrace.each{ |line| print_debug( line ) } end |
#print_debug_pp ⇒ Object
Pretty prints an object, used for debugging, needs some improvement but it’ll do for now
Obeys @@debug
185 186 187 188 |
# File 'lib/arachni/ui/cli/output.rb', line 185 def print_debug_pp( obj = nil ) return if !debug? pp obj end |
#print_error(str = '') ⇒ Object
Prints an error message
It ignores all flags, error messages will be output under all circumstances.
73 74 75 76 |
# File 'lib/arachni/ui/cli/output.rb', line 73 def print_error( str = '' ) print_color( '[-]', 31, str, $stderr, true ) log_error( str ) end |
#print_error_backtrace(e) ⇒ Object
204 205 206 |
# File 'lib/arachni/ui/cli/output.rb', line 204 def print_error_backtrace( e ) e.backtrace.each{ |line| print_error( line ) } end |
#print_info(str = '') ⇒ Object
Prints an info message
Obeys @@only_positives
143 144 145 146 |
# File 'lib/arachni/ui/cli/output.rb', line 143 def print_info( str = '', unmute = false ) return if only_positives? print_color( '[~]', 30, str, $stdout, unmute ) end |
#print_line(str = '') ⇒ Object
Prints a line of message
Obeys @@only_positives
234 235 236 237 238 239 240 241 242 243 |
# File 'lib/arachni/ui/cli/output.rb', line 234 def print_line( str = '', unmute = false ) return if only_positives? return if muted? && !unmute # we may get IO errors...freaky stuff... begin puts str rescue end 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.
156 157 158 |
# File 'lib/arachni/ui/cli/output.rb', line 156 def print_ok( str = '', unmute = false ) print_color( '[+]', 32, str, $stdout, unmute ) end |
#print_status(str = '') ⇒ Object
Prints a status message
Obeys @@only_positives
128 129 130 131 |
# File 'lib/arachni/ui/cli/output.rb', line 128 def print_status( str = '', unmute = false ) return if only_positives? print_color( '[*]', 34, str, $stdout, unmute ) end |
#print_verbose(str = '') ⇒ Object
Prints a verbose message
Obeys @@verbose
219 220 221 222 |
# File 'lib/arachni/ui/cli/output.rb', line 219 def print_verbose( str = '', unmute = false ) return if !verbose? print_color( '[v]', 37, str, $stdout, unmute ) end |
#reroute_to_file(file) ⇒ Object
181 182 183 |
# File 'lib/arachni/rpc/server/output.rb', line 181 def reroute_to_file( file ) @@reroute_to_file = file end |
#reroute_to_file? ⇒ Boolean
185 186 187 |
# File 'lib/arachni/rpc/server/output.rb', line 185 def reroute_to_file? @@reroute_to_file end |
#set_buffer_cap(cap) ⇒ Object
59 60 61 |
# File 'lib/arachni/rpc/server/output.rb', line 59 def set_buffer_cap( cap ) @@output_buffer_cap = cap end |
#set_error_logfile(logfile) ⇒ Object
58 59 60 |
# File 'lib/arachni/ui/cli/output.rb', line 58 def set_error_logfile( logfile ) @@error_logfile = logfile end |
#uncap_buffer ⇒ Object
63 64 65 |
# File 'lib/arachni/rpc/server/output.rb', line 63 def uncap_buffer @@output_buffer_cap = nil end |
#unmute ⇒ Object
318 319 320 |
# File 'lib/arachni/ui/cli/output.rb', line 318 def unmute @@mute = false end |
#verbose ⇒ void
This method returns an undefined value.
Sets the @@verbose flag to true
251 252 253 |
# File 'lib/arachni/ui/cli/output.rb', line 251 def verbose @@verbose = true end |
#verbose? ⇒ Bool
Returns the @@verbose flag
261 262 263 |
# File 'lib/arachni/ui/cli/output.rb', line 261 def verbose? @@verbose end |