inspec / inspec

InSpec: Auditing and Testing Framework
http://inspec.io
Other
2.87k stars 681 forks source link

InSpec Reporter | HTML format append error message #4972

Closed amitchettri closed 4 years ago

amitchettri commented 4 years ago

Describe the problem

I am using InSpec Reporter to generate the patch scan report in HTML format but in the report I am getting error message as show in the snapshot. Can i get some help overcome this? image

I have used the devsec community profile from the supermarket to get this report and below is the command executed inspec supermarket exec dev-sec/linux-patch-baseline -t ssh://root:password@192.168.4.13 --reporter html:patch.htm

When i don't generate the report and get the output on screen the output is normal as below

Profile: DevSec Linux Patch Benchmark (linux-patch-baseline)
Version: 0.5.0
Target:  ssh://root@192.168.4.13:22

  ×  verify-patches: Operating system is up-to-date
     ×  Linux Update is expected to be uptodate
     expected `Linux Update.uptodate?` to return true, got false
  ×  patches: All operating system package updates are installed (480 failed)
     ×  System Package device-mapper-persistent-data version is expected to eq "0.8.5-1.el7"

     expected: "0.8.5-1.el7"
          got: "0.7.3-3.el7"

     (compared using ==)

     ×  System Package gnome-settings-daemon version is expected to eq "3.28.1-5.el7"

     expected: "3.28.1-5.el7"
          got: "3.28.1-2.el7"

     (compared using ==)

Aha! Link: https://chef.aha.io/features/SH-2529

amitchettri commented 4 years ago

for all the profile when --reporter html:name.html CLI flag is used. the generated page have below error's added on it

below is from a sample from nginx-baseline profile. And a sample snapshot from patch and linux basline profile

Failure/Error: DEFAULT_FAILURE_NOTIFIER = lambda { |failure, _opts| raise failure }

# nginx-baseline-master/controls/nginx_spec.rb:133:in `block (3 levels) in load_with_context'
nginx-baseline-master/controls/nginx_spec.rb:133:in `block (3 levels) in load_with_context'
131# Couldn't get snippet for nginx-baseline-master/controls/nginx_spec.rb
linux-basline linux-patch-baseline nginx ubuntu-patch-baseline
clintoncwolfe commented 4 years ago

I can't reproduce this error on ubuntu 18.04 and inspec 4.18.114 using dev-sec/linux-patch-baseline . What OS and inspec version are you using?

amitchettri commented 4 years ago

I can't reproduce this error on ubuntu 18.04 and inspec 4.18.114 using dev-sec/linux-patch-baseline . What OS and inspec version are you using?

Hello @clintoncwolfe,

Below are the details for the OS used and Inspec

inspec version

4.18.104

OS where inspec is installed

cat /etc/redhat-release

CentOS Linux release 7.7.1908 (Core)

clintoncwolfe commented 4 years ago

~What OS is the target?~ I'm able to reproduce the issue running 4.18.104 locally on a centos7 machine, but targeting a centos7 machine from a MacOS machine does not reproduce the issue. Curious.

Anyway, what I'd like to do is to put in a run_data filter (#5054). That will filter out the error message in plugin-type and core reporters (such as the proposed html2 reporter (#5045)) but not formatter-type reporters (such as the existing html reporter).

That's the approach I'd like to take as it avoids getting into the RSpec innards and our anticipated way forward is with the html2 reporter.

amitchettri commented 4 years ago

Target os is a mix of CentOS OS and ubuntu 18.04

clintoncwolfe commented 4 years ago

I've looked into this in further detail, and found that it only occurs on a centOS host with an RSpec formatter such as html; by the time it reaches the InSpec reporter (either core or plugin) it does not appear in the result message. So, fixing it on a run data filter isn't needed and #5054 is moot. Since our way forward for HTML reports is the html2 reporter plugin, and fixing this would require a monkeypatch into the HTML formatter (which we don't want people to use anyway), I think this is one we are not going to fix directly.

5045 should give you a clean HTML report.

amitchettri commented 4 years ago

Thanks @clintoncwolfe for the detail information, l will check on this.

kekaichinose commented 4 years ago

@amitchettri we merged in #5045 back on 2020-06-25 and released it with version 4.21.1: https://github.com/inspec/inspec/releases/tag/v4.21.1

Are you able to verify and see if it resolves your issue? Thanks!

kekaichinose commented 4 years ago

@amitchettri per my comment from back in July, I haven't seen a follow-up so assuming we're resolved here. I'm going to close the issue. Feel free to file a new issue, based on any findings you have using the html2 reporter plugin, and we can go from there. Thanks!