Zizmor

1.23.1 · active · verified Sat Apr 11

Zizmor is a static analysis tool for GitHub Actions, designed to identify common security vulnerabilities in CI/CD setups. It detects issues such as template injection, accidental credential leakage, excessive permission scopes, and impostor commits. Currently at version 1.23.1, the project maintains an active development pace with frequent releases.

Warnings

Install

Quickstart

This quickstart demonstrates how to run `zizmor` as a command-line tool from Python using `subprocess`. The `--target .` flag scans the current directory for GitHub Actions workflows. A GitHub token (GH_TOKEN) is often necessary for `zizmor` to perform comprehensive 'online audits' and resolve remote actions without hitting GitHub API rate limits.

import subprocess
import os

# Ensure zizmor is installed via 'pip install zizmor' and in your PATH.
# A GitHub token (GH_TOKEN) is often required for full functionality,
# especially for 'online audits' or resolving remote actions.
github_token = os.environ.get('GH_TOKEN', '')

try:
    # Run zizmor audit on the current directory ('.')
    # Replace '.' with your target GitHub Actions workflow directory if different.
    command = [
        "zizmor",
        "audit",
        "--target",
        "."
    ]
    if github_token:
        command.extend(["--github-token", github_token])

    print(f"Running command: {' '.join(command)}")
    process = subprocess.run(
        command,
        capture_output=True,
        text=True,
        check=False  # Set to True if you want an exception on non-zero exit codes
    )

    print("\n--- Zizmor Output ---")
    print(process.stdout)
    if process.stderr:
        print("\n--- Zizmor Errors ---")
        print(process.stderr)

    if process.returncode != 0:
        print(f"\nZizmor exited with non-zero status code: {process.returncode}")
    else:
        print("\nZizmor completed successfully.")

except FileNotFoundError:
    print("Error: 'zizmor' command not found. Please ensure zizmor is installed and in your system's PATH.")
except Exception as e:
    print(f"An unexpected error occurred: {e}")

view raw JSON →