1
0
mirror of https://github.com/sredevopsorg/deepseek-kubernetes-sandbox.git synced 2026-11-03 01:13:24 +00:00

fix(ci): harden workflow token scope and download integrity (#39)

Security audit of .github/workflows found a script-injection vector in the
release workflow, over-broad token grants on non-publishing jobs, and
downloaded tooling/manifests executed without integrity checks.

- release: pass the tag/dispatch input through env instead of interpolating
  it into the validation script; default workflow permissions to contents:read
- build-main/build-gateway: grant write scopes only to the build job
- _build-image/codeql: stop persisting checkout credentials
- ci/release: verify actionlint, hadolint and git-cliff against pinned SHA-256s
- ci-manifests/e2e: verify upstream CRD manifests against versions.env pins
- e2e: redact token material before uploading cluster diagnostics
- docs: add workflow-security.md with controls, audit record and residual
  repository-setting recommendations

Co-authored-by: SREDevOpsAgents <agents@sredevops.org>
This commit is contained in:
SREDevOps.org Agent
2026-10-30 15:16:51 -03:00
committed by GitHub
parent 4c073eef71
commit 2f959e6afb
11 changed files with 125 additions and 20 deletions

View File

@@ -17,11 +17,10 @@ on:
required: true
type: string
# Read-only by default; the build and publish jobs add the write scopes they
# need as job-level grants.
permissions:
contents: write
packages: write
id-token: write
attestations: write
contents: read
concurrency:
group: release-${{ github.ref }}
@@ -51,13 +50,17 @@ jobs:
- name: Validate tag against versions.env
id: meta
shell: bash
env:
# Passed through the environment, never interpolated into the script:
# a tag name or dispatch input can contain shell metacharacters.
REQUESTED_TAG: ${{ inputs.tag || github.ref_name }}
run: |
set -euo pipefail
set -a
# shellcheck disable=SC1091
source versions.env
set +a
tag="${{ inputs.tag || github.ref_name }}"
tag="$REQUESTED_TAG"
identity="$DSH_VERSION"
[ -z "$RELEASE_REVISION" ] || identity="$DSH_VERSION-$RELEASE_REVISION"
if [ "$tag" != "$identity" ]; then
@@ -205,11 +208,17 @@ jobs:
- name: Install git-cliff
env:
GIT_CLIFF_VERSION: v2.14.2
# SHA-256 of git-cliff-2.14.2-x86_64-unknown-linux-gnu.tar.gz; upstream
# publishes the matching SHA-512 next to the asset. Update with the version.
GIT_CLIFF_SHA256: 24f397c733add5390fdceee3a2088588ab0d5f944ce00d34cb7029b888cf2db4
run: |
set -euo pipefail
version="${GIT_CLIFF_VERSION#v}"
curl -fsSL -o /tmp/git-cliff.tar.gz "https://github.com/orhun/git-cliff/releases/download/$GIT_CLIFF_VERSION/git-cliff-$version-x86_64-unknown-linux-gnu.tar.gz"
tar -xzf /tmp/git-cliff.tar.gz -C /tmp
asset="git-cliff-${version}-x86_64-unknown-linux-gnu.tar.gz"
curl -fsSL --proto '=https' -o "/tmp/$asset" \
"https://github.com/orhun/git-cliff/releases/download/$GIT_CLIFF_VERSION/$asset"
printf '%s %s\n' "$GIT_CLIFF_SHA256" "/tmp/$asset" | sha256sum -c -
tar -xzf "/tmp/$asset" -C /tmp
install -m 0755 "/tmp/git-cliff-$version/git-cliff" /usr/local/bin/git-cliff
git-cliff --version