Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InSpec verifier in Test Kitchen does not support the new reporter output #164

Closed
burtlo opened this issue Feb 19, 2018 · 15 comments
Closed
Labels
Type: Bug Doesn't work as expected.

Comments

@burtlo
Copy link

burtlo commented Feb 19, 2018

Description

I started working on this learn chef rally module with pre-release of InSpec 2.0.x. In this module you use test kitchen with InSpec and kitchen-dokken.

At one point the module you demonstrate how you can set the format to JSON. I did that and execute:

-----> Starting Kitchen (v1.19.2)
-----> Verifying <default-ubuntu-1604>...
[DEPRECATED] The option --format is being is being deprecated and will be removed in inspec 3.0. Please use --reporter
[DEPRECATED] The option 'output' is being is being deprecated and will be removed in inspec 3.0. Please use --reporter name:path
[2018-02-19T00:38:50-06:00] WARN: URL target https://github.com/dev-sec/linux-baseline transformed to https://github.com/dev-sec/linux-baseline/archive/master.tar.gz. Consider using the git fetcher
       Loaded linux-baseline
       Finished verifying <default-ubuntu-1604> (0m2.64s).
-----> Kitchen is finished. (0m4.33s)

I see the deprecations so I switch the verifier from format to reporter.

      inspec_tests:
        - name: dev-sec/linux-baseline
      controls:
        - package-08
      format: json
      output: ./linux-baseline-results.json

I run verify again and see no file is generated.

I re-read the deprecation and and update the verifier to the following:

      inspec_tests:
        - name: dev-sec/linux-baseline
      controls:
        - package-08
      reporter: json:./linux-baseline-results.json

I run verify again and see no file is generated.

InSpec and Platform Version

$ inspec version
2.0.11

Commit: 8416c07a

@chris-rock
Copy link
Collaborator

This work is scheduled for this week @jquick

@chris-rock chris-rock added the bug label Feb 19, 2018
@jquick
Copy link
Contributor

jquick commented Feb 19, 2018

The old format should work fine but we should still update it via kitchen-inspec so we don't have deprecation.

verifier:
  name: inspec
  format: json
  output: json.out

@aaronlippold
Copy link

When the inspec_tests has two profiles - the old format is producing two json files but with no data. I will follow up with more info but give it a try on your side, with was with 1.51.x and 2.0.11 on my side.

@aaronlippold
Copy link

It seems to dump the json output to the screen as well.

@aaronlippold
Copy link

If possible when I load more than one profile, if I only have one output file for my reporter I would like to condense the output to that one file.

@jquick
Copy link
Contributor

jquick commented Feb 21, 2018

The new stable 2.0.17 should have all the fixes for this in it. The two profiles getting exported separately is news to me though. Ill have to take a look.

@aaronlippold
Copy link

Ok. Thanks. Let me know

@jquick
Copy link
Contributor

jquick commented Feb 22, 2018

I have confirmed this is working as expected in 1.51.21 and 2.0.17

@tolland
Copy link

tolland commented Feb 24, 2018

Seems to be ignoring the output option, selecting the right formatter, but forcing stdout. This is quick work-around that gets junit and json working;
limepepper/inspec@12208de

@jquick
Copy link
Contributor

jquick commented Feb 24, 2018

Thanks @tolland. Are you on version >= 1.51.21? A fix like yours has been added to more recent versions:
https://github.com/chef/inspec/blob/master/lib/inspec/base_cli.rb#L103

@tolland
Copy link

tolland commented Feb 24, 2018

Ah I missed that.. yeah that fix is good!

@aaronlippold
Copy link

Should this issue be closed?

@jquick
Copy link
Contributor

jquick commented Mar 9, 2018

Yes, closing.

@jquick jquick closed this as completed Mar 9, 2018
@kabakakao
Copy link

For me it is not working as expected:

    verifier:
      name: inspec
      reporter: json:./linux-baseline-results.json

This will be ignored and I got the cli output.

bundle exec inspec version
2.2.64

@tas50 tas50 added Type: Bug Doesn't work as expected. and removed bug labels Jan 14, 2019
@stsully
Copy link

stsully commented Sep 24, 2019

For me it is not working as expected:

    verifier:
      name: inspec
      reporter: json:./linux-baseline-results.json

I think kitchen is expecting it to be an array, so try to configure it like this:

    verifier:
      name: inspec
      reporter: 
        - json:./linux-baseline-results.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Doesn't work as expected.
Projects
None yet
Development

No branches or pull requests

8 participants