Output Formats

You can view Code Security output in various formats.

CLI

For CLI-based output:

Copy

.spectral/spectral.yaml

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

HTML

For the output in the HTML format for infosec reviews, secops reviews or sending your periodical security email:

Copy

.spectral/spectral.yaml

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

CSV

For the CSV output, the configuration is for each repository, which means that after you run spectral init the configuration file .spectral/spectral.yaml is added to that repository.

Note - You can have one configuration file for multiple repositories and point with the -c flag to the global config file's location.

For output in the CSV format:

Copy

.spectral/spectral.yaml

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

JSON

For output in the JSONClosed JavaScript Object Notation. A lightweight data interchange format. format:

Copy

.spectral/spectral.yaml

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

Log

You can use the log format (with timestamps and logfmt fields) to parse or push to log indexing services, such as Elastic.

In addition, you can switch to JSON log.

Copy

.spectral/spectral.yaml

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

Junit (junit-xml)

The Junit format is suitable for interop with CI/CD products that accept junit-xml test result format.

Code Security generates a failing test that you can inspect in your CI dashboard like any other test.

Copy

.spectral/spectral.yaml

reporter:
    outputs:
        junit: {}

The XML results are generated in junit-out. To use, for example with CircleCI, point your CI to this folder:

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