23 releases

0.5.0 Jul 8, 2024
0.4.2 Sep 7, 2023
0.4.1 Jul 30, 2023
0.3.7 Feb 28, 2023
0.2.15 Jul 6, 2021

#97 in Command line utilities

Download history 264/week @ 2024-04-01 163/week @ 2024-04-08 399/week @ 2024-04-15 487/week @ 2024-04-22 613/week @ 2024-04-29 480/week @ 2024-05-06 378/week @ 2024-05-13 561/week @ 2024-05-20 754/week @ 2024-05-27 610/week @ 2024-06-03 779/week @ 2024-06-10 545/week @ 2024-06-17 913/week @ 2024-06-24 508/week @ 2024-07-01 450/week @ 2024-07-08 739/week @ 2024-07-15

2,656 downloads per month

MIT license

58KB
1K SLoC

Workflow Status

shellcheck-sarif

This crate provides a command line tool to convert shellcheck diagnostic output into SARIF.

The latest documentation can be found here.

shellcheck is a popular linter / static analysis tool for shell scripts. More information can be found on the official repository: https://github.com/koalaman/shellcheck

SARIF or the Static Analysis Results Interchange Format is an industry standard format for the output of static analysis tools. More information can be found on the official website: https://sarifweb.azurewebsites.net/.

Installation

shellcheck-sarif may be installed via cargo

cargo install shellcheck-sarif

via cargo-binstall

cargo binstall shellcheck-sarif

or downloaded directly from Github Releases

# make sure to adjust the target and version (you may also want to pin to a specific version)
curl -sSL https://github.com/psastras/sarif-rs/releases/download/shellcheck-sarif-latest/shellcheck-sarif-x86_64-unknown-linux-gnu -o shellcheck-sarif

Usage

For most cases, simply run shellcheck with json output and pipe the results into shellcheck-sarif.

Example

shellcheck -f json shellscript.sh | shellcheck-sarif

If you are using Github Actions, SARIF is useful for integrating with Github Advanced Security (GHAS), which can show code alerts in the "Security" tab of your repository.

After uploading shellcheck-sarif output to Github, shellcheck diagnostics are available in GHAS.

Example

on:
  workflow_run:
    workflows: ["main"]
    branches: [main]
    types: [completed]

name: sarif

jobs:
  upload-sarif:
    runs-on: ubuntu-latest
    if: ${{ github.ref == 'refs/heads/main' }}
    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
      - uses: Swatinem/rust-cache@v1
      - run: cargo install shellcheck-sarif sarif-fmt
      - run: shellcheck -f json shellscript.sh | shellcheck-sarif | tee
          results.sarif | sarif-fmt
      - name: Upload SARIF file
        uses: github/codeql-action/upload-sarif@v1
        with:
          sarif_file: results.sarif

License: MIT

Dependencies

~2.2–3.5MB
~63K SLoC