Class: WPScan::Formatter::Cli

Inherits:
Base
  • Object
show all
Defined in:
app/formatters/cli.rb

Overview

CLI Formatter

Direct Known Subclasses

CliNoColour

Constant Summary

Constants inherited from Base

Base::ERB_SUPPORTS_KVARGS

Instance Attribute Summary

Attributes inherited from Base

#controller_name

Instance Method Summary collapse

Methods inherited from Base

#base_format, #beautify, #format, #formats, #initialize, #output, #render, #template_vars, #user_interaction?, #view_path, #views_directories

Constructor Details

This class inherits a constructor from WPScan::Formatter::Base

Instance Method Details

#amber(text) ⇒ String

Parameters:

  • text (String)

Returns:

  • (String)


61
62
63
# File 'app/formatters/cli.rb', line 61

def amber(text)
  colorize(text, 33)
end

#bar_clearObject

ANSI sequence to clear the current line and return to column 0. Emitted at the start of each streamed enumeration finding so the ruby-progressbar line (which redraws via r and leaves its previous render visible when interleaved with foreign output) gets wiped before the finding prints. No-op on non-TTY stdout so file/pipe output stays clean.



17
18
19
# File 'app/formatters/cli.rb', line 17

def bar_clear
  $stdout.tty? ? "\e[2K\r" : ''
end

#blue(text) ⇒ String

Parameters:

  • text (String)

Returns:

  • (String)


67
68
69
# File 'app/formatters/cli.rb', line 67

def blue(text)
  colorize(text, 34)
end

#bold(text) ⇒ String

Parameters:

  • text (String)

Returns:

  • (String)


43
44
45
# File 'app/formatters/cli.rb', line 43

def bold(text)
  colorize(text, 1)
end

#colorize(text, color_code) ⇒ String

Parameters:

  • text (String)
  • color_code (Integer)

Returns:

  • (String)


74
75
76
# File 'app/formatters/cli.rb', line 74

def colorize(text, color_code)
  "\e[#{color_code}m#{text}\e[0m"
end

#critical_iconString

Returns:

  • (String)


37
38
39
# File 'app/formatters/cli.rb', line 37

def critical_icon
  red('[!]')
end

#green(text) ⇒ String

Parameters:

  • text (String)

Returns:

  • (String)


55
56
57
# File 'app/formatters/cli.rb', line 55

def green(text)
  colorize(text, 32)
end

#info_iconString

Returns:

  • (String)


22
23
24
# File 'app/formatters/cli.rb', line 22

def info_icon
  green('[+]')
end

#notice_iconString

Returns:

  • (String)


27
28
29
# File 'app/formatters/cli.rb', line 27

def notice_icon
  blue('[i]')
end

#red(text) ⇒ String

Parameters:

  • text (String)

Returns:

  • (String)


49
50
51
# File 'app/formatters/cli.rb', line 49

def red(text)
  colorize(text, 31)
end

#streams?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'app/formatters/cli.rb', line 7

def streams?
  true
end

#warning_iconString

Returns:

  • (String)


32
33
34
# File 'app/formatters/cli.rb', line 32

def warning_icon
  amber('[!]')
end