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¶
shellcheckinstalled and available in the agent'sPATH(checked withshellcheck --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¶
- If
SHELLCHECK_GIT_URLis set, makes a shallow clone of the repository (atSHELLCHECK_GIT_REF, if given) into a temporary directory. For HTTPS URLs it authenticates withGIT_USERNAME/GIT_TOKEN. - Finds the scripts to check. A single file is checked as is. In a directory, it picks up every file ending in
.shor.bash, and every file that starts with a shebang (#!). - Runs
shellcheck -f jsonon those files, adding-SforSHELLCHECK_SEVERITYand-sforSHELLCHECK_SHELLwhen set - Creates one Faraday vulnerability per ShellCheck finding:
- Name: the ShellCheck message
- Severity:
errorbecomes high,warningbecomes medium,infoandstylebecome info - Details: the
SCcode, the line and column range, and the suggested fix, with a link to the ShellCheck wiki page for the code
- 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_TARGETmust 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.