diff --git a/.github/scripts/update-compat-versions.py b/.github/scripts/update-compat-versions.py index 2e8fec928fe..49f01f36d36 100644 --- a/.github/scripts/update-compat-versions.py +++ b/.github/scripts/update-compat-versions.py @@ -40,11 +40,11 @@ from typing import Iterable VERSION_RE = re.compile(r"^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$") FROM_VERSIONS_RE = re.compile( - r"(?ms)^(?P[ \t]*)from_versions[ \t]*=[ \t]*(?P\[(?:[^\]]|\n)*?\])" + r"(?ms)^(?P[ \t]*)from_versions[ \t]*=[ \t]*(?P\[[^\]]*?\])" ) FROM_VERSIONS_ASSIGNMENT_RE = re.compile(r"(?m)^[ \t]*from_versions[ \t]*=") FROM_RANGE_RE = re.compile( - r"(?ms)^[ \t]*from_range[ \t]*=[ \t]*(?P\[(?:[^\]]|\n)*?\])" + r"(?ms)^[ \t]*from_range[ \t]*=[ \t]*(?P\[[^\]]*?\])" ) FROM_RANGE_ASSIGNMENT_RE = re.compile(r"(?m)^[ \t]*from_range[ \t]*=") diff --git a/.github/workflows/apidoc.yml b/.github/workflows/apidoc.yml index fb5601fdc5b..b19c27b881a 100644 --- a/.github/workflows/apidoc.yml +++ b/.github/workflows/apidoc.yml @@ -12,9 +12,15 @@ on: name: Build API docs +# Least-privilege default for every job; jobs that need more grant it explicitly. +permissions: + contents: read + jobs: apidoc: runs-on: ubuntu-latest + permissions: + contents: write # github-pages-deploy-action pushes to gh-pages with GITHUB_TOKEN. steps: - uses: actions/checkout@v4 with: diff --git a/.github/workflows/check-git-deps.yml b/.github/workflows/check-git-deps.yml index a4ec488e850..50e7d1dd0da 100644 --- a/.github/workflows/check-git-deps.yml +++ b/.github/workflows/check-git-deps.yml @@ -11,6 +11,10 @@ on: paths: - 'Cargo.toml' +# Least-privilege default for every job; jobs that need more grant it explicitly. +permissions: + contents: read + jobs: check-git-deps: if: ${{ github.event.pull_request.draft == false }} diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 0d38a844539..6e4df16650c 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -30,6 +30,10 @@ concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true +# Least-privilege default for every job; jobs that need more grant it explicitly. +permissions: + contents: read + jobs: check-typos-and-docs: if: ${{ github.repository == 'GreptimeTeam/greptimedb' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) }} diff --git a/.github/workflows/dependency-check.yml b/.github/workflows/dependency-check.yml index e5d6e036a85..760937cb891 100644 --- a/.github/workflows/dependency-check.yml +++ b/.github/workflows/dependency-check.yml @@ -6,6 +6,10 @@ on: branches: - main +# Least-privilege default for every job; jobs that need more grant it explicitly. +permissions: + contents: read + jobs: check-dependencies: if: ${{ github.event.pull_request.draft == false }} diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml index 0295c5d2779..3a21a3e2ded 100644 --- a/.github/workflows/dev-build.yml +++ b/.github/workflows/dev-build.yml @@ -90,6 +90,10 @@ env: # The source code will check out in the following path: '${WORKING_DIR}/dev/greptime'. CHECKOUT_GREPTIMEDB_PATH: dev/greptimedb +# Least-privilege default for every job; jobs that need more grant it explicitly. +permissions: + contents: read + jobs: allocate-runners: name: Allocate runners diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index fa8bc7af2d9..3736f99f38b 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -33,6 +33,10 @@ on: name: Docs CI +# Least-privilege default for every job; jobs that need more grant it explicitly. +permissions: + contents: read + # To pass the required status check, see: # https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks diff --git a/.github/workflows/grafana.yml b/.github/workflows/grafana.yml index 2ec57b3cf5d..69551183df0 100644 --- a/.github/workflows/grafana.yml +++ b/.github/workflows/grafana.yml @@ -8,6 +8,10 @@ on: paths: - 'grafana/**' # Trigger only when files under the grafana/ directory change +# Least-privilege default for every job; jobs that need more grant it explicitly. +permissions: + contents: read + jobs: check-panels: if: ${{ github.event.pull_request.draft == false }} diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 6f0134c2a11..9b6b660ab92 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -41,6 +41,10 @@ concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true +# Least-privilege default for every job; jobs that need more grant it explicitly. +permissions: + contents: read + jobs: github-script-tests: if: ${{ github.repository == 'GreptimeTeam/greptimedb' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) }} diff --git a/.github/workflows/nightly-build.yml b/.github/workflows/nightly-build.yml index 81627e9fa4c..d39a3d74b76 100644 --- a/.github/workflows/nightly-build.yml +++ b/.github/workflows/nightly-build.yml @@ -71,6 +71,10 @@ env: NIGHTLY_RELEASE_PREFIX: nightly +# Least-privilege default for every job; jobs that need more grant it explicitly. +permissions: + contents: read + jobs: allocate-runners: name: Allocate runners diff --git a/.github/workflows/nightly-ci.yml b/.github/workflows/nightly-ci.yml index b00b910df5a..4c59aa5c9db 100644 --- a/.github/workflows/nightly-ci.yml +++ b/.github/workflows/nightly-ci.yml @@ -9,6 +9,10 @@ concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true +# Least-privilege default for every job; jobs that need more grant it explicitly. +permissions: + contents: read + jobs: sqlness-test: name: Run sqlness test @@ -206,6 +210,9 @@ jobs: name: Send notification to Greptime team needs: [check-status] runs-on: ubuntu-latest + permissions: + contents: read + issues: write # cyborg report-ci-failure opens an issue with GITHUB_TOKEN. env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_DEVELOP_CHANNEL }} steps: diff --git a/.github/workflows/release-dev-builder-images.yaml b/.github/workflows/release-dev-builder-images.yaml index 9f74035f8c9..8eb877b229b 100644 --- a/.github/workflows/release-dev-builder-images.yaml +++ b/.github/workflows/release-dev-builder-images.yaml @@ -46,6 +46,10 @@ on: required: false default: false +# Least-privilege default for every job; jobs that need more grant it explicitly. +permissions: + contents: read + jobs: changes: name: Detect changed components diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c4489f9aabd..8ac5c36bf80 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -123,6 +123,10 @@ env: # nightly release may run again; see the 'Check nightly release necessity' step. NIGHTLY_RELEASE_MAX_AGE_DAYS: 5 +# Least-privilege default for every job; jobs that need more grant it explicitly. +permissions: + contents: read + jobs: allocate-runners: name: Allocate runners @@ -736,6 +740,8 @@ jobs: query-regression-release, ] runs-on: ubuntu-latest + permissions: + contents: write # ncipollo/release-action creates the release with GITHUB_TOKEN. steps: - uses: actions/checkout@v4 with: @@ -751,6 +757,11 @@ jobs: name: Update compatibility versions needs: [allocate-runners, publish-github-release] if: ${{ needs.publish-github-release.result == 'success' }} + # Must cover what the called workflow's 'update' job requests; a caller's + # permissions are the ceiling for a reusable workflow. + permissions: + contents: write + pull-requests: write uses: ./.github/workflows/update-compat-versions.yml with: release_tag: ${{ needs.allocate-runners.outputs.version }} diff --git a/.github/workflows/run-multi-lang-tests.yml b/.github/workflows/run-multi-lang-tests.yml index dad4fbaa080..d3610281bf9 100644 --- a/.github/workflows/run-multi-lang-tests.yml +++ b/.github/workflows/run-multi-lang-tests.yml @@ -52,6 +52,10 @@ on: default: false description: 'Whether the artifact is a tarball (tar.gz) that needs to be extracted' +# Least-privilege default for every job; jobs that need more grant it explicitly. +permissions: + contents: read + jobs: run-tests: name: Run Multi-language SDK Tests diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index edf4b509fb7..57a1941ef65 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -30,6 +30,10 @@ concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true +# Least-privilege default for every job; jobs that need more grant it explicitly. +permissions: + contents: read + jobs: github-script-tests: if: ${{ github.repository == 'GreptimeTeam/greptimedb' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) }} diff --git a/.github/workflows/update-compat-versions.yml b/.github/workflows/update-compat-versions.yml index 460a2c30815..1a655d76ae0 100644 --- a/.github/workflows/update-compat-versions.yml +++ b/.github/workflows/update-compat-versions.yml @@ -18,6 +18,10 @@ concurrency: group: update-compat-versions cancel-in-progress: false +# Least-privilege default for every job; jobs that need more grant it explicitly. +permissions: + contents: read + jobs: validate-release: if: ${{ github.repository == 'GreptimeTeam/greptimedb' }}