Module: Arachni::UI::Output
- Extended by:
- Output
- Included in:
- Browser, Browser::Javascript, BrowserCluster, Component::Manager, Component::Output, Data::Plugins, Framework, HTTP::Client, HTTP::Client::Dynamic404Handler, HTTP::ProxyServer, HTTP::ProxyServer::Connection, HTTP::ProxyServer::SSLInterceptor, HTTP::ProxyServer::Tunnel, HTTP::Request, Parser, Platform::Manager, Platform::Manager, Plugin::Formatter, Plugins::Proxy::TemplateScope, RPC::Server::Dispatcher, RPC::Server::Dispatcher::Node, RPC::Server::Instance, Rest::Server, Session, Support::Mixins::Observable, Trainer, CLI::Framework, CLI::OptionParser, CLI::RPC::Client::DispatcherMonitor, CLI::RPC::Client::Instance, CLI::RPC::Client::Remote, CLI::Reporter, CLI::Reproduce, Output, Arachni::URI, Arachni::URI
- Defined in:
- lib/arachni/ui/foo/output.rb,
lib/arachni/rpc/server/output.rb,
ui/cli/output.rb
Overview
CLI Output module.
Provides a command line output interface to the framework.
All UIs should provide an Arachni::UI::Output
module with these methods.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #caller_location ⇒ Object
- #debug?(level = 1) ⇒ Bool
-
#debug_level ⇒ Integer
Debugging level.
- #debug_level_1? ⇒ Boolean
- #debug_level_2? ⇒ Boolean
- #debug_level_3? ⇒ Boolean
- #debug_level_4? ⇒ Boolean
-
#debug_off ⇒ Object
Disables #print_debug messages.
-
#debug_on(level = 1) ⇒ Object
(also: #debug)
Enables #print_debug messages.
-
#disable_only_positives ⇒ Object
Undoes #only_positives.
- #error_buffer ⇒ Object
- #error_log_fd ⇒ Object
-
#error_logfile ⇒ String
Location of the error log file.
- #has_error_log? ⇒ Boolean
- #included(base) ⇒ Object
-
#log_error(str = '') ⇒ Object
Logs an error message to the error log file.
-
#mute ⇒ Object
Mutes all output messages, unless they explicitly override the mute status.
- #muted? ⇒ Bool
-
#only_positives ⇒ Object
Mutes everything but #print_ok messages.
- #only_positives? ⇒ Bool
-
#print_bad(str = '', unmute = false) ⇒ Object
Used to draw attention to a bad situation which isn't an error.
-
#print_debug(str = '', level = 1) ⇒ Object
Prints a debugging message.
-
#print_debug_backtrace(e, level = 1) ⇒ Object
Prints the backtrace of an exception as debugging messages.
- #print_debug_exception(e, level = 1) ⇒ Object
- #print_debug_level_1(str = '') ⇒ Object
- #print_debug_level_2(str = '') ⇒ Object
- #print_debug_level_3(str = '') ⇒ Object
- #print_debug_level_4(str = '') ⇒ Object
-
#print_error(str = '') ⇒ Object
Prints and logs an error message.
-
#print_error_backtrace(e) ⇒ Object
Prints the backtrace of an exception as error messages.
- #print_exception(e) ⇒ Object
-
#print_info(str = '', unmute = false) ⇒ Object
Prints an info message.
-
#print_line(str = '', unmute = false) ⇒ Object
Prints an unclassified message.
-
#print_ok(str = '', unmute = false) ⇒ Object
Prints a good message, something that went very very right, like the discovery of an issue.
-
#print_status(str = '', unmute = false) ⇒ Object
Prints a status message.
-
#print_verbose(str = '', unmute = false) ⇒ Object
Prints a verbose message.
- #reroute_to_file(file) ⇒ Object
- #reroute_to_file? ⇒ Boolean
- #set_error_logfile(logfile) ⇒ Object
-
#unmute ⇒ Object
Unmutes output messages.
- #verbose? ⇒ Bool
-
#verbose_off ⇒ Object
Disables #print_verbose messages.
-
#verbose_on ⇒ Object
(also: #verbose)
Enables #print_verbose messages.
Class Method Details
.reset_output_options ⇒ Object
32 33 |
# File 'lib/arachni/ui/foo/output.rb', line 32 def self. end |
Instance Method Details
#caller_location ⇒ Object
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'ui/cli/output.rb', line 217 def caller_location file = nil line = nil caller_method = nil Kernel.caller.each do |c| file, line, method = *c.scan( /(.*):(\d+):in `(?:.*\s)?(.*)'/ ).flatten next if file == __FILE__ caller_method = method break end context = nil if caller_method file.gsub!( Options.paths.lib, '' ) file.gsub!( Options.paths.root, '' ) dir = File.dirname( file ) dir = '' if dir == '.' dir << File::SEPARATOR if !dir.empty? file = "#{dir}#{File.basename( file, '.rb' )}" context = "[#{file}##{caller_method}:#{line}]" end context end |
#debug?(level = 1) ⇒ Bool
357 358 |
# File 'ui/cli/output.rb', line 357 def debug?(*) end |
#debug_level ⇒ Integer
Returns Debugging level.
347 348 349 |
# File 'ui/cli/output.rb', line 347 def debug_level @@debug end |
#debug_level_1? ⇒ Boolean
75 76 77 |
# File 'lib/arachni/ui/foo/output.rb', line 75 def debug_level_1? debug? 1 end |
#debug_level_2? ⇒ Boolean
78 79 80 |
# File 'lib/arachni/ui/foo/output.rb', line 78 def debug_level_2? debug? 2 end |
#debug_level_3? ⇒ Boolean
81 82 83 |
# File 'lib/arachni/ui/foo/output.rb', line 81 def debug_level_3? debug? 3 end |
#debug_level_4? ⇒ Boolean
84 85 86 |
# File 'lib/arachni/ui/foo/output.rb', line 84 def debug_level_4? debug? 4 end |
#debug_off ⇒ Object
Disables #print_debug messages.
341 342 |
# File 'ui/cli/output.rb', line 341 def debug_off end |
#debug_on(level = 1) ⇒ Object Also known as: debug
Enables #print_debug messages.
333 334 |
# File 'ui/cli/output.rb', line 333 def debug_on(*) end |
#disable_only_positives ⇒ Object
Undoes #only_positives.
380 381 |
# File 'ui/cli/output.rb', line 380 def disable_only_positives end |
#error_buffer ⇒ Object
159 160 161 |
# File 'ui/cli/output.rb', line 159 def error_buffer @@error_buffer end |
#error_log_fd ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'ui/cli/output.rb', line 74 def error_log_fd return @@error_fd if @@error_fd @@error_fd = File.open( error_logfile, 'a' ) @@error_fd.sync = true Kernel.at_exit do begin @@error_fd.close if @@error_fd rescue IOError end end @@error_fd # Errno::EMFILE (too many open files) or something, nothing we can do # about it except catch it to avoid a crash. rescue SystemCallError => e print_bad "[#{e.class}] #{e}" e.backtrace.each { |line| print_bad line } nil end |
#error_logfile ⇒ String
Returns Location of the error log file.
66 67 68 |
# File 'ui/cli/output.rb', line 66 def error_logfile @@error_logfile end |
#has_error_log? ⇒ Boolean
70 71 72 |
# File 'ui/cli/output.rb', line 70 def has_error_log? File.exist? error_logfile end |
#included(base) ⇒ Object
18 19 20 |
# File 'lib/arachni/ui/foo/output.rb', line 18 def included( base ) base.extend ClassMethods end |
#log_error(str = '') ⇒ Object
Logs an error message to the error log file.
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'ui/cli/output.rb', line 120 def log_error( str = '' ) return if !error_log_fd if !@@error_log_written_env @@error_log_written_env = true ['', "#{Time.now} " + ( '-' * 80 )].each do |s| error_log_fd.puts s @@error_buffer << s end begin h = {} ENV.each { |k, v| h[k] = v } = Arachni::Options.to_rpc_data if ['http']['authentication_username'] ['http']['authentication_username'] = '*****' ['http']['authentication_password'] = ['http']['authentication_username'] end = .to_yaml ['ENV:', h.to_yaml, '-' * 80, 'OPTIONS:', ].each do |s| error_log_fd.puts s @@error_buffer += s.split("\n") end rescue end error_log_fd.puts '-' * 80 @@error_buffer << '-' * 80 end t = "[#{Time.now}]" @@error_buffer << "#{t} #{str}" print_color( t, 31, str, error_log_fd, true ) end |
#mute ⇒ Object
Mutes all output messages, unless they explicitly override the mute status.
390 391 |
# File 'ui/cli/output.rb', line 390 def mute end |
#muted? ⇒ Bool
400 401 |
# File 'ui/cli/output.rb', line 400 def muted? end |
#only_positives ⇒ Object
Mutes everything but #print_ok messages.
375 376 |
# File 'ui/cli/output.rb', line 375 def only_positives end |
#only_positives? ⇒ Bool
385 386 |
# File 'ui/cli/output.rb', line 385 def only_positives? end |
#print_bad(str = '', unmute = false) ⇒ Object
Used to draw attention to a bad situation which isn't an error.
167 168 |
# File 'ui/cli/output.rb', line 167 def print_bad(*) end |
#print_debug(str = '', level = 1) ⇒ Object
Prints a debugging message.
204 205 |
# File 'ui/cli/output.rb', line 204 def print_debug(*) end |
#print_debug_backtrace(e, level = 1) ⇒ Object
Prints the backtrace of an exception as debugging messages.
275 276 |
# File 'ui/cli/output.rb', line 275 def print_debug_backtrace(*) end |
#print_debug_exception(e, level = 1) ⇒ Object
262 263 264 265 266 267 |
# File 'ui/cli/output.rb', line 262 def print_debug_exception( e, level = 1 ) return if !debug? print_debug( "[#{e.class}] #{e}", level ) print_debug_backtrace( e, level ) end |
#print_debug_level_1(str = '') ⇒ Object
57 58 |
# File 'lib/arachni/ui/foo/output.rb', line 57 def print_debug_level_1(*) end |
#print_debug_level_2(str = '') ⇒ Object
60 61 |
# File 'lib/arachni/ui/foo/output.rb', line 60 def print_debug_level_2(*) end |
#print_debug_level_3(str = '') ⇒ Object
63 64 |
# File 'lib/arachni/ui/foo/output.rb', line 63 def print_debug_level_3(*) end |
#print_debug_level_4(str = '') ⇒ Object
66 67 |
# File 'lib/arachni/ui/foo/output.rb', line 66 def print_debug_level_4(*) end |
#print_error(str = '') ⇒ Object
Prints and logs an error message.
100 101 |
# File 'ui/cli/output.rb', line 100 def print_error(*) end |
#print_error_backtrace(e) ⇒ Object
Prints the backtrace of an exception as error messages.
108 109 |
# File 'ui/cli/output.rb', line 108 def print_error_backtrace(*) end |
#print_exception(e) ⇒ Object
39 40 |
# File 'lib/arachni/ui/foo/output.rb', line 39 def print_exception(*) end |
#print_info(str = '', unmute = false) ⇒ Object
Prints an info message.
185 186 |
# File 'ui/cli/output.rb', line 185 def print_info(*) end |
#print_line(str = '', unmute = false) ⇒ Object
Prints an unclassified message.
296 297 |
# File 'ui/cli/output.rb', line 296 def print_line(*) end |
#print_ok(str = '', unmute = false) ⇒ Object
Prints a good message, something that went very very right, like the discovery of an issue.
195 196 |
# File 'ui/cli/output.rb', line 195 def print_ok(*) end |
#print_status(str = '', unmute = false) ⇒ Object
Prints a status message.
176 177 |
# File 'ui/cli/output.rb', line 176 def print_status(*) end |
#print_verbose(str = '', unmute = false) ⇒ Object
Prints a verbose message.
287 288 |
# File 'ui/cli/output.rb', line 287 def print_verbose(*) end |
#reroute_to_file(file) ⇒ Object
73 74 75 |
# File 'lib/arachni/rpc/server/output.rb', line 73 def reroute_to_file( file ) @@reroute_to_file = file end |
#reroute_to_file? ⇒ Boolean
77 78 79 |
# File 'lib/arachni/rpc/server/output.rb', line 77 def reroute_to_file? @@reroute_to_file end |
#set_error_logfile(logfile) ⇒ Object
60 61 62 |
# File 'ui/cli/output.rb', line 60 def set_error_logfile( logfile ) @@error_logfile = logfile end |
#unmute ⇒ Object
Unmutes output messages.
395 396 |
# File 'ui/cli/output.rb', line 395 def unmute end |
#verbose? ⇒ Bool
323 324 |
# File 'ui/cli/output.rb', line 323 def verbose? end |
#verbose_off ⇒ Object
Disables #print_verbose messages.
318 319 320 |
# File 'ui/cli/output.rb', line 318 def verbose_off @@verbose = false end |
#verbose_on ⇒ Object Also known as: verbose
Enables #print_verbose messages.
310 311 |
# File 'ui/cli/output.rb', line 310 def verbose_on end |