mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
Qlty (zizmor) security findings in the workflows that build and publish
every release:
- template-injection (128): ${{ ... }} pasted into a run: script is expanded
before the shell sees it, so a crafted workflow_dispatch input, tag or step
output becomes shell code. 251 expressions in 13 workflows now reach their
scripts through the step's env: and are used as quoted shell variables
($env:NAME in the PowerShell steps); ${{ env.X }} is plain $X. Where a
value sat in single quotes it is double-quoted now, and six unquoted ones
are quoted.
- unpinned-uses (20 in Qlty, 160 with current zizmor): every action is
pinned to a commit, with its version as a comment for Dependabot.
actions/dependency-review-action@v5 was a branch; it is v5.0.0.
- excessive-permissions (8): AppImage, Flatpak, mac, windows,
release-all and release-all-missing grant contents: read at the workflow
level, and each job that writes (a release asset, a git push, the docker
push, gh run rerun) is granted that on the job. Nothing used actions:
write except recover, which keeps it.
- artipacked (47 -> 13): actions/checkout gets persist-credentials: false,
except in the jobs that push with the checkout's credentials, directly or
through releases/version.sh, release-website.sh, release-charts.sh and
backfill-charts.sh.
actionlint with shellcheck reports 50 notes, the 56 before minus the six
quoted. Every PowerShell step parses (pwsh 7.6.7). Not run on GitHub.
tests/workflowHardening.test.cjs fails on an expression in a run script,
an unpinned action, a workflow-level write grant in a multi-job workflow,
or a checkout keeping credentials outside the pushing jobs, and runs
zizmor when it is installed. Eleven guards that pinned the old text, or ran
the extracted scripts with the expressions substituted, now pin the env
form and pass the values as the step's environment.
Thanks to Qlty and xet7 !
172 lines
7.9 KiB
YAML
172 lines
7.9 KiB
YAML
# ─────────────────────────────────────────────────────────────────────────────
|
|
# Publish a variant Docker image — MANUALLY, never as part of a release.
|
|
#
|
|
# wekanteam/wekan-gantt-gpl (and wekanteam/wekan-ondra) are the same WeKan as
|
|
# wekanteam/wekan: the variant repositories are byte-identical to wekan/wekan
|
|
# apart from the snap name in snapcraft.yaml, so the image content is the same
|
|
# image. This workflow therefore does not rebuild anything - it points a variant
|
|
# tag at the multi-arch manifest the release already built and verified, with
|
|
# `docker buildx imagetools create`. Same digests, all five architectures, no
|
|
# half-hour emulated build, and no way for the variant image to drift from the
|
|
# release it claims to be.
|
|
#
|
|
# A RELEASE NO LONGER NEEDS THIS. release-all.yml's docker job tags both variants
|
|
# on all three registries in its own `docker buildx build --push`, so every
|
|
# release publishes them with the release's own digests. What this file is for now
|
|
# is everything outside a release: publishing a variant for a version whose
|
|
# release predates that change, repairing a tag, or pointing a variant at a
|
|
# different version deliberately.
|
|
#
|
|
# `workflow_dispatch` ONLY, on purpose: nothing here runs on a push, a tag or a
|
|
# schedule.
|
|
#
|
|
# If a variant repository ever stops being identical to wekan/wekan, this
|
|
# retag becomes wrong: build that repository's own Dockerfile instead.
|
|
#
|
|
# Local equivalent, same behaviour: releases/docker-publish-variant.sh
|
|
# ─────────────────────────────────────────────────────────────────────────────
|
|
name: Publish variant Docker image (manual)
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
image:
|
|
description: 'Docker Hub repository under wekanteam/ to publish'
|
|
required: true
|
|
default: 'wekan-gantt-gpl'
|
|
type: choice
|
|
options:
|
|
- wekan-gantt-gpl
|
|
- wekan-ondra
|
|
version:
|
|
description: 'WeKan version to publish, without the v (e.g. 10.49). Empty = newest GitHub release.'
|
|
required: false
|
|
default: ''
|
|
type: string
|
|
also_latest:
|
|
description: 'Also move the :latest tag of the variant image'
|
|
required: false
|
|
default: true
|
|
type: boolean
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
retag:
|
|
timeout-minutes: 30
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
# First step on purpose: a missing or wrong credential is then ONE named
|
|
# line at the top of the log, not a failure deep inside a push.
|
|
- name: Check DOCKERHUB_AUTH is configured and works
|
|
env:
|
|
DOCKERHUB_AUTH: ${{ secrets.DOCKERHUB_AUTH }}
|
|
INPUT_IMAGE: ${{ inputs.image }}
|
|
run: |
|
|
set -uo pipefail
|
|
if [ -z "${DOCKERHUB_AUTH:-}" ]; then
|
|
echo "::error::docker-variant: DOCKERHUB_AUTH is not set - the image cannot be pushed. It is base64 of 'username:token' for docker.io."
|
|
exit 1
|
|
fi
|
|
if ! creds="$(printf '%s' "$DOCKERHUB_AUTH" | base64 -d 2>/dev/null)"; then
|
|
echo "::error::docker-variant: DOCKERHUB_AUTH is not valid base64. Set it with: printf '%s' 'user:token' | base64 -w0"
|
|
exit 1
|
|
fi
|
|
case "$creds" in
|
|
*:*) ;;
|
|
*) echo "::error::docker-variant: DOCKERHUB_AUTH decodes to something without a ':' - it must be base64 of 'username:token'."; exit 1 ;;
|
|
esac
|
|
user="${creds%%:*}"
|
|
token="${creds#*:}"
|
|
if ! printf '%s' "$token" | docker login docker.io -u "$user" --password-stdin; then
|
|
echo "::error::docker-variant: DOCKERHUB_AUTH was REJECTED by docker.io (login failed as user '$user'). The token is wrong, expired, or lacks push rights for wekanteam/${INPUT_IMAGE}."
|
|
exit 1
|
|
fi
|
|
echo "docker-variant: DOCKERHUB_AUTH works for docker.io (user '$user')."
|
|
|
|
- name: Work out which version to publish
|
|
id: v
|
|
env:
|
|
INPUT_VERSION: ${{ inputs.version }}
|
|
INPUT_IMAGE: ${{ inputs.image }}
|
|
run: |
|
|
set -euo pipefail
|
|
version="${INPUT_VERSION}"
|
|
if [ -z "$version" ]; then
|
|
# The newest release of wekan/wekan, asked of GitHub rather than guessed.
|
|
version="$(curl -sSL -H 'Accept: application/vnd.github+json' \
|
|
https://api.github.com/repos/wekan/wekan/releases/latest \
|
|
| sed -n 's/.*"tag_name": *"v\{0,1\}\([^"]*\)".*/\1/p' | head -1)"
|
|
fi
|
|
version="${version#v}"
|
|
if [ -z "$version" ]; then
|
|
echo "::error::docker-variant: no version given and the newest release could not be read from the GitHub API."
|
|
exit 1
|
|
fi
|
|
echo "version=$version" >> "$GITHUB_OUTPUT"
|
|
echo "Publishing wekanteam/${INPUT_IMAGE} from wekanteam/wekan:v$version"
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
|
|
|
|
- name: Retag wekanteam/wekan as wekanteam/${{ inputs.image }}
|
|
env:
|
|
STEP_V_VERSION: ${{ steps.v.outputs.version }}
|
|
INPUT_IMAGE: ${{ inputs.image }}
|
|
INPUT_ALSO_LATEST: ${{ inputs.also_latest }}
|
|
run: |
|
|
set -euo pipefail
|
|
src="wekanteam/wekan:v${STEP_V_VERSION}"
|
|
dst="wekanteam/${INPUT_IMAGE}:v${STEP_V_VERSION}"
|
|
|
|
# The source must exist and be the full multi-arch manifest, or the
|
|
# variant tag would quietly cover fewer architectures than wekan does.
|
|
if ! platforms="$(docker buildx imagetools inspect "$src" \
|
|
--format '{{range .Manifest.Manifests}}{{.Platform.OS}}/{{.Platform.Architecture}} {{end}}' 2>&1)"; then
|
|
echo "::error::docker-variant: $src cannot be inspected - is that version released and pushed? ($platforms)"
|
|
exit 1
|
|
fi
|
|
echo "$src covers: $platforms"
|
|
for want in linux/amd64 linux/arm64 linux/ppc64le linux/s390x linux/riscv64; do
|
|
case " $platforms " in
|
|
*" $want "*) ;;
|
|
*) echo "::error::docker-variant: $src has no $want, so the variant image would be missing it too."; exit 1 ;;
|
|
esac
|
|
done
|
|
|
|
tags=(-t "$dst")
|
|
if [ "${INPUT_ALSO_LATEST}" = "true" ]; then
|
|
tags+=(-t "wekanteam/${INPUT_IMAGE}:latest")
|
|
fi
|
|
# imagetools create copies the MANIFEST, so the variant tag points at the
|
|
# very digests the release built and verified. Nothing is rebuilt.
|
|
docker buildx imagetools create "${tags[@]}" "$src"
|
|
|
|
# Pushed is not the same as pushed correctly: ask Docker Hub what it has.
|
|
got="$(docker buildx imagetools inspect "$dst" \
|
|
--format '{{range .Manifest.Manifests}}{{.Platform.OS}}/{{.Platform.Architecture}} {{end}}')"
|
|
echo "$dst covers: $got"
|
|
for want in linux/amd64 linux/arm64 linux/ppc64le linux/s390x linux/riscv64; do
|
|
case " $got " in
|
|
*" $want "*) ;;
|
|
*) echo "::error::docker-variant: $dst is missing $want after the push."; exit 1 ;;
|
|
esac
|
|
done
|
|
echo "OK: $dst published (same digests as $src)."
|
|
|
|
- name: Job result
|
|
if: always()
|
|
env:
|
|
JOB_STATUS: ${{ job.status }}
|
|
INPUT_IMAGE: ${{ inputs.image }}
|
|
run: |
|
|
case "${JOB_STATUS}" in
|
|
success) mark='OK ' ;;
|
|
failure) mark='FAILED ' ;;
|
|
cancelled) mark='CANCELLED' ;;
|
|
*) mark="${JOB_STATUS}" ;;
|
|
esac
|
|
echo "$mark docker-variant wekanteam/${INPUT_IMAGE}"
|
|
echo "$mark docker-variant wekanteam/${INPUT_IMAGE}" >> "$GITHUB_STEP_SUMMARY"
|