Class: Abide::CLI::ComplyReportCommand
- Inherits:
-
AbideCommand
- Object
- CmdParse::Command
- AbideCommand
- Abide::CLI::ComplyReportCommand
- Defined in:
- lib/abide_dev_utils/cli/comply.rb
Constant Summary collapse
- CMD_NAME =
'report'
- CMD_SHORT =
'Generates a yaml report of Puppet Comply scan results'
- CMD_LONG =
<<~LONGCMD Generates a yaml file that shows the scan results of all nodes in Puppet Comply. This command utilizes Selenium WebDriver and the Google Chrome browser to automate clicking through the Comply UI and building a report. In order to use this command, you MUST have Google Chrome installed and you MUST install the chromedriver binary. More info and instructions can be found here: https://www.selenium.dev/documentation/en/getting_started_with_webdriver/. LONGCMD
- CMD_COMPLY_URL =
'The URL (including https://) of Puppet Comply'
- CMD_COMPLY_PASSWORD =
'The password for Puppet Comply'
- OPT_TIMEOUT_DESC =
<<~EOTO The number of seconds you would like requests to wait before timing out. Defaults to 10 seconds. EOTO
- OPT_STATUS_DESC =
<<~EODESC A comma-separated list of check statuses to ONLY include in the report. Valid statuses are: pass, fail, error, notapplicable, notchecked, unknown, informational EODESC
- OPT_IGNORE_NODES =
<<~EOIGN A comma-separated list of node certnames to ignore building reports for. This options is mutually exclusive with --only and, if both are set, --only will take precedence over this option. EOIGN
- OPT_ONLY_NODES =
<<~EOONLY A comma-separated list of node certnames to ONLY build reports for. No other nodes will have reports built for them except the ones specified. This option is mutually exclusive with --ignore and, if both are set, this options will take precedence over --ignore. EOONLY
Constants included from AbideDevUtils::Config
AbideDevUtils::Config::DEFAULT_PATH
Instance Method Summary collapse
- #execute(comply_url = nil, comply_password = nil) ⇒ Object
- #help_arguments ⇒ Object
-
#initialize ⇒ ComplyReportCommand
constructor
A new instance of ComplyReportCommand.
Methods inherited from AbideCommand
Methods included from AbideDevUtils::Config
config_section, #config_section, fetch, #fetch, #to_h, to_h
Constructor Details
#initialize ⇒ ComplyReportCommand
Returns a new instance of ComplyReportCommand.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/abide_dev_utils/cli/comply.rb', line 51 def initialize super(CMD_NAME, CMD_SHORT, CMD_LONG, takes_commands: false) argument_desc(COMPLY_URL: CMD_COMPLY_URL, COMPLY_PASSWORD: CMD_COMPLY_PASSWORD) .on('-o [FILE]', '--out-file [FILE]', 'Path to save the report') { |f| @data[:file] = f } .on('-u [USERNAME]', '--username [USERNAME]', 'The username for Comply (defaults to comply)') do |u| @data[:username] = u end .on('-t [SECONDS]', '--timeout [SECONDS]', OPT_TIMEOUT_DESC) do |t| @data[:timeout] = t end .on('-s [X,Y,Z]', '--status [X,Y,Z]', %w[pass fail error notapplicable notchecked unknown informational], Array, OPT_STATUS_DESC) do |s| s&.map! { |i| i == 'notchecked' ? 'not checked' : i } @data[:status] = s end .on('--only [X,Y,Z]', Array, OPT_ONLY_NODES) do |o| @data[:onlylist] = o end .on('--ignore [X,Y,Z]', Array, OPT_IGNORE_NODES) do |i| @data[:ignorelist] = i end .on('--page-source-on-error', 'Dump page source to file on error') do @data[:page_source_on_error] = true end end |
Instance Method Details
#execute(comply_url = nil, comply_password = nil) ⇒ Object
88 89 90 91 92 93 94 95 96 |
# File 'lib/abide_dev_utils/cli/comply.rb', line 88 def execute(comply_url = nil, comply_password = nil) Abide::CLI::VALIDATE.filesystem_path(`command -v chromedriver`.strip) conf = config_section('comply') comply_url = conf.fetch(:url) if comply_url.nil? comply_password = comply_password.nil? ? conf.fetch(:password, Abide::CLI::PROMPT.password) : comply_password report = AbideDevUtils::Comply.build_report(comply_url, comply_password, conf, **@data) outfile = @data.fetch(:file, nil).nil? ? conf.fetch(:report_path, 'comply_scan_report.yaml') : @data[:file] Abide::CLI::OUTPUT.yaml(report, file: outfile) end |
#help_arguments ⇒ Object
79 80 81 82 83 84 85 86 |
# File 'lib/abide_dev_utils/cli/comply.rb', line 79 def help_arguments <<~ARGHELP Arguments: COMPLY_URL #{CMD_COMPLY_URL} COMPLY_PASSWORD #{CMD_COMPLY_PASSWORD} ARGHELP end |