From 6c86cfc6d06dee1fbdd96fc6407c099fc18858ad Mon Sep 17 00:00:00 2001 From: Aaron <7063649+ahcode0919@users.noreply.github.com> Date: Wed, 4 Nov 2026 21:54:12 -0800 Subject: [PATCH 1/2] Add Zizmor GitHub Action Security --- .devcontainer/Dockerfile | 9 +++--- .devcontainer/devcontainer.json | 5 +-- .github/dependabot.yml | 46 +++++++++++++++++++++++++++ .github/workflows/python.yml | 26 ++++++--------- .github/workflows/release-drafter.yml | 10 +++--- .github/workflows/release.yml | 13 +++++--- .github/workflows/security.yml | 41 ++++++++++++++++++++++++ Brewfile | 1 + README.md | 24 ++++++++++++-- justfile | 2 ++ pyproject.toml | 4 +-- 11 files changed, 141 insertions(+), 40 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/security.yml diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 4f6e87b..7a2f5ce 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,17 +1,17 @@ # See here for image contents: https://github.com/devcontainers/images/tree/main/src -ARG VARIANT="3.14-bookworm" -FROM mcr.microsoft.com/vscode/devcontainers/python:${VARIANT} +# Image version 3.3.2, Python 3.14, Debian bookworm. Tag and digest are updated by Dependabot. +FROM mcr.microsoft.com/vscode/devcontainers/python:3.3.2-3.14-bookworm@sha256:94053b777943a4eda40e83d5386f7c5befb72f5bb778878ac527bb9491adcd42 # [Choice] Node.js version: none, lts/*, 16, 14, 12, 10 ARG NODE_VERSION="none" RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi # Just Installation -COPY --from=ghcr.io/casey/just:latest /just /usr/local/bin/ +COPY --from=ghcr.io/casey/just:1.59.0@sha256:014cbe6e6de678864004e2fd8b0405f77ce43b20b225e816feb330f2fb575c01 /just /usr/local/bin/ # uv Installation -COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/ +COPY --from=ghcr.io/astral-sh/uv:0.13.7@sha256:96f40d3904aad8d0bd010539001d36c8e2188b981e1334471a90c4a1d93bb490 /uv /uvx /usr/local/bin/ # [Optional] Uncomment this section to install additional OS packages. # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ @@ -19,4 +19,3 @@ COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/ # [Optional] Uncomment this line to install global node packages. # RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 - diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 1a979fc..29a8655 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -6,10 +6,7 @@ "dockerfile": "Dockerfile", "context": "..", "args": { - // Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6 - // Append -bullseye or -buster to pin to an OS version. - // Use -bullseye variants on local on arm64/Apple Silicon. - "VARIANT": "3.14-bookworm", + // The Python version is pinned in the Dockerfile's FROM line (tag + digest). // Options "NODE_VERSION": "none" } diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..d3535f0 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,46 @@ +# Dependabot configuration. +# See https://docs.github.com/en/code-security/dependabot/working-with-dependabot/dependabot-options-reference +version: 2 + +updates: + # GitHub Actions used in .github/workflows (updates SHA pins and their version comments) + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + cooldown: + default-days: 7 + labels: ["dependencies"] + groups: + github-actions: + patterns: ["*"] + + # Python dependencies in pyproject.toml / uv.lock + - package-ecosystem: "uv" + directory: "/" + schedule: + interval: "weekly" + cooldown: + default-days: 7 + labels: ["dependencies"] + groups: + python-minor-and-patch: + update-types: ["minor", "patch"] + + # Base image in .devcontainer/Dockerfile + - package-ecosystem: "docker" + directory: "/.devcontainer" + schedule: + interval: "weekly" + cooldown: + default-days: 7 + labels: ["dependencies"] + + # Features in .devcontainer/devcontainer.json + - package-ecosystem: "devcontainers" + directory: "/" + schedule: + interval: "weekly" + cooldown: + default-days: 7 + labels: ["dependencies"] diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 78b3cb0..d7be2e8 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -1,4 +1,4 @@ -name: CI Checks +name: Python CI Checks on: push: @@ -6,31 +6,23 @@ on: pull_request: branches: [ main ] -permissions: - contents: read - pull-requests: read +permissions: {} jobs: code-check-and-unit-test: - runs-on: ubuntu-latest + runs-on: ubuntu-slim steps: - - uses: actions/checkout@v7 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: - fetch-depth: 0 # gitleaks needs commit history to scan the PR range - - name: Setup just - uses: extractions/setup-just@v3 + persist-credentials: false - name: Install uv - uses: astral-sh/setup-uv@v7 + uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 with: - enable-cache: true - version: ">=0.11,<0.12" - - name: Check gitleaks - uses: gitleaks/gitleaks-action@v3 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITLEAKS_ENABLE_COMMENTS: false + enable-cache: false + version: ">=0.13,<0.14" - name: Setup environment run: | + uv tool install rust-just just sync - name: Lint run: | diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 086cf7e..a1ab2b4 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -12,25 +12,25 @@ permissions: jobs: update-draft: if: github.event_name == 'push' - runs-on: ubuntu-latest + runs-on: ubuntu-slim permissions: contents: write # Release Drafter looks up the merged PRs for each commit pull-requests: read steps: - - uses: release-drafter/release-drafter@v6 + - uses: release-drafter/release-drafter@978bb0b30c5ee8cdd332ced253758157150d43f0 # v7.10.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} autolabel: if: github.event_name == 'pull_request' && github.event.action != 'labeled' && github.event.action != 'unlabeled' - runs-on: ubuntu-latest + runs-on: ubuntu-slim permissions: # Release Drafter reads .github/release-drafter.yml through the contents API contents: read pull-requests: write steps: - - uses: release-drafter/release-drafter@v6 + - uses: release-drafter/release-drafter@978bb0b30c5ee8cdd332ced253758157150d43f0 # v7.10.0 with: disable-releaser: true env: @@ -45,7 +45,7 @@ jobs: contents: read pull-requests: read steps: - - uses: mheap/github-action-required-labels@v5 + - uses: mheap/github-action-required-labels@23e10fde7e062233401931a0eece796cd9bf3177 # v5.6.0 with: mode: minimum count: 1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ff9a499..f6c2b36 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,17 +18,20 @@ jobs: # Release Drafter looks up the merged PRs for each commit pull-requests: read steps: - - uses: actions/checkout@v7 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: main + # Credentials are kept so the job can push the release commit + persist-credentials: true # zizmor: ignore[artipacked] - name: Install uv - uses: astral-sh/setup-uv@v7 + uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 with: - version: ">=0.11,<0.12" + enable-cache: false + version: ">=0.13,<0.14" - name: Refresh draft release id: drafter - uses: release-drafter/release-drafter@v6 + uses: release-drafter/release-drafter@978bb0b30c5ee8cdd332ced253758157150d43f0 # v7.10.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -38,7 +41,7 @@ jobs: run: uv version "$VERSION" - name: Update CHANGELOG.md - uses: stefanzweifel/changelog-updater-action@v1 + uses: stefanzweifel/changelog-updater-action@a938690fad7edf25368f37e43a1ed1b34303eb36 # v1.12.0 with: latest-version: ${{ steps.drafter.outputs.tag_name }} release-notes: ${{ steps.drafter.outputs.body }} diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml new file mode 100644 index 0000000..2030c73 --- /dev/null +++ b/.github/workflows/security.yml @@ -0,0 +1,41 @@ +name: GitHub Actions Security Analysis + +on: + push: + branches: ["main"] + pull_request: + branches: ["**"] + +permissions: {} + +jobs: + zizmor: + runs-on: ubuntu-slim + permissions: + contents: read # only needed for private or internal repos + actions: read # only needed for private or internal repos + steps: + - name: Checkout repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Run zizmor + uses: zizmorcore/zizmor-action@45d7276c9ca790aabd705e31ca99c6185c3e76dd # v0.8.1 + with: + advanced-security: false + gitleaks: + runs-on: ubuntu-slim + permissions: + contents: read # needed for private repos + pull-requests: read # gitleaks lists the PR's commits to scan + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + fetch-depth: 0 + - name: Check gitleaks + uses: gitleaks/gitleaks-action@e0c47f4f8be36e29cdc102c57e68cb5cbf0e8d1e # v3.0.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITLEAKS_ENABLE_COMMENTS: false diff --git a/Brewfile b/Brewfile index 3448ca2..68ab74e 100644 --- a/Brewfile +++ b/Brewfile @@ -1,3 +1,4 @@ brew "gitleaks" brew "just" brew "uv" +brew "zizmor" diff --git a/README.md b/README.md index 0bdc5b0..0d0ddfe 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # PyPricecharting API Client ![](https://github.com/ahcode0919/pypricecharting/actions/workflows/python.yml/badge.svg?branch=main) +[![Security](https://github.com/ahcode0919/pypricecharting/actions/workflows/security.yml/badge.svg?branch=main)](https://github.com/ahcode0919/pypricecharting/actions/workflows/security.yml) [![gitleaks](https://img.shields.io/badge/protected%20by-gitleaks-blue)](https://github.com/gitleaks/gitleaks) Pricecharting API Client written in Python @@ -9,11 +10,12 @@ Project supports local development and VSCode Dev container development ### Local Development Installation -Note: Project uses `uv` and `just` to manage project configuration and commands +Note: Project uses `uv` (0.13.x, enforced by `required-version` in `pyproject.toml`) and `just` to +manage project configuration and commands * Install `just` - `brew install just` * Set up project - `just setup` - * Installs Homebrew dependencies (`gitleaks`, `just`, `uv`) + * Installs Homebrew dependencies (`gitleaks`, `just`, `uv`, `zizmor`) * Installs `prek` git hooks * Syncs project dependencies @@ -25,6 +27,9 @@ Note: Project uses `uv` and `just` to manage project configuration and commands * Optional - Install recommended extensions * Reopen in container using Remote Development Container menu +The base image, `just`, and `uv` are pinned by version and digest in `.devcontainer/Dockerfile` +and updated by Dependabot. To change the Python version, edit the `FROM` line. + ## Project Commands * `just setup` - install tools and git hooks, then sync dependencies @@ -34,6 +39,7 @@ Note: Project uses `uv` and `just` to manage project configuration and commands * `just test` - run unit tests * `just prek` - run all pre-commit hooks * `just git-leaks` - scan staged changes for secrets +* `just zizmor` - audit GitHub Actions workflows for security issues * `uv add {package}` - install a dependency ### Pre-commit Hooks @@ -45,6 +51,20 @@ Note: Project uses `uv` and `just` to manage project configuration and commands * `just test` * `gitleaks` secret scan of staged changes +## CI and Security + +| Workflow | Runs on | Purpose | +| ------------------------------------------------- | ---------------------------- | ---------------------------------------------- | +| `python.yml` | push / PR to `main` | lint and unit tests | +| `security.yml` | push to `main`, all PRs | zizmor workflow audit, gitleaks secret scan | +| `release-drafter.yml` | push to `main`, PRs | update the draft release, label PRs | +| `release.yml` | manual | publish a release | + +* GitHub Actions are pinned to full commit SHAs, with the version in a trailing comment +* Dependabot (`.github/dependabot.yml`) checks weekly for updates to GitHub Actions, Python + dependencies, the dev container image, and dev container features. New releases wait 7 days + before an update is proposed. Dependabot PRs get the `dependencies` label + ## Releases Releases are managed with [Release Drafter](https://github.com/release-drafter/release-drafter), diff --git a/justfile b/justfile index 7cc4087..df5bd76 100644 --- a/justfile +++ b/justfile @@ -20,3 +20,5 @@ sync: uv sync --all-groups test: uv run pytest +zizmor: + zizmor . --collect all diff --git a/pyproject.toml b/pyproject.toml index 4176c79..de1e577 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ requires-python = ">=3.14" dependencies = [] [build-system] -requires = ["uv_build>=0.11.32,<0.12.0"] +requires = ["uv_build>=0.13.7,<0.14.0"] build-backend = "uv_build" [dependency-groups] @@ -43,4 +43,4 @@ extend-ignore = ["E501"] # Line too long (handled by formatter) quote-style = "double" [tool.uv] -required-version = ">=0.11,<0.12" +required-version = ">=0.13,<0.14" From 1bc545562d0bd18f327f48448eebb3af14b411c0 Mon Sep 17 00:00:00 2001 From: Aaron <7063649+ahcode0919@users.noreply.github.com> Date: Wed, 4 Nov 2026 22:04:44 -0800 Subject: [PATCH 2/2] Correct permissions --- .github/workflows/python.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index d7be2e8..8bc3a9b 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -11,6 +11,8 @@ permissions: {} jobs: code-check-and-unit-test: runs-on: ubuntu-slim + permissions: + contents: read steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: