Files
wekan/tests/nodeRuntimeDependency.test.cjs
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

44 lines
2.5 KiB
JavaScript

const { test } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const { spawnSync } = require('node:child_process');
const read = file => fs.readFileSync(file, 'utf8');
test('runtime bundler rejects foreign architectures and preserves licensing', () => {
const result = spawnSync('python3', ['-B', 'tests/bundle-node-runtime.py'], { encoding: 'utf8' });
assert.equal(result.status, 0, result.stdout + result.stderr);
});
test('Docker keeps libatomic outside the removable build dependencies', () => {
const docker = read('Dockerfile');
assert.match(docker, /apt-get install[^\n]*file libatomic1/);
// There is no removable build-dependency list any more (nothing in the image
// is compiled); what must hold is that nothing purges it again.
assert.doesNotMatch(docker, /apt-get (?:remove|purge)[^\n]*libatomic1/);
assert.doesNotMatch((docker.match(/ENV BUILD_DEPS="[^"]*"/) || [''])[0], /libatomic1/);
});
test('native and emulated Linux bundles both package their own runtime', () => {
assert.match(read('releases/embed-verified-node.sh'), /python3 "\$here\/bundle-node-runtime.py" "\$dest" \|\| exit 1/);
const emulated = read('releases/install-node-for-arch.sh');
assert.match(emulated, /apt-install.sh[^\n]*libatomic1/);
assert.match(emulated, /bundle-node-runtime.py" \/bundle\/node/);
const launch = read('releases/ferretdb/start-wekan.sh');
assert.match(launch, /export LD_LIBRARY_PATH="\$DIR\/node-runtime\$\{LD_LIBRARY_PATH:\+:\$LD_LIBRARY_PATH\}"/);
});
test('AppImage and Flatpak require the bundled library and preserve the bundle', () => {
for (const name of ['AppImage', 'Flatpak']) {
const workflow = read(`.github/workflows/${name}.yml`);
// AppImage also wraps the musl bundles, whose Node.js needs no glibc
// libraries; every glibc bundle must still carry node-runtime.
assert.match(workflow, name === 'AppImage'
? /\[ "\$\{MATRIX_MUSL\}" = true \] \|\| required="\$required bundle\/node-runtime\/libatomic\.so\.1"\n\s+for f in \$required/
: /for f in [^\n]*bundle\/node-runtime\/libatomic.so.1/);
assert.match(workflow, /cp -a bundle /);
}
});
test('Sandstorm includes and checks libatomic in its private library tree', () => {
const source = read('sandstorm-src/build-deps.sh');
assert.match(source, /libz.so.1 libatomic.so.1; do/);
assert.match(source, /\[ -f "\$DEPS\/lib\/x86_64-linux-gnu\/libatomic.so.1" \] \|\|/);
assert.match(source, /cp -L \/usr\/share\/doc\/libatomic1\/copyright/);
});