Module: InspecPlugins::FlexReporter::ErbHelpers
- Included in:
- Reporter
- Defined in:
- lib/inspec-reporter-flex/mixin/erb_helpers.rb
Instance Method Summary collapse
-
#control_passed?(control) ⇒ Boolean
Return if all results of a control have passed/skipped/waived.
-
#impact_to_severity(inspec_severity) ⇒ String
Map InSpec severity (0..1) to CVSS scale (none-low-medium-high-critical).
-
#inspec_resource ⇒ Inspec::Backend
Allow access to all InSpec resources from the report.
-
#os ⇒ Class
Return InSpec OS resource results.
-
#remote_command(cmd) ⇒ Train::Extras::CommandResult
Execute a remote command.
-
#remote_file_content(remote_file) ⇒ String
Retrieve remote file contents.
-
#scan_time ⇒ DateTime
Return latest start time of the scan.
-
#status_to_pass(inspec_status) ⇒ Strint
Map InSpec status to cleartext.
-
#sys_info ⇒ Class
Return InSpec SysInfo resource results.
Instance Method Details
#control_passed?(control) ⇒ Boolean
Return if all results of a control have passed/skipped/waived.
53 54 55 |
# File 'lib/inspec-reporter-flex/mixin/erb_helpers.rb', line 53 def control_passed?(control) control[:results].any? { |result| result[:status] == "failed" } end |
#impact_to_severity(inspec_severity) ⇒ String
Map InSpec severity (0..1) to CVSS scale (none-low-medium-high-critical)
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/inspec-reporter-flex/mixin/erb_helpers.rb', line 75 def impact_to_severity(inspec_severity) case inspec_severity when 0.0...0.1 "none" when 0.1...0.4 "low" when 0.4...0.7 "medium" when 0.7...0.9 "high" when 0.9..1.0 "critical" else "unknown" end end |
#inspec_resource ⇒ Inspec::Backend
Allow access to all InSpec resources from the report.
29 30 31 |
# File 'lib/inspec-reporter-flex/mixin/erb_helpers.rb', line 29 def inspec_resource runner.backend end |
#os ⇒ Class
Return InSpec OS resource results.
37 38 39 |
# File 'lib/inspec-reporter-flex/mixin/erb_helpers.rb', line 37 def os runner.backend.os end |
#remote_command(cmd) ⇒ Train::Extras::CommandResult
Execute a remote command.
14 15 16 |
# File 'lib/inspec-reporter-flex/mixin/erb_helpers.rb', line 14 def remote_command(cmd) runner.backend.backend.run_command(cmd) end |
#remote_file_content(remote_file) ⇒ String
Retrieve remote file contents.
22 23 24 |
# File 'lib/inspec-reporter-flex/mixin/erb_helpers.rb', line 22 def remote_file_content(remote_file) runner.backend.backend.file(remote_file).content end |
#scan_time ⇒ DateTime
Return latest start time of the scan
6 7 8 |
# File 'lib/inspec-reporter-flex/mixin/erb_helpers.rb', line 6 def scan_time DateTime.strptime(report[:profiles].last[:controls].last[:results].last[:start_time]) end |
#status_to_pass(inspec_status) ⇒ Strint
Map InSpec status to cleartext
61 62 63 64 65 66 67 68 |
# File 'lib/inspec-reporter-flex/mixin/erb_helpers.rb', line 61 def status_to_pass(inspec_status) case inspec_status when "passed", "skipped", "waived" "ok" else "not ok" end end |
#sys_info ⇒ Class
Return InSpec SysInfo resource results.
45 46 47 |
# File 'lib/inspec-reporter-flex/mixin/erb_helpers.rb', line 45 def sys_info runner.backend.sys_info end |