diff --git a/.github/workflows/build-trigger-argo-workflow.yaml b/.github/workflows/build-trigger-argo-workflow.yaml index 7a967ddc9..e677299b2 100644 --- a/.github/workflows/build-trigger-argo-workflow.yaml +++ b/.github/workflows/build-trigger-argo-workflow.yaml @@ -16,6 +16,9 @@ on: - synchronize merge_group: +permissions: + contents: read + jobs: lint-test-build: runs-on: ubuntu-latest @@ -26,6 +29,11 @@ jobs: contents: read steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + with: + egress-policy: audit + - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: diff --git a/.github/workflows/check-drone-signature.yaml b/.github/workflows/check-drone-signature.yaml index 9fbd2d3f6..e2bb04100 100644 --- a/.github/workflows/check-drone-signature.yaml +++ b/.github/workflows/check-drone-signature.yaml @@ -12,6 +12,9 @@ on: type: string default: "https://drone.grafana.net" +permissions: + contents: read + jobs: # This job checks if we should run the drone signature check. # If the repository is under the "grafana" org, we will run the signature check. @@ -24,6 +27,12 @@ jobs: outputs: isFork: ${{ steps.check-if-fork.outputs.isFork }} steps: + - name: Harden the runner (Audit all outbound calls) + if: ${{ ! github.event.repository.private }} + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + with: + egress-policy: audit + - name: Check if forked repository id: check-if-fork run: | @@ -55,6 +64,11 @@ jobs: needs: check-fork if: needs.check-fork.outputs.isFork == 'false' steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + with: + egress-policy: audit + - name: Checkout repo uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: diff --git a/.github/workflows/check-for-non-releasable-actions.yaml b/.github/workflows/check-for-non-releasable-actions.yaml index af3f29d81..cf8cc087f 100644 --- a/.github/workflows/check-for-non-releasable-actions.yaml +++ b/.github/workflows/check-for-non-releasable-actions.yaml @@ -11,6 +11,9 @@ on: branches: - main +permissions: + contents: read + jobs: check-for-non-releasable-actions: permissions: @@ -20,6 +23,11 @@ jobs: timeout-minutes: 5 steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + with: + egress-policy: audit + - name: Checkout Code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 23384882f..881db5950 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -20,6 +20,9 @@ on: # To trigger a CodeQL analysis manually workflow_dispatch: +permissions: + contents: read + jobs: analyze: name: Analyze (${{ matrix.language }}) @@ -43,6 +46,11 @@ jobs: - "**/dist/**" steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + with: + egress-policy: audit + - name: Checkout repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml new file mode 100644 index 000000000..23bcb4c34 --- /dev/null +++ b/.github/workflows/dependency-review.yml @@ -0,0 +1,31 @@ +# Dependency Review Action +# +# This Action will scan dependency manifest files that change as part of a Pull Request, +# surfacing known-vulnerable versions of the packages declared or updated in the PR. +# Once installed, if the workflow run is marked as required, +# PRs introducing known-vulnerable packages will be blocked from merging. +# +# Source repository: https://github.com/actions/dependency-review-action +name: "Dependency Review" +on: + pull_request: + merge_group: + +permissions: + contents: read + +jobs: + dependency-review: + runs-on: ubuntu-latest + steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + with: + egress-policy: audit + + - name: "Checkout Repository" + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false + - name: "Dependency Review" + uses: actions/dependency-review-action@67d4f4bd7a9b17a0db54d2a7519187c65e339de8 # v4 diff --git a/.github/workflows/lint-pr-title.yml b/.github/workflows/lint-pr-title.yml index 7accc3d80..1432224a0 100644 --- a/.github/workflows/lint-pr-title.yml +++ b/.github/workflows/lint-pr-title.yml @@ -10,6 +10,9 @@ on: merge_group: +permissions: + contents: read + jobs: lint-pr-title: permissions: @@ -19,6 +22,11 @@ jobs: runs-on: ubuntu-latest steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + with: + egress-policy: audit + - name: Checkout uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: diff --git a/.github/workflows/lint-shared-workflows.yaml b/.github/workflows/lint-shared-workflows.yaml index 574e856a1..59477ead0 100644 --- a/.github/workflows/lint-shared-workflows.yaml +++ b/.github/workflows/lint-shared-workflows.yaml @@ -14,6 +14,9 @@ on: name: Lint shared-workflows +permissions: + contents: read + jobs: lint: name: Lint all shared workflows @@ -24,6 +27,11 @@ jobs: runs-on: ubuntu-latest steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + with: + egress-policy: audit + - name: Checkout uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: @@ -58,6 +66,11 @@ jobs: options: --user root steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + with: + egress-policy: audit + - name: Checkout uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: diff --git a/.github/workflows/publish-techdocs.yaml b/.github/workflows/publish-techdocs.yaml index 145ca9014..193618ded 100644 --- a/.github/workflows/publish-techdocs.yaml +++ b/.github/workflows/publish-techdocs.yaml @@ -46,6 +46,9 @@ on: default: "ops" type: string +permissions: + contents: read + jobs: generate-and-publish-docs: runs-on: ubuntu-latest @@ -53,6 +56,12 @@ jobs: contents: "read" id-token: "write" steps: + - name: Harden the runner (Audit all outbound calls) + if: ${{ ! github.event.repository.private }} + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + with: + egress-policy: audit + - id: checkout name: Checkout uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9dc04526d..0a87e7ec7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,6 +5,9 @@ on: branches: - main +permissions: + contents: read + jobs: release-please: runs-on: ubuntu-latest @@ -14,6 +17,11 @@ jobs: pull-requests: write # Needed to create release PRs steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + with: + egress-policy: audit + - uses: googleapis/release-please-action@a02a34c4d625f9be7cb89156071d8567266a2445 # v4.2.0 id: release with: diff --git a/.github/workflows/renovate.yml b/.github/workflows/renovate.yml index d5a5e376c..b8dd00998 100644 --- a/.github/workflows/renovate.yml +++ b/.github/workflows/renovate.yml @@ -31,6 +31,9 @@ on: merge_group: +permissions: + contents: read + jobs: renovate: permissions: @@ -44,6 +47,11 @@ jobs: if: github.event.pull_request.head.repo.full_name == github.repository steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + with: + egress-policy: audit + - name: Checkout Code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: diff --git a/.github/workflows/reusable-zizmor.yml b/.github/workflows/reusable-zizmor.yml index 4d20201a1..167386799 100644 --- a/.github/workflows/reusable-zizmor.yml +++ b/.github/workflows/reusable-zizmor.yml @@ -70,6 +70,12 @@ jobs: MIN_CONFIDENCE: ${{ inputs.min-confidence }} steps: + - name: Harden the runner (Audit all outbound calls) + if: ${{ ! github.event.repository.private }} + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + with: + egress-policy: audit + - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml new file mode 100644 index 000000000..dc9ca9144 --- /dev/null +++ b/.github/workflows/scorecards.yml @@ -0,0 +1,82 @@ +# This workflow uses actions that are not certified by GitHub. They are provided +# by a third-party and are governed by separate terms of service, privacy +# policy, and support documentation. + +name: Scorecard supply-chain security +on: + # For Branch-Protection check. Only the default branch is supported. See + # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection + branch_protection_rule: + # To guarantee Maintained check is occasionally updated. See + # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained + schedule: + - cron: "20 7 * * 2" + push: + branches: + - main + +# Declare default permissions as read only. +permissions: read-all + +jobs: + analysis: + name: Scorecard analysis + runs-on: ubuntu-latest + permissions: + # Needed to upload the results to code-scanning dashboard. + security-events: write + # Needed to publish results and get a badge (see publish_results below). + id-token: write + contents: read + actions: read + # To allow GraphQL ListCommits to work + issues: read + pull-requests: read + # To detect SAST tools + checks: read + + steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + with: + egress-policy: audit + + - name: "Checkout code" + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false + + - name: "Run analysis" + uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0 + with: + results_file: results.sarif + results_format: sarif + # (Optional) "write" PAT token. Uncomment the `repo_token` line below if: + # - you want to enable the Branch-Protection check on a *public* repository, or + # - you are installing Scorecards on a *private* repository + # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat. + # repo_token: ${{ secrets.SCORECARD_TOKEN }} + + # Public repositories: + # - Publish results to OpenSSF REST API for easy access by consumers + # - Allows the repository to include the Scorecard badge. + # - See https://github.com/ossf/scorecard-action#publishing-results. + # For private repositories: + # - `publish_results` will always be set to `false`, regardless + # of the value entered here. + publish_results: true + + # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF + # format to the repository Actions tab. + - name: "Upload artifact" + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: SARIF file + path: results.sarif + retention-days: 5 + + # Upload the results to GitHub's code scanning dashboard. + - name: "Upload to code-scanning" + uses: github/codeql-action/upload-sarif@28deaeda66b76a05916b6923827895f2b14ab387 # v3.28.16 + with: + sarif_file: results.sarif diff --git a/.github/workflows/self-zizmor.yml b/.github/workflows/self-zizmor.yml index cd6430ea7..00d7e4dcf 100644 --- a/.github/workflows/self-zizmor.yml +++ b/.github/workflows/self-zizmor.yml @@ -3,6 +3,9 @@ on: push: pull_request: +permissions: + contents: read + jobs: zizmor: name: Run zizmor from current branch (self test) diff --git a/.github/workflows/test-find-pr-for-commit.yml b/.github/workflows/test-find-pr-for-commit.yml index c76f940c1..5dbcacf2b 100644 --- a/.github/workflows/test-find-pr-for-commit.yml +++ b/.github/workflows/test-find-pr-for-commit.yml @@ -49,6 +49,11 @@ jobs: pull-requests: read steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + with: + egress-policy: audit + - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: diff --git a/.github/workflows/test-get-vault-secrets.yaml b/.github/workflows/test-get-vault-secrets.yaml index 065aeda73..671e21b3c 100644 --- a/.github/workflows/test-get-vault-secrets.yaml +++ b/.github/workflows/test-get-vault-secrets.yaml @@ -20,6 +20,9 @@ on: merge_group: +permissions: + contents: read + jobs: test: strategy: @@ -42,6 +45,11 @@ jobs: if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login == 'grafana' steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + with: + egress-policy: audit + - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: @@ -76,6 +84,11 @@ jobs: permissions: contents: read steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + with: + egress-policy: audit + - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: diff --git a/.github/workflows/test-lint-pr-title.yml b/.github/workflows/test-lint-pr-title.yml index 773235855..c451d6e5a 100644 --- a/.github/workflows/test-lint-pr-title.yml +++ b/.github/workflows/test-lint-pr-title.yml @@ -19,6 +19,9 @@ on: merge_group: +permissions: + contents: read + jobs: build-lint-pr-title: runs-on: ubuntu-latest @@ -30,6 +33,11 @@ jobs: working-directory: actions/lint-pr-title steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + with: + egress-policy: audit + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false diff --git a/.github/workflows/test-login-to-gar.yaml b/.github/workflows/test-login-to-gar.yaml index 515813961..cd4cc2b0c 100644 --- a/.github/workflows/test-login-to-gar.yaml +++ b/.github/workflows/test-login-to-gar.yaml @@ -35,6 +35,11 @@ jobs: # Don't run for forks - they don't have access to secrets if: github.event.pull_request.head.repo.full_name == github.repository steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + with: + egress-policy: audit + - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: diff --git a/.github/workflows/test-publish-techdocs.yml b/.github/workflows/test-publish-techdocs.yml index 2de384116..ba3330a96 100644 --- a/.github/workflows/test-publish-techdocs.yml +++ b/.github/workflows/test-publish-techdocs.yml @@ -31,6 +31,9 @@ concurrency: group: "${{ github.workflow }}-${{ github.ref }}" cancel-in-progress: true +permissions: + contents: read + jobs: publish-docs: uses: ./.github/workflows/publish-techdocs.yaml diff --git a/.github/workflows/test-setup-argo.yml b/.github/workflows/test-setup-argo.yml index 449765ef5..c5393d875 100644 --- a/.github/workflows/test-setup-argo.yml +++ b/.github/workflows/test-setup-argo.yml @@ -25,6 +25,9 @@ concurrency: group: "${{ github.workflow }}-${{ github.ref }}" cancel-in-progress: true +permissions: + contents: read + jobs: setup-argo: runs-on: ubuntu-latest @@ -45,6 +48,11 @@ jobs: name: "Setup Argo (cache hit: ${{ matrix.cache-hit }})" steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + with: + egress-policy: audit + - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: diff --git a/.github/workflows/test-setup-jrsonnet.yml b/.github/workflows/test-setup-jrsonnet.yml index 1c5d17f02..bad5403f5 100644 --- a/.github/workflows/test-setup-jrsonnet.yml +++ b/.github/workflows/test-setup-jrsonnet.yml @@ -25,6 +25,9 @@ concurrency: group: "${{ github.workflow }}-${{ github.ref }}" cancel-in-progress: true +permissions: + contents: read + jobs: setup-jrsonnet: runs-on: ubuntu-latest @@ -43,6 +46,11 @@ jobs: name: "Setup Jrsonnet (cache hit: ${{ matrix.cache-hit }})" steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + with: + egress-policy: audit + - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: diff --git a/.github/workflows/test-techdocs-rewrite-relative-links.yaml b/.github/workflows/test-techdocs-rewrite-relative-links.yaml index ddb3f47f5..2e33fcc44 100644 --- a/.github/workflows/test-techdocs-rewrite-relative-links.yaml +++ b/.github/workflows/test-techdocs-rewrite-relative-links.yaml @@ -20,6 +20,9 @@ on: merge_group: +permissions: + contents: read + jobs: test: runs-on: ubuntu-latest @@ -28,6 +31,11 @@ jobs: actions: write # needed for cache steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 + with: + egress-policy: audit + - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..eb8dbc132 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,22 @@ +repos: + - repo: https://github.com/gitleaks/gitleaks + rev: v8.16.3 + hooks: + - id: gitleaks + - repo: https://github.com/golangci/golangci-lint + rev: v1.52.2 + hooks: + - id: golangci-lint + - repo: https://github.com/jumanjihouse/pre-commit-hooks + rev: 3.0.0 + hooks: + - id: shellcheck + - repo: https://github.com/pre-commit/mirrors-eslint + rev: v8.38.0 + hooks: + - id: eslint + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: end-of-file-fixer + - id: trailing-whitespace diff --git a/actions/lint-pr-title/Dockerfile b/actions/lint-pr-title/Dockerfile index c7885c0e7..7b11a9340 100644 --- a/actions/lint-pr-title/Dockerfile +++ b/actions/lint-pr-title/Dockerfile @@ -1,4 +1,4 @@ -FROM oven/bun:1.1.27 AS base +FROM oven/bun:1.1.27@sha256:0bce8e8f0eb41e131df5529fcce89dc8b97135f4a583fa7f28d48cbcdb26ff4e AS base WORKDIR /usr/src/app FROM base AS install