diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 94a26bd..4cb3b22 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,9 +1,11 @@ # Global default code owners * @lopes -# Reusable Security Workflows & Gitleaks Baseline +# Reusable Security Workflows & Scanner Baselines /.github/workflows/ @lopes +/.github/dependabot.yml @lopes /.gitleaks.toml @lopes +/.zizmor.yml @lopes # Account-Wide Security Policy & Documentation /SECURITY.md @lopes diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index d57652c..0724cad 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -13,6 +13,7 @@ body: options: - "Gitleaks Secret Scanning (.gitleaks.toml, security.yml)" - "Opengrep SAST Scanning (security.yml)" + - "Zizmor GitHub Actions Scanning (.zizmor.yml, security.yml)" - "Trivy Vulnerability & IaC Scanning (security.yml)" - "Community Health Defaults (SECURITY.md)" validations: diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index bb65aa8..2c7cef5 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -13,7 +13,7 @@ body: id: context attributes: label: Context - description: "Security rationale, false-positive analysis, execution time impact across caller repositories, and affected files (`.gitleaks.toml`, `security.yml`)." + description: "Security rationale, false-positive analysis, execution time impact across caller repositories, and affected files (`.gitleaks.toml`, `.zizmor.yml`, `security.yml`)." validations: required: true - type: textarea diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index ccc4db0..8b1f289 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -6,12 +6,12 @@ ## Type of Change - [ ] Reusable Security Workflow (`.github/workflows/security.yml`) -- [ ] Canonical Gitleaks Ruleset (`.gitleaks.toml`) +- [ ] Canonical Scanner Baselines (`.gitleaks.toml`, `.zizmor.yml`) - [ ] Account-Wide Security Policy (`SECURITY.md`) - [ ] Documentation & Governance (`README.md`, `.github/`) ## Quality Checklist -- [ ] Reusable workflow (`security.yml`) passes on this PR (`gitleaks`, `opengrep`, `trivy`). +- [ ] Reusable workflow (`security.yml`) passes on this PR (`gitleaks`, `opengrep`, `zizmor`, `trivy`). - [ ] Scanner versions and action tags are explicitly pinned. - [ ] Downstream impact across caller repositories (`lopes/*`) reviewed. - [ ] Commit follows [Scoped Commits](https://scopedcommits.com/) convention (`: `). diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index 2a06c24..4c53188 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -48,18 +48,24 @@ jobs: with: fetch-depth: 0 path: repo + persist-credentials: false - name: Checkout shared security baseline uses: actions/checkout@v7 with: repository: lopes/.github path: baseline + persist-credentials: false - name: Install pinned gitleaks env: GITLEAKS_VERSION: ${{ inputs.gitleaks_version || '8.30.1' }} run: | set -euo pipefail + [[ "${GITLEAKS_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { + echo "::error::Invalid gitleaks_version '${GITLEAKS_VERSION}' (expected X.Y.Z)" >&2 + exit 1 + } curl -fsSL "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" -o /tmp/gitleaks.tar.gz tar -xzf /tmp/gitleaks.tar.gz -C /usr/local/bin gitleaks chmod +x /usr/local/bin/gitleaks @@ -86,12 +92,17 @@ jobs: with: fetch-depth: 1 path: repo + persist-credentials: false - name: Install pinned opengrep static binary env: OPENGREP_VERSION: ${{ inputs.opengrep_version || '1.33.1' }} run: | set -euo pipefail + [[ "${OPENGREP_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { + echo "::error::Invalid opengrep_version '${OPENGREP_VERSION}' (expected X.Y.Z)" >&2 + exit 1 + } curl -fsSL "https://github.com/opengrep/opengrep/releases/download/v${OPENGREP_VERSION}/opengrep_manylinux_x86" -o /usr/local/bin/opengrep chmod +x /usr/local/bin/opengrep opengrep --version @@ -140,18 +151,24 @@ jobs: with: fetch-depth: 1 path: repo + persist-credentials: false - name: Checkout shared security baseline uses: actions/checkout@v7 with: repository: lopes/.github path: baseline + persist-credentials: false - name: Install pinned zizmor env: ZIZMOR_VERSION: ${{ inputs.zizmor_version || '1.32.0' }} run: | set -euo pipefail + [[ "${ZIZMOR_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { + echo "::error::Invalid zizmor_version '${ZIZMOR_VERSION}' (expected X.Y.Z)" >&2 + exit 1 + } curl -fsSL "https://github.com/zizmorcore/zizmor/releases/download/v${ZIZMOR_VERSION}/zizmor-x86_64-unknown-linux-gnu.tar.gz" -o /tmp/zizmor.tar.gz tar -xzf /tmp/zizmor.tar.gz -C /usr/local/bin zizmor chmod +x /usr/local/bin/zizmor @@ -160,17 +177,27 @@ jobs: - name: Audit GitHub Actions workflows run: | set -euo pipefail - if [ ! -d repo/.github/workflows ]; then - echo "No .github/workflows directory found; skipping zizmor." + if [ ! -d repo/.github/workflows ] && \ + [ ! -f repo/.github/dependabot.yml ] && \ + [ ! -f repo/.github/dependabot.yaml ] && \ + [ ! -f repo/action.yml ] && \ + [ ! -f repo/action.yaml ]; then + echo "No GitHub Actions workflows, composite actions, or dependabot config found; skipping zizmor." exit 0 fi - if [ -f repo/.zizmor.yml ]; then - CONFIG_PATH="repo/.zizmor.yml" - elif [ -f repo/zizmor.yml ]; then - CONFIG_PATH="repo/zizmor.yml" - else - CONFIG_PATH="baseline/.zizmor.yml" - fi + CONFIG_PATH="baseline/.zizmor.yml" + for candidate in \ + repo/.github/zizmor.yml \ + repo/.github/zizmor.yaml \ + repo/.zizmor.yml \ + repo/.zizmor.yaml \ + repo/zizmor.yml \ + repo/zizmor.yaml; do + if [ -f "${candidate}" ]; then + CONFIG_PATH="${candidate}" + break + fi + done echo "Using zizmor config: ${CONFIG_PATH}" zizmor --no-online-audits --config "${CONFIG_PATH}" --min-severity medium repo @@ -183,6 +210,7 @@ jobs: uses: actions/checkout@v7 with: fetch-depth: 1 + persist-credentials: false - name: Run Trivy filesystem vulnerability and misconfiguration scan uses: aquasecurity/trivy-action@v0.36.0 diff --git a/README.md b/README.md index 2ef7988..34c765c 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,21 @@ # .github -Shared GitHub Actions reusable security workflows, canonical `.gitleaks.toml` baseline, and default community health files for `github.com/lopes` repositories. +Shared GitHub Actions reusable security workflows, canonical `.gitleaks.toml` and `.zizmor.yml` baselines, and default community health files for `github.com/lopes` repositories. ## What Lives Here - **[`.github/workflows/security.yml`](.github/workflows/security.yml)** — Reusable workflow (`workflow_call`) executing four open-source deterministic checks across all repository paths (including `tests/`): 1. **`gitleaks`** (`v8.30.1`) — Full git commit-history secret scan (`fetch-depth: 0`, `--redact`). Uses the caller repository's `.gitleaks.toml` if present, or falls back to this repository's canonical [`.gitleaks.toml`](.gitleaks.toml). 2. **`opengrep`** (`v1.33.1`) — Open-source multi-language static analysis (`python`, `bash`, `rust`, `terraform`, `yaml/github-actions`, `generic/secrets`) at `ERROR` severity. - 3. **`zizmor`** (`v1.32.0`) — Dedicated GitHub Actions workflow security auditor (template injection, excessive permissions, dangerous triggers, cache poisoning). Uses the caller repository's `.zizmor.yml` if present, or falls back to this repository's canonical [`.zizmor.yml`](.zizmor.yml). - 4. **`trivy`** (`aquasecurity/trivy-action`) — Filesystem dependency vulnerability (`CRITICAL,HIGH` with available fixes) and IaC misconfiguration scan (Terraform, Ansible, Dockerfiles, GitHub Actions, and lockfiles). + 3. **`zizmor`** (`v1.32.0`) — Dedicated GitHub Actions workflow security auditor (template injection, excessive permissions, dangerous triggers, cache poisoning). Uses the caller repository's zizmor config (`.github/zizmor.yml`, `.zizmor.yml`, `zizmor.yml`, or `.yaml` variants) if present, or falls back to this repository's canonical [`.zizmor.yml`](.zizmor.yml). + 4. **`trivy`** (`aquasecurity/trivy-action` `v0.36.0`) — Filesystem dependency vulnerability (`CRITICAL,HIGH` with available fixes) and IaC misconfiguration scan (Terraform, Ansible, Dockerfiles, GitHub Actions, and lockfiles). - **[`.gitleaks.toml`](.gitleaks.toml)** — Canonical secret-scanning ruleset extending Gitleaks defaults with explicit URL query-parameter credential detection (`?key=`, `?api_key=`, `?token=`, `?access_token=`, `?license_key=`) and zero `tests/` exclusions. -- **[`.zizmor.yml`](.zizmor.yml)** — Canonical GitHub Actions static analysis baseline enforcing version reference pinning (`ref-pin`) while focusing audits on workflow security flaws (`--min-severity medium`). +- **[`.zizmor.yml`](.zizmor.yml)** — Canonical GitHub Actions static analysis baseline enforcing version reference pinning (`ref-pin`) while focusing audits on workflow security flaws (`--min-severity medium`, with `artipacked` disabled to avoid false positives on standard `actions/checkout` steps in caller workflows that do not upload workspace artifacts). - **[`SECURITY.md`](SECURITY.md)** — Account-wide default vulnerability disclosure policy inherited automatically by all public repositories under `github.com/lopes` unless overridden locally. > [!IMPORTANT] > **Why maintain an account-owned `.github` repository instead of calling a third-party workflow?** -> 1. **Supply-chain containment:** Referencing an external vendor's `uses: org/repo/.github/workflows/...@main` across every public and private repository delegates runner execution and `GITHUB_TOKEN` access to a mutable third-party branch. Owning `lopes/.github` keeps version pinning (`gitleaks`, `opengrep`, `trivy-action`, `actions/checkout`) under direct control while still pulling official upstream binaries and actions. +> 1. **Supply-chain containment:** Referencing an external vendor's `uses: org/repo/.github/workflows/...@main` across every public and private repository delegates runner execution and `GITHUB_TOKEN` access to a mutable third-party branch. Owning `lopes/.github` keeps version pinning (`gitleaks`, `opengrep`, `zizmor`, `trivy-action`, `actions/checkout`) under direct control while still pulling official upstream binaries and actions. > 2. **Fast, focused execution (~25s vs. 5+ min):** Multi-linter suites (`super-linter`, `megalinter`) pull multi-gigabyte container images on every run and do not bundle `opengrep` or account-wide `.gitleaks.toml` inheritance. > 3. **Single source of truth:** Updating a scanner version or adding a custom secret rule in `.gitleaks.toml` happens in one commit here rather than opening pull requests across every repository, and GitHub only inherits default community health files (`SECURITY.md`) from `/.github`.