From 4ac2728e73d5b47b69d7052b3c0e023a5d58a7b1 Mon Sep 17 00:00:00 2001 From: Will Jones Date: Thu, 19 Nov 2026 14:42:22 -0800 Subject: [PATCH] ci: scope workflow permissions and drop unverified downloads (#5103) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Fixes four high-severity Aikido findings in CI and the Dockerfile. - **Workflow permissions:** `npm-publish.yml` and `codex-update-lance-dependency.yml` now set `permissions: {}` at the workflow level and grant permissions per job. - `npm-publish`: only `publish` gets `id-token: write` (npm provenance). Nothing in the workflow needed `contents: write`, so every job is now read-only. - `codex-update-lance-dependency`: keeps `contents: write`, because the branch is pushed with the checkout token. It drops `pull-requests: write` and `actions: read`, because all `gh` calls use `ROBOT_TOKEN`. - **license-header-check:** replaces `curl .../master/install.sh | bash` with `go install …@v1.5.0`. Go verifies the module against sum.golang.org, so we don't maintain a hash ourselves. Go is preinstalled on `ubuntu-latest`. - **Dockerfile:** drops the rustup `curl | sh` along with `build-essential`, `protoc`, and `git`, and runs as a non-root `lancedb` user. `lancedb` installs from prebuilt `manylinux_2_28` wheels, and the toolchain was only needed for the tantivy FTS support removed in #3282. Alternatives considered for the Dockerfile, in case we want Rust in the image: - `COPY --from=rust:-slim-bookworm@sha256:…` to copy the toolchain from the official image, pinned by digest. - Download `rustup-init` from `static.rust-lang.org` and check it against the published `.sha256`. Neither seemed worth it for an image that only runs `pip install lancedb`. ## Evidence - In a clean Python 3.12 venv, `pip install --only-binary :all: lancedb` installed 0.41.0, and building an FTS index and querying it worked. Docker wasn't available, so the image itself wasn't built. - Running `license-header-checker` v1.5.0 installed via `go install` over `rust/` reports `license_ok: 258 files`. - This PR runs both the `npm-publish` dry run and `license-header-check`, because both workflows' path filters include their own files. ## Merge Risk **Door:** two-way; CI config and an example Dockerfile only. **Blast Radius:** release automation. If `npm publish` or the Codex bump job needs a permission I removed, it will fail on the next tag or dispatch, and restoring that one permission fixes it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 --- .../codex-update-lance-dependency.yml | 8 ++--- .github/workflows/license-header-check.yml | 5 ++-- .github/workflows/npm-publish.yml | 12 ++++++-- dockerfiles/Dockerfile | 29 ++++--------------- 4 files changed, 21 insertions(+), 33 deletions(-) diff --git a/.github/workflows/codex-update-lance-dependency.yml b/.github/workflows/codex-update-lance-dependency.yml index ef59213bd..1d1890efb 100644 --- a/.github/workflows/codex-update-lance-dependency.yml +++ b/.github/workflows/codex-update-lance-dependency.yml @@ -16,14 +16,14 @@ on: default: "" type: string -permissions: - contents: write - pull-requests: write - actions: read +permissions: {} jobs: update: runs-on: ubuntu-latest + permissions: + # Pushes the branch with the checkout token. PR creation uses ROBOT_TOKEN. + contents: write steps: - name: Show inputs run: | diff --git a/.github/workflows/license-header-check.yml b/.github/workflows/license-header-check.yml index 8b8510b58..904eea2c4 100644 --- a/.github/workflows/license-header-check.yml +++ b/.github/workflows/license-header-check.yml @@ -21,11 +21,10 @@ jobs: steps: - name: Check out code uses: actions/checkout@v6 + # `go install` at a fixed version is verified against the Go checksum database. - name: Install license-header-checker - working-directory: /tmp run: | - curl -s https://raw.githubusercontent.com/lluissm/license-header-checker/master/install.sh | bash - mv /tmp/bin/license-header-checker /usr/local/bin/ + GOBIN=/usr/local/bin go install github.com/lluissm/license-header-checker/cmd/license-header-checker@v1.5.0 - name: Check license headers (rust) run: license-header-checker -a -v ./rust/license_header.txt ./ rs && [[ -z `git status -s` ]] - name: Check license headers (python) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 6de291c7d..fbaa43201 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -4,9 +4,7 @@ env: MACOSX_DEPLOYMENT_TARGET: '10.13' CARGO_INCREMENTAL: '0' -permissions: - contents: write - id-token: write +permissions: {} on: push: @@ -33,6 +31,8 @@ concurrency: jobs: build-lancedb: + permissions: + contents: read strategy: fail-fast: false matrix: @@ -326,6 +326,8 @@ jobs: nodejs/dist/* !nodejs/dist/*.node test-lancedb: + permissions: + contents: read name: "Test: ${{ matrix.settings.target }} - node@${{ matrix.node }}" needs: - build-lancedb @@ -394,6 +396,10 @@ jobs: run: node_modules/.bin/jest --verbose publish: name: Publish + permissions: + contents: read + # npm provenance + id-token: write runs-on: ubuntu-latest defaults: run: diff --git a/dockerfiles/Dockerfile b/dockerfiles/Dockerfile index 1c223b9b8..d8cafa690 100644 --- a/dockerfiles/Dockerfile +++ b/dockerfiles/Dockerfile @@ -1,27 +1,10 @@ -# Simple base dockerfile that supports basic dependencies required to run lance with FTS and Hybrid Search +# Simple base dockerfile for running LanceDB, including FTS and Hybrid Search # Usage: docker build -t lancedb:latest -f Dockerfile . FROM python:3.12-slim-bookworm -# Install build dependencies in a single layer -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - curl \ - build-essential \ - protobuf-compiler \ - git \ - ca-certificates && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# Install Rust (pinned installer, non-interactive) -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile minimal - -# Set the environment variable for Rust -ENV PATH="/root/.cargo/bin:${PATH}" - -# Verify installations -RUN python --version && \ - rustc --version && \ - protoc --version - +# lancedb ships prebuilt manylinux wheels, so no Rust or C toolchain is needed. RUN pip install --no-cache-dir lancedb + +RUN useradd --create-home --uid 1000 lancedb +USER lancedb +WORKDIR /home/lancedb