Install | Policies | How to use | Configuration
GitHub Actions linter for security best practices.
$ ghalint run
ERRO[0000] read a workflow file error="parse a workflow file as YAML: yaml: line 10: could not find expected ':'" program=ghalint version= workflow_file_path=.github/workflows/release.yaml
ERRO[0000] github.token should not be set to workflow's env env_name=GITHUB_TOKEN policy_name=workflow_secrets program=ghalint version= workflow_file_path=.github/workflows/test.yaml
ERRO[0000] secret should not be set to workflow's env env_name=DATADOG_API_KEY policy_name=workflow_secrets program=ghalint version= workflow_file_path=.github/workflows/test.yaml
ghalint is a command line tool to check GitHub Actions Workflows and action.yaml for security policy compliance.
lintnet is a general purpose linter powered by Jsonnet. We've ported ghalint to the lintnet module, so you can migrate ghalint to lintnet!
permissionsread-all permission should not be usedwrite-all permission should not be usedsecrets: inherit should not be usedlatestpersist-credentials should be falseshell is required if run is setpersist-credentials should be falseRun the command ghalint run on the repository root directory.
ghalint run
Then ghalint validates workflow files ^\.github/workflows/.*\.ya?ml$.
Run the command ghalint run-action.
ghalint run-action
The alias act is available.
ghalint act
Then ghalint validates action files ^([^/]+/){0,3}action\.ya?ml$ on the current directory.
You can also specify file paths.
ghalint act foo/action.yaml bar/action.yml
Configuration file path: ^(\.|\.github/)?ghalint\.ya?ml$
You can specify the configuration file with the command line option -config (-c) or the environment variable GHALINT_CONFIG.
ghalint -c foo.yaml run
If you look for a CLI tool to validate configuration with JSON Schema, ajv-cli is useful.
ajv --spec=draft2020 -s json-schema/ghalint.json -d ghalint.yaml
Version: main
# yaml-language-server: $schema=https://raw.githubusercontent.com/suzuki-shunsuke/ghalint/main/json-schema/ghalint.json
Or pinning version:
# yaml-language-server: $schema=https://raw.githubusercontent.com/suzuki-shunsuke/ghalint/v1.2.1/json-schema/ghalint.json
You can disable the following policies.
e.g.
excludes:
- policy_name: deny_inherit_secrets
workflow_file_path: .github/workflows/actionlint.yaml
job_name: actionlint
- policy_name: job_secrets
workflow_file_path: .github/workflows/actionlint.yaml
job_name: actionlint
- policy_name: action_ref_should_be_full_length_commit_sha
action_name: slsa-framework/slsa-github-generator
- policy_name: github_app_should_limit_repositories
workflow_file_path: .github/workflows/test.yaml
job_name: test
step_id: create_token
GHALINT_CONFIG: Configuration file pathGHALINT_LOG_LEVEL: Log level One of error, warn, info (default), debugGHALINT_LOG_COLOR: Configure log color. One of auto (default), always, and never.💡 If you want to enable log color in GitHub Actions, please try GHALINT_LOG_COLOR=always
env:
GHALINT_LOG_COLOR: always
AS IS
TO BE
ghalint reads GitHub Actions Workflows ^\.github/workflows/.*\.ya?ml$ and validates them.
If there are violatation ghalint outputs error logs and fails.
If there is no violation ghalint succeeds.
[!WARNING] These features are experimental, meaning they are unstable and may be changed or removed at minor or patch versions.
$ ghalint exp validate-input
ERRO[0000] invalid input key action=suzuki-shunsuke/actionlint-action@c8d3c0dcc9152f1d1c7d4a38cbf4953c3a55953d input_key=actionlint_option job_key=actionlint program=ghalint required_inputs= valid_inputs="sparse-checkout, actionlint_options" version=v1.0.0-local workflow_file_path=.github/workflows/actionlint.yaml
ghalint exp validate-input command validates inputs of actions and reusable workflows.
It fails if required inputs aren't given or unknown inputs are passed.
[!WARNING] Actions using
required: truewill not automatically return an error if the input is not specified. This means ifghalint exp validate-inputfails as required inputs aren't given, the action may work without any problem. Nowghalint exp validate-inputcan't ignore those errors. Ideally, actions should be fixed.
By default, the following files are validated.
.github/workflows/*.yaml
.github/workflows/*.yml
action.yaml
action.yml
*/action.yaml
*/action.yml
*/*/action.yaml
*/*/action.yml
*/*/*/action.yaml
*/*/*/action.yml
This command uses a GitHub access token with contents:read permission to download actions and reusable workflows.
It downloads them into XDG_DATA_HOME/ghalint.
You can pass a GitHub access token by environment variables GITHUB_TOKEN or GHALINT_GITHUB_TOKEN.
You can also manage it by secret stores such as GNOME Keyring, Windows Credential Manager, and macOS Keychain.
ghalint exp token set [-stdin]
ghalint exp token rm # Remove a token from secret store
1,207 commits
276 commits
182 commits
2 commits
Go
99.3%
Install | Policies | How to use | Configuration
GitHub Actions linter for security best practices.
$ ghalint run
ERRO[0000] read a workflow file error="parse a workflow file as YAML: yaml: line 10: could not find expected ':'" program=ghalint version= workflow_file_path=.github/workflows/release.yaml
ERRO[0000] github.token should not be set to workflow's env env_name=GITHUB_TOKEN policy_name=workflow_secrets program=ghalint version= workflow_file_path=.github/workflows/test.yaml
ERRO[0000] secret should not be set to workflow's env env_name=DATADOG_API_KEY policy_name=workflow_secrets program=ghalint version= workflow_file_path=.github/workflows/test.yaml
ghalint is a command line tool to check GitHub Actions Workflows and action.yaml for security policy compliance.
lintnet is a general purpose linter powered by Jsonnet. We've ported ghalint to the lintnet module, so you can migrate ghalint to lintnet!
permissionsread-all permission should not be usedwrite-all permission should not be usedsecrets: inherit should not be usedlatestpersist-credentials should be falseshell is required if run is setpersist-credentials should be falseRun the command ghalint run on the repository root directory.
ghalint run
Then ghalint validates workflow files ^\.github/workflows/.*\.ya?ml$.
Run the command ghalint run-action.
ghalint run-action
The alias act is available.
ghalint act
Then ghalint validates action files ^([^/]+/){0,3}action\.ya?ml$ on the current directory.
You can also specify file paths.
ghalint act foo/action.yaml bar/action.yml
Configuration file path: ^(\.|\.github/)?ghalint\.ya?ml$
You can specify the configuration file with the command line option -config (-c) or the environment variable GHALINT_CONFIG.
ghalint -c foo.yaml run
If you look for a CLI tool to validate configuration with JSON Schema, ajv-cli is useful.
ajv --spec=draft2020 -s json-schema/ghalint.json -d ghalint.yaml
Version: main
# yaml-language-server: $schema=https://raw.githubusercontent.com/suzuki-shunsuke/ghalint/main/json-schema/ghalint.json
Or pinning version:
# yaml-language-server: $schema=https://raw.githubusercontent.com/suzuki-shunsuke/ghalint/v1.2.1/json-schema/ghalint.json
You can disable the following policies.
e.g.
excludes:
- policy_name: deny_inherit_secrets
workflow_file_path: .github/workflows/actionlint.yaml
job_name: actionlint
- policy_name: job_secrets
workflow_file_path: .github/workflows/actionlint.yaml
job_name: actionlint
- policy_name: action_ref_should_be_full_length_commit_sha
action_name: slsa-framework/slsa-github-generator
- policy_name: github_app_should_limit_repositories
workflow_file_path: .github/workflows/test.yaml
job_name: test
step_id: create_token
GHALINT_CONFIG: Configuration file pathGHALINT_LOG_LEVEL: Log level One of error, warn, info (default), debugGHALINT_LOG_COLOR: Configure log color. One of auto (default), always, and never.💡 If you want to enable log color in GitHub Actions, please try GHALINT_LOG_COLOR=always
env:
GHALINT_LOG_COLOR: always
AS IS
TO BE
ghalint reads GitHub Actions Workflows ^\.github/workflows/.*\.ya?ml$ and validates them.
If there are violatation ghalint outputs error logs and fails.
If there is no violation ghalint succeeds.
[!WARNING] These features are experimental, meaning they are unstable and may be changed or removed at minor or patch versions.
$ ghalint exp validate-input
ERRO[0000] invalid input key action=suzuki-shunsuke/actionlint-action@c8d3c0dcc9152f1d1c7d4a38cbf4953c3a55953d input_key=actionlint_option job_key=actionlint program=ghalint required_inputs= valid_inputs="sparse-checkout, actionlint_options" version=v1.0.0-local workflow_file_path=.github/workflows/actionlint.yaml
ghalint exp validate-input command validates inputs of actions and reusable workflows.
It fails if required inputs aren't given or unknown inputs are passed.
[!WARNING] Actions using
required: truewill not automatically return an error if the input is not specified. This means ifghalint exp validate-inputfails as required inputs aren't given, the action may work without any problem. Nowghalint exp validate-inputcan't ignore those errors. Ideally, actions should be fixed.
By default, the following files are validated.
.github/workflows/*.yaml
.github/workflows/*.yml
action.yaml
action.yml
*/action.yaml
*/action.yml
*/*/action.yaml
*/*/action.yml
*/*/*/action.yaml
*/*/*/action.yml
This command uses a GitHub access token with contents:read permission to download actions and reusable workflows.
It downloads them into XDG_DATA_HOME/ghalint.
You can pass a GitHub access token by environment variables GITHUB_TOKEN or GHALINT_GITHUB_TOKEN.
You can also manage it by secret stores such as GNOME Keyring, Windows Credential Manager, and macOS Keychain.
ghalint exp token set [-stdin]
ghalint exp token rm # Remove a token from secret store
1,207 commits
276 commits
182 commits
2 commits
Go
99.3%