Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

[MISC] Give GitHub workflows least-privilege token permissions (#2396)

Ritwik G255f0d39fd9b
diff --git a/.github/workflows/ci-frontend-lint.yaml b/.github/workflows/ci-frontend-lint.yaml
index 7131ecf9c..8dc81bfe5 100644
--- a/.github/workflows/ci-frontend-lint.yaml
+++ b/.github/workflows/ci-frontend-lint.yaml
@@ -14,6 +14,10 @@ on:
types: [opened, synchronize, reopened, ready_for_review]
branches: [main]
+# The repo default token is write; grant only what each job needs.
+permissions:
+ contents: read
+
jobs:
# Gating jobs below run when `changes` finds frontend files, AND whenever
# `changes` itself did not succeed: a skipped job satisfies a required
@@ -22,6 +26,10 @@ jobs:
changes:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ # dorny/paths-filter lists PR files via the API.
+ pull-requests: read
outputs:
# Push is already path-filtered by its trigger, so force true off-PR.
frontend: ${{ github.event_name != 'pull_request' || steps.filter.outputs.frontend == 'true' }}
@@ -44,10 +52,16 @@ jobs:
needs: changes
if: ${{ !cancelled() && github.event.pull_request.draft != true && (needs.changes.result != 'success' || needs.changes.outputs.frontend == 'true') }}
runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ # marocchino/sticky-pull-request-comment posts the lint report.
+ pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
+ with:
+ persist-credentials: false
- name: Setup Biome
uses: biomejs/setup-biome@4c91541eaada48f67d7dbd7833600ce162b68f51 # v2.7.1
@@ -107,6 +121,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v6
+ with:
+ persist-credentials: false
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
@@ -131,6 +147,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v6
+ with:
+ persist-credentials: false
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
diff --git a/.github/workflows/ci-test.yaml b/.github/workflows/ci-test.yaml
index 8509f496b..dc7960897 100644
--- a/.github/workflows/ci-test.yaml
+++ b/.github/workflows/ci-test.yaml
@@ -19,6 +19,10 @@ on:
- main
workflow_dispatch:
+# The repo default token is write; grant only what each job needs.
+permissions:
+ contents: read
+
jobs:
# Path filtering at job level, not trigger paths-ignore: an untriggered
# workflow reports no check run, so a required check waits forever; a job
@@ -28,6 +32,10 @@ jobs:
# and docker/** changes must be e2e-tested.
changes:
runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ # dorny/paths-filter lists PR files via the API.
+ pull-requests: read
outputs:
# Filtering is a PR-time saving only. On workflow_dispatch there is no
# base to diff, so paths-filter resolves against the default branch and a
@@ -270,6 +278,10 @@ jobs:
# from a real tier failure.
if: always() && github.event.pull_request.draft == false
runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ # marocchino/sticky-pull-request-comment posts the test report.
+ pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
diff --git a/.github/workflows/docker-tools-build-push.yaml b/.github/workflows/docker-tools-build-push.yaml
index dc1173b82..3e186978e 100644
--- a/.github/workflows/docker-tools-build-push.yaml
+++ b/.github/workflows/docker-tools-build-push.yaml
@@ -24,6 +24,11 @@ on:
run-name: "[${{ inputs.service_name }}:${{ inputs.tag }}] Docker Image Build and Push (Development)"
+# The repo default token is write. The image goes to Docker Hub via secrets,
+# so the token is only used to check out.
+permissions:
+ contents: read
+
jobs:
build-and-push:
runs-on: ubuntu-latest
@@ -33,6 +38,8 @@ jobs:
- name: Checkout code
uses: actions/checkout@v6
+ with:
+ persist-credentials: false
# Set up QEMU for ARM64 emulation
- name: Set up QEMU
diff --git a/.github/workflows/production-build.yaml b/.github/workflows/production-build.yaml
index b91d35b33..63d842936 100644
--- a/.github/workflows/production-build.yaml
+++ b/.github/workflows/production-build.yaml
@@ -18,6 +18,11 @@ on:
run-name: "[${{ github.event.release.tag_name || github.event.inputs.tag }}] Docker Image Build and Push (Production)"
+# The repo default token is write. Docker Hub and Slack are reached via
+# secrets, so the token only reads: checkout and `gh release list`.
+permissions:
+ contents: read
+
jobs:
# Validates tag format and version monotonicity within the same major.minor line.
# This guards the workflow_dispatch tag input and any release event.
@@ -112,10 +117,13 @@ jobs:
uses: actions/checkout@v6
with:
ref: ${{ github.event.release.tag_name }}
+ persist-credentials: false
- name: Checkout code for branch
if: github.event_name != 'release'
uses: actions/checkout@v6
+ with:
+ persist-credentials: false
# Set up QEMU for ARM64 emulation
- name: Set up QEMU
diff --git a/.github/workflows/release-notification.yaml b/.github/workflows/release-notification.yaml
index f22e83285..cf5d23882 100644
--- a/.github/workflows/release-notification.yaml
+++ b/.github/workflows/release-notification.yaml
@@ -4,6 +4,9 @@ on:
release:
types: [created]
+# Posts to a Slack incoming webhook (a secret); never uses the GITHUB_TOKEN.
+permissions: {}
+
jobs:
notify-slack:
runs-on: ubuntu-latest