# 6. Generating Results

InSpec allows you to output your test results to one or more reporters. You can configure the reporter(s) using either the --json-config option or the --reporter option. While you can configure multiple reporters to write to different files, only one reporter can output to the screen(stdout).

inspec exec /root/my_nginx -t docker://CONTAINER_NAME --reporter cli json:baseline_output.json
1

# 6.1. Syntax

You can specify one or more reporters using the --reporter cli flag. You can also specify a output by appending a path separated by a colon.

Output json to screen.

inspec exec /root/my_nginx --reporter json
1

or

inspec exec /root/my_nginx --reporter json:-
1

Output yaml to screen

inspec exec /root/my_nginx --reporter yaml
1

or

inspec exec /root/my_nginx --reporter yaml:-
1

Output cli to screen and write json to a file.

inspec exec /root/my_nginx --reporter cli json:/tmp/output.json
1

Output nothing to screen and write junit and html to a file.

inspec exec /root/my_nginx --reporter junit:/tmp/junit.xml html:www/index.html
1

Output json to screen and write to a junit file.

inspec exec /root/my_nginx --reporter json junit:/tmp/junit.xml | tee out.json
1

If you wish to pass the profiles directly after specifying the reporters you will need to use the end of options flag --.

inspec exec --reporter json junit:/tmp/junit.xml -- profile1 profile2
1

Output cli to screen and write json to a file.

# InSpec config.json file

InSpec also let's you capture all these in a reuaable configuration file:

{
  "reporter": {
    "cli": {
      "stdout": true
    },
    "json": {
      "file": "/tmp/output.json",
      "stdout": false
    }
  }
}
1
2
3
4
5
6
7
8
9
10
11

You can read more about this at https://docs.chef.io/inspec/config/ (opens new window)

# 6.2. Supported Reporters

The following are the current supported reporters:

  • cli
  • json
  • json-min
  • yaml
  • documentation
  • junit
  • progress
  • json-rspec
  • html

You can read more here: https://www.inspec.io/docs/reference/reporters/ (opens new window)

# 6.3. Putting it all together

The following command will run the nginx baseline profile from github and use the reporter to output a json, you will need this for the next step loading it into heimdall:

inspec exec https://github.com/dev-sec/nginx-baseline -t ssh://TARGET_USERNAME:TARGET_PASSWORD@TARGET_IP --reporter cli json:baseline_output.json
1