Files
wekan/.github/workflows/ucs.yml
T
Lauri Ojansivu 7f7cc63cde GitHub Actions: no expressions in scripts, actions pinned, least privilege.
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 !
2026-10-15 23:19:50 +03:00

142 lines
6.2 KiB
YAML

name: UCS App Center
run-name: UCS ${{ inputs.version || 'latest' }}
on:
workflow_dispatch:
inputs:
version:
description: 'WeKan release version without v; leave empty for latest published release'
required: false
type: string
permissions:
contents: read
# This publisher is started separately with workflow_dispatch. Do not race
# creation of a portal version or overwrite an image built by another attempt.
concurrency:
group: wekan-ucs-publish
cancel-in-progress: false
jobs:
publish:
runs-on: ubuntu-latest
timeout-minutes: 45
env:
VERSION: ${{ inputs.version }}
UCS_SOURCE_APP: ${{ vars.UCS_SOURCE_APP }}
UCS_TARGET_UCS: ${{ vars.UCS_TARGET_UCS }}
steps:
- name: Check UCS publishing configuration
id: config
env:
PROVIDER_USER: ${{ secrets.UNIVENTION_APP_PROVIDER_USER }}
PROVIDER_PASSWORD: ${{ secrets.UNIVENTION_APP_PROVIDER_PASSWORD }}
run: |
set -eu
if [ -z "$PROVIDER_USER" ] || [ -z "$PROVIDER_PASSWORD" ] || [ -z "$UCS_SOURCE_APP" ] || [ -z "$UCS_TARGET_UCS" ]; then
echo '::notice::UCS publishing not configured. See docs/Platforms/FOSS/Container/Docker/UCS/UCS-upgrades.md.'
echo 'enabled=false' >> "$GITHUB_OUTPUT"
else
echo 'enabled=true' >> "$GITHUB_OUTPUT"
fi
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
if: steps.config.outputs.enabled == 'true'
- name: Resolve published WeKan and FerretDB versions
if: steps.config.outputs.enabled == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
mkdir -p "$GITHUB_WORKSPACE/.tools/tmp"
echo "TMPDIR=$GITHUB_WORKSPACE/.tools/tmp" >> "$GITHUB_ENV"
if [ -n "$VERSION" ]; then
python3 -c 'import sys; sys.path.insert(0,"releases"); import importlib; importlib.import_module("ucs-release").version(sys.argv[1])' "$VERSION"
gh release view "v$VERSION" --repo wekan/wekan --json tagName,isDraft,isPrerelease > .tools/tmp/ucs-wekan-release.json
else
gh release view --repo wekan/wekan --json tagName,isDraft,isPrerelease > .tools/tmp/ucs-wekan-release.json
fi
gh release view --repo wekan/FerretDB --json tagName,isDraft,isPrerelease > .tools/tmp/ucs-ferretdb-release.json
python3 releases/ucs-release.py resolve \
--wekan-release .tools/tmp/ucs-wekan-release.json \
--ferretdb-release .tools/tmp/ucs-ferretdb-release.json
- name: Report selected versions
if: steps.config.outputs.enabled == 'true'
run: |
printf 'WeKan: ghcr.io/wekan/wekan:v%s\nFerretDB: %s\nUCS section: %s\n' \
"$VERSION" "$UCS_FERRETDB_IMAGE" "$UCS_TARGET_UCS" >> "$GITHUB_STEP_SUMMARY"
- name: Get the official Provider Portal CLI
if: steps.config.outputs.enabled == 'true'
run: |
bash releases/fetch.sh -o .tools/univention-appcenter-control \
https://provider-portal.software-univention.de/appcenter-selfservice/univention-appcenter-control
# The official CLI imports distutils.version (Python 3.12 removed it).
python3 -m pip install 'setuptools==80.9.0'
python3 .tools/univention-appcenter-control upload --help
- name: Check whether UCS already published this version
id: portal
if: steps.config.outputs.enabled == 'true'
env:
UNIVENTION_APP_PROVIDER_USER: ${{ secrets.UNIVENTION_APP_PROVIDER_USER }}
UNIVENTION_APP_PROVIDER_PASSWORD: ${{ secrets.UNIVENTION_APP_PROVIDER_PASSWORD }}
run: python3 releases/ucs-release.py plan --version "$VERSION"
- name: Checkout the app definition
if: steps.config.outputs.enabled == 'true' && steps.portal.outputs.skip != 'true'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: wekan/univention
ref: master
path: univention
persist-credentials: false
- name: Prepare versioned compose and migration hook
id: prepare
if: steps.config.outputs.enabled == 'true' && steps.portal.outputs.skip != 'true'
run: python3 releases/ucs-release.py prepare --version "$VERSION"
# The standard WeKan release already published the migration tools inside
# the app image on Docker Hub, GHCR and Quay. upload checks anonymous pulls
# with mirror fallback and runs start.sh --check before any portal write.
- name: Upload or finish the UCS portal draft
id: upload
if: steps.config.outputs.enabled == 'true' && steps.portal.outputs.skip != 'true'
env:
UNIVENTION_APP_PROVIDER_USER: ${{ secrets.UNIVENTION_APP_PROVIDER_USER }}
UNIVENTION_APP_PROVIDER_PASSWORD: ${{ secrets.UNIVENTION_APP_PROVIDER_PASSWORD }}
run: python3 releases/ucs-release.py upload --version "$VERSION"
- name: Keep the exact submitted app definition
if: steps.upload.outputs.result == 'uploaded'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: ucs-${{ env.VERSION }}
path: .tools/ucs-release/component
- name: Report UCS result
if: always()
env:
ENABLED: ${{ steps.config.outputs.enabled }}
EXISTING: ${{ steps.portal.outputs.result }}
UPLOADED: ${{ steps.upload.outputs.result }}
RESULT: ${{ job.status }}
run: |
if [ "$ENABLED" != true ]; then
echo 'UCS: not configured; no upload attempted.' >> "$GITHUB_STEP_SUMMARY"
elif [ "$RESULT" != success ]; then
echo 'UCS: FAILED. See this job; portal publication was not verified.' >> "$GITHUB_STEP_SUMMARY"
elif [ "$EXISTING" = published ]; then
echo 'UCS: already published; left unchanged.' >> "$GITHUB_STEP_SUMMARY"
elif [ "$UPLOADED" = uploaded ]; then
echo 'UCS: draft uploaded and read back. UCS testing and provider/Univention approval remain.' >> "$GITHUB_STEP_SUMMARY"
else
echo 'UCS: no verified upload.' >> "$GITHUB_STEP_SUMMARY"
fi