Spectral supports a wide array of reporting outputs. From simple console reports to HTML to JUnit reports.

πŸ“˜

You actually need none of the outputs when you get your Spectral account. Your results and metadata will appear in your Spectral account UI. You usually use these when you want more power, or just to interactively investigate things.

If you have a reporting format you'd want to see added, tell us about it.


Stylish

The Stylish reporter is the default Spectral reporter. It can output a few different "styles" of reports that we've grown accustomed to: CLI, HTML, CSV, JSON.

If you want cool CLI-based reports with colors and to-the-point messaging, you don't need to do anything special to configure it, it's enabled by default with an empty stylish block:

reporter:
    outputs:
        stylish: {}  # produce CLI based reports

There are a few additional kinds of reports in this reporter below.

πŸ‘

Note that we are sunsetting some of these reporters, as the new Spectral account UI cover them in a better way. The CLI and CSV outputs will always exist.

HTML

To configure Spectral to output HTML reports for infosec reviews, secops reviews or your periodical security email sendouts:

reporter:
    outputs:
        stylish: { html: "output.html" }  # produce HTML reports

CSV

If you want results in CSV format, to be sliced and diced later, or you have your own report generation pipeline that you only need to feed some CSV into, here's how to configure the stylish reporter to output CSV:

reporter:
    outputs:
        stylish: { csv: "output.csv" }  # produce CSV reports

JSON

If you want results in JSON format:

reporter:
    outputs:
        stylish: { json: "output.json" }  # produce JSON reports

TABLE

If you want results in a table format (only available to the terminal output, not as a file):

reporter:
    outputs:
        stylish: { table: "" }  # produce table output

JSON

The JSON reporter is mainly use for interoperability. Build a script that runs Spectral and pushes results some where else? Use the JSON reporter.

Configure in spectral.yaml:

reporter:
    outputs:
        json: {}

HTML

The HTML reporter lets you render a visually rich Spectral scan report. You can convert it to PDF with simple tools.

Configure in spectral.yaml:

reporter:
    outputs:
        html: {}

JUNIT

The JUnit reporter is great for interop with CI/CD products that take a junit-xml test result format (probably most if not all of them).

Using this format, a Spectral scan is similar to a test scan. When there are real findings, Spectral will generate a failing test that you can inspect in your CI dashboard like any other test.

Here's how to configure in your spectral.yaml:

reporter:
    outputs:
        junit: {}

This will output the XML results in junit-out. To pick it up, for example with Circle CI, make sure to point your CI to this folder:

version: 2
jobs:
  build:
    docker:
      - image: circleci/node:latest
    steps:
      - checkout
      - run:  $HOME/.spectral/spectral run
      - store_test_results:
          path: ./junit-out/

Log, JSON

The log reporter is a standard looking logger based output with timestamps, logfmt fields and is perfect for parsing or pushing to a log indexing services such as Elastic.

You can switch to JSON logging as well (see flag).

Configure in spectral.yaml:

reporter:
    outputs:
        log: {}
        # log: { json: true }    # use JSON logging