Skip to content

ShellCheck Executor

Category: Source Code Analysis Script: shellcheck.py Integration: CLI Faraday Plugin: Raw JSON Website: https://www.shellcheck.net/

Description

Runs ShellCheck static analysis on shell scripts and imports the warnings into Faraday. You can scan a single script, a directory, or a Git repository.

Prerequisites

  • shellcheck installed and available in the agent's PATH (checked with shellcheck --version)
  • git, if you scan a repository by URL
  • Read access to the scripts, either as a local path or a Git repository

Configuration

Environment Variables (Setup)

Variable Required Description
GIT_USERNAME No Username for cloning private repositories over HTTPS (default: oauth2)
GIT_TOKEN No Access token for cloning private repositories over HTTPS

Execution Arguments

Parameter Type Mandatory Description
SHELLCHECK_TARGET string No* Path to a script or directory to scan. When SHELLCHECK_GIT_URL is set, it is a subpath inside the cloned repository (e.g., scripts/).
SHELLCHECK_SEVERITY string No Minimum ShellCheck level to report: error, warning, info or style. If empty, ShellCheck uses its default (style, which reports everything).
SHELLCHECK_SHELL string No Shell dialect to check against: bash, sh, dash or ksh. If empty, ShellCheck detects it from each script's shebang.
SHELLCHECK_GIT_URL url No* Git repository to clone and scan
SHELLCHECK_GIT_REF string No Branch or tag to clone (default: the repository's default branch)

* You must set SHELLCHECK_TARGET, SHELLCHECK_GIT_URL, or both.

YAML Configuration Example

executors:
  shellcheck:
    repo_executor: shellcheck.py
    max_size: 65536
    varenvs:
      GIT_USERNAME: "<git_username>"
      GIT_TOKEN: "<git_token>"
    params:
      SHELLCHECK_TARGET:
        mandatory: false
        type: string
        base: string
      SHELLCHECK_SEVERITY:
        mandatory: false
        type: string
        base: string
      SHELLCHECK_SHELL:
        mandatory: false
        type: string
        base: string
      SHELLCHECK_GIT_URL:
        mandatory: false
        type: url
        base: string
      SHELLCHECK_GIT_REF:
        mandatory: false
        type: string
        base: string

How It Works

  1. If SHELLCHECK_GIT_URL is set, makes a shallow clone of the repository (at SHELLCHECK_GIT_REF, if given) into a temporary directory. For HTTPS URLs it authenticates with GIT_USERNAME/GIT_TOKEN.
  2. Finds the scripts to check. A single file is checked as is. In a directory, it picks up every file ending in .sh or .bash, and every file that starts with a shebang (#!).
  3. Runs shellcheck -f json on those files, adding -S for SHELLCHECK_SEVERITY and -s for SHELLCHECK_SHELL when set
  4. Creates one Faraday vulnerability per ShellCheck finding:
    • Name: the ShellCheck message
    • Severity: error becomes high, warning becomes medium, info and style become info
    • Details: the SC code, the line and column range, and the suggested fix, with a link to the ShellCheck wiki page for the code
  5. Groups the vulnerabilities into one host per scanned file and deletes the temporary clone when the run ends

Notes

  • Each scanned file appears as a Faraday host, with the file path in the host's address field and the file name as hostname.
  • If no scripts are found or ShellCheck reports nothing, nothing is imported.
  • SHELLCHECK_TARGET must point inside the cloned repository. Paths that escape it (e.g., ../) are rejected.
  • The token is hidden in the agent log if the clone fails.
  • The shared agent parameters (AGENT_CONFIG_* tags and severity filters) are not applied by this executor.