Files
wekan/.github/workflows/android.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

196 lines
7.7 KiB
YAML

name: Android bundles
# WeKan on Android, for Termux: the published Linux bundle of each CPU,
# rebuilt inside Termux's own image (real Bionic and Android clang, the ARM
# ones on ARM runners) by releases/android/build-bundle.sh with wekan/
# node-patches' node-android-<cpu> of the same version, then started and
# required to answer HTTP 200. The same pattern as the musl and BSD bundles.
# A target whose Linux bundle, or whose Android Node.js, is not published yet
# is SKIPPED, not failed, and builds by itself once it is.
on:
workflow_dispatch:
inputs:
tag:
description: 'Existing WeKan release tag (empty = latest published release)'
type: string
required: false
publish:
description: 'Attach the Android bundles and checksums to that release'
type: boolean
default: true
only:
description: 'JSON target list, e.g. ["android-arm64"] (empty = all)'
type: string
default: ''
workflow_call:
inputs:
tag:
type: string
required: true
publish:
type: boolean
default: true
only:
type: string
default: ''
permissions:
contents: read
concurrency:
group: wekan-android-${{ inputs.tag || github.ref }}
cancel-in-progress: false
jobs:
plan:
runs-on: ubuntu-24.04
timeout-minutes: 10
outputs:
tag: ${{ steps.plan.outputs.tag }}
matrix: ${{ steps.plan.outputs.matrix }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- id: plan
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ inputs.tag }}
ONLY: ${{ inputs.only }}
run: |
set -euo pipefail
tag="${TAG:-$(gh release view --repo "$GITHUB_REPOSITORY" --json tagName -q .tagName)}"
echo "tag=$tag" >> "$GITHUB_OUTPUT"
matrix="$(python3 -c '
import json, os
targets = json.load(open("releases/android/targets.json"))
only = json.loads(os.environ.get("ONLY") or "[]")
if only:
targets = [t for t in targets if t["target"] in only]
print(json.dumps({"include": targets}))')"
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
echo "Release $tag; targets: $matrix"
build:
needs: plan
name: Android ${{ matrix.target }}
runs-on: ${{ matrix.runner }}
# 32-bit ARM runs on the arm64 runner only when its kernel can; a target
# that cannot run there must not fail the others.
continue-on-error: ${{ matrix.tolerate_failure || false }}
timeout-minutes: 150
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.plan.outputs.matrix) }}
env:
TAG: ${{ needs.plan.outputs.tag }}
TARGET: ${{ matrix.target }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Fetch and verify the Linux bundle and the Android Node.js
id: fetch
env:
GH_TOKEN: ${{ github.token }}
BASE: ${{ matrix.base }}
run: |
set -euo pipefail
version="${TAG#v}"
zip="wekan-${version}-${BASE}.zip"
if ! gh release download "$TAG" --repo "$GITHUB_REPOSITORY" --pattern "$zip" --pattern "$zip.sha256sum" || [ ! -f "$zip" ]; then
echo "::notice::$TARGET: $TAG has no $zip; skipped."
echo "skip=true" >> "$GITHUB_OUTPUT"; exit 0
fi
[ -f "$zip.sha256sum" ] || { echo "::error::$zip has no published .sha256sum; a bundle is never rebuilt from an unverified one."; exit 1; }
sha256sum -c "$zip.sha256sum"
unzip -q "$zip"
rm -f "$zip" "$zip.sha256sum"
node_version="$(grep -aoE 'nodejs\.org/download/release/v[0-9]+\.[0-9]+\.[0-9]+/' bundle/node | head -n1 | sed -E 's#.*/(v[0-9.]+)/#\1#')"
[ -n "$node_version" ] || { echo "::error::Could not read the Node.js version of bundle/node."; exit 1; }
rc=0; out="$(bash releases/resolve-node-source.sh "$TARGET" "$node_version")" || rc=$?
if [ "$rc" = 3 ] || ! printf '%s\n' "$out" | grep -q '^node_found=true'; then
echo "::notice::$TARGET: wekan/node-patches has no node-$TARGET for $node_version yet; skipped."
echo "skip=true" >> "$GITHUB_OUTPUT"; exit 0
fi
eval "$(printf '%s\n' "$out" | grep -E '^node_(url|sha256|kind|member)=')"
mkdir -p android-tools
bash releases/fetch.sh -o android-node.download "$node_url"
[ -n "$node_sha256" ] || { echo "::error::$node_url has no published SHA256."; exit 1; }
echo "$node_sha256 android-node.download" | sha256sum -c -
case "$node_kind" in
binary) mv android-node.download android-tools/node ;;
tar.xz) tar -xJf android-node.download -C android-tools && mv "android-tools/$node_member" android-tools/node && rm -f android-node.download ;;
*) echo "::error::unexpected Android Node.js kind: $node_kind"; exit 1 ;;
esac
chmod +x android-tools/node
file android-tools/node bundle/ferretdb
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Rebuild and start it in Termux
if: steps.fetch.outputs.skip != 'true'
env:
TERMUX_ARCH: ${{ matrix.termux_arch }}
ARCH: ${{ matrix.arch }}
run: |
# Termux's entrypoint clears the Docker environment when it switches
# to its unprivileged user, so the values go after the switch (as
# bun.yml does), and that user needs a writable bind mount.
chmod -R a+rwX .
docker run --rm --security-opt seccomp=unconfined -v "$PWD:/work" -w /work \
"termux/termux-docker:$TERMUX_ARCH" env "ARCH=$ARCH" DO_NOT_TRACK=1 bash -ec '
apt-get update
apt-get install -y nodejs-lts python make clang pkg-config libvips curl procps file
bash releases/android/build-bundle.sh "$ARCH"'
- name: Package
if: steps.fetch.outputs.skip != 'true'
env:
VERSION: ${{ steps.fetch.outputs.version }}
run: |
set -euo pipefail
sudo chown -R "$(id -u):$(id -g)" bundle
out="wekan-${VERSION}-${TARGET}.zip"
zip -qry "$out" bundle
sha256sum "$out" > "$out.sha256sum"
ls -la "$out" "$out.sha256sum"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: steps.fetch.outputs.skip != 'true'
with:
name: android-${{ matrix.target }}
path: wekan-*-${{ matrix.target }}.zip*
retention-days: 3
compression-level: 0
publish:
needs: [plan, build]
if: ${{ !cancelled() && inputs.publish }}
runs-on: ubuntu-24.04
timeout-minutes: 60
permissions:
contents: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
pattern: android-*
path: artifacts
- name: Attach every Android bundle that was built and started
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ needs.plan.outputs.tag }}
run: |
set -euo pipefail
shopt -s nullglob
published=0
for f in artifacts/android-*/wekan-*.zip; do
(cd "$(dirname "$f")" && sha256sum -c "$(basename "$f").sha256sum")
bash releases/github-release-upload.sh "$GITHUB_REPOSITORY" "$TAG" "$f" "$f.sha256sum"
published=$((published + 1))
done
echo "Published $published Android bundles to $TAG."