Class: CMSScanner::Scan
- Inherits:
-
Object
- Object
- CMSScanner::Scan
- Defined in:
- lib/cms_scanner.rb
Overview
Scan
Instance Attribute Summary collapse
-
#run_error ⇒ Object
readonly
Returns the value of attribute run_error.
Instance Method Summary collapse
- #controllers ⇒ Controllers
- #datastore ⇒ Hash
-
#exit_hook ⇒ Object
Hook to be able to have an exit code returned depending on the findings / errors.
-
#formatter ⇒ Object
Used for convenience.
-
#initialize {|_self| ... } ⇒ Scan
constructor
A new instance of Scan.
- #run ⇒ Object
-
#run_error_exit_code ⇒ Integer
The exit code related to the run_error.
Constructor Details
Instance Attribute Details
#run_error ⇒ Object (readonly)
Returns the value of attribute run_error.
85 86 87 |
# File 'lib/cms_scanner.rb', line 85 def run_error @run_error end |
Instance Method Details
#controllers ⇒ Controllers
96 97 98 |
# File 'lib/cms_scanner.rb', line 96 def controllers @controllers ||= NS::Controllers.new end |
#datastore ⇒ Hash
126 127 128 |
# File 'lib/cms_scanner.rb', line 126 def datastore controllers.first.datastore end |
#exit_hook ⇒ Object
Hook to be able to have an exit code returned depending on the findings / errors
132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/cms_scanner.rb', line 132 def exit_hook at_exit do exit(run_error_exit_code) if run_error controller = controllers.first # The parsed_option[:url] must be checked to avoid raising erros when only -h/-v are given exit(NS::ExitCode::VULNERABLE) if controller.[:url] && controller.target.vulnerable? exit(NS::ExitCode::OK) end end |
#formatter ⇒ Object
Used for convenience
121 122 123 |
# File 'lib/cms_scanner.rb', line 121 def formatter controllers.first.formatter end |
#run ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/cms_scanner.rb', line 100 def run controllers.run rescue OptParseValidator::NoRequiredOption => e @run_error = e formatter.output('@usage', msg: e.) rescue => e @run_error = e formatter.output('@scan_aborted', reason: e., trace: e.backtrace, verbose: controllers.first.[:verbose]) ensure Browser.instance.hydra.abort formatter.beautify end |
#run_error_exit_code ⇒ Integer
Returns The exit code related to the run_error.
145 146 147 148 149 150 151 152 |
# File 'lib/cms_scanner.rb', line 145 def run_error_exit_code return NS::ExitCode::CLI_OPTION_ERROR if run_error.is_a?(OptParseValidator::Error) || run_error.is_a?(OptionParser::ParseError) return NS::ExitCode::INTERRUPTED if run_error.is_a?(Interrupt) NS::ExitCode::ERROR end |