Module: Arachni::UI::Output
- Extended by:
- Output
- Included in:
- Component::Manager, Framework, Module::Output, Parser, Plugin::Formatter, RPC::Server::Dispatcher, RPC::Server::Dispatcher::Node, RPC::Server::Instance, Report::Base, Session, Spider, CLI, DispatcherMonitor, Output, RPC, 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.
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
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
-
#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_bad(str = '') ⇒ Object
Same as print_error but the message won’t be printed to stderr.
-
#print_debug(str = '') ⇒ void
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 = '') ⇒ void
Prints an error message.
- #print_error_backtrace(e) ⇒ 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
- #set_buffer_cap(cap) ⇒ 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 |
# 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 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 |
# 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 end |
Instance Method Details
#debug? ⇒ Bool
Returns the @@debug flag
272 273 274 |
# File 'lib/arachni/ui/cli/output.rb', line 272 def debug? @@debug end |
#debug_off ⇒ Object
262 263 264 |
# File 'lib/arachni/ui/cli/output.rb', line 262 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
257 258 259 |
# File 'lib/arachni/ui/cli/output.rb', line 257 def debug_on @@debug = true end |
#disable_only_positives ⇒ Object
286 287 288 |
# File 'lib/arachni/ui/cli/output.rb', line 286 def disable_only_positives @@only_positives = false 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 |
#mute ⇒ Object
300 301 302 |
# File 'lib/arachni/ui/cli/output.rb', line 300 def mute @@mute = true end |
#muted? ⇒ Boolean
308 309 310 |
# File 'lib/arachni/ui/cli/output.rb', line 308 def muted? @@mute end |
#only_positives ⇒ void
This method returns an undefined value.
Sets the @@only_positives flag to true
282 283 284 |
# File 'lib/arachni/ui/cli/output.rb', line 282 def only_positives @@only_positives = true end |
#only_positives? ⇒ Bool
Returns the @@only_positives flag
296 297 298 |
# File 'lib/arachni/ui/cli/output.rb', line 296 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.
99 100 101 102 |
# File 'lib/arachni/ui/cli/output.rb', line 99 def print_bad( str = '', unmute = false ) return if muted? && !unmute print_color( '[-]', 31, str, $stdout, unmute ) end |
#print_debug(str = '') ⇒ void
156 157 158 159 |
# File 'lib/arachni/ui/cli/output.rb', line 156 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
185 186 187 188 |
# File 'lib/arachni/ui/cli/output.rb', line 185 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
171 172 173 174 |
# File 'lib/arachni/ui/cli/output.rb', line 171 def print_debug_pp( obj = nil ) return if !debug? 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.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/arachni/ui/cli/output.rb', line 63 def print_error( str = '' ) print_color( '[-]', 31, str, $stderr, true ) File.open( 'error.log', '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 |
#print_error_backtrace(e) ⇒ Object
190 191 192 |
# File 'lib/arachni/ui/cli/output.rb', line 190 def print_error_backtrace( e ) e.backtrace.each{ |line| print_error( line ) } end |
#print_info(str = '') ⇒ void
129 130 131 132 |
# File 'lib/arachni/ui/cli/output.rb', line 129 def print_info( str = '', unmute = false ) return if only_positives? print_color( '[~]', 30, str, $stdout, unmute ) end |
#print_line(str = '') ⇒ void
220 221 222 223 224 225 226 227 228 229 |
# File 'lib/arachni/ui/cli/output.rb', line 220 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.
142 143 144 |
# File 'lib/arachni/ui/cli/output.rb', line 142 def print_ok( str = '', unmute = false ) print_color( '[+]', 32, str, $stdout, unmute ) end |
#print_status(str = '') ⇒ void
114 115 116 117 |
# File 'lib/arachni/ui/cli/output.rb', line 114 def print_status( str = '', unmute = false ) return if only_positives? print_color( '[*]', 34, str, $stdout, unmute ) end |
#print_verbose(str = '') ⇒ void
205 206 207 208 |
# File 'lib/arachni/ui/cli/output.rb', line 205 def print_verbose( str = '', unmute = false ) return if !verbose? print_color( '[v]', 37, str, $stdout, unmute ) end |
#reroute_to_file(file) ⇒ Object
187 188 189 |
# File 'lib/arachni/rpc/server/output.rb', line 187 def reroute_to_file( file ) @@reroute_to_file = file end |
#reroute_to_file? ⇒ Boolean
191 192 193 |
# File 'lib/arachni/rpc/server/output.rb', line 191 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 |
#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
304 305 306 |
# File 'lib/arachni/ui/cli/output.rb', line 304 def unmute @@mute = false end |
#verbose ⇒ void
This method returns an undefined value.
Sets the @@verbose flag to true
237 238 239 |
# File 'lib/arachni/ui/cli/output.rb', line 237 def verbose @@verbose = true end |
#verbose? ⇒ Bool
Returns the @@verbose flag
247 248 249 |
# File 'lib/arachni/ui/cli/output.rb', line 247 def verbose? @@verbose end |