Files
wekan/tests/packagedStartupConfiguration.test.cjs
T
Lauri Ojansivu 130af564c9 Docker image: distroless, with a Node.js entrypoint and no shell.
Artifact Hub's Trivy report of v13.30 listed 218 vulnerabilities in
ghcr.io/wekan/wekan, 214 of them in Debian packages WeKan never runs
(util-linux, login, tar, coreutils, systemd libraries, sqlite) with no
Debian fix to update to. The image is now gcr.io/distroless/cc-debian13
plus libatomic1, node, WeKan, FerretDB and the MongoDB tools; that base
scans at 55 findings, 2 HIGH. Distroless publishes no linux/386, so for
386 the same Debian 13 packages are assembled into scratch, each with
its dpkg record; the release workflow reads both bases from the
Dockerfile and the image keeps all seven platforms. The wekan user
stays 999:999.

With no shell, releases/ferretdb/wekan-entrypoint.mjs replaces
wekan-entrypoint.sh, with the same decisions, exported and tested. It
runs sqlite-recovery.mjs with its own node: the shell entrypoint ran
/build/node, which the image never had, so every start with the bundled
FerretDB stopped with status 127 since v11.52. It also makes cpu-exec's
qemu-user decision itself. The UCS migration launcher and tools, the
UCS hook's volume preparation (ucs-release.py), the MongoDB tool
launchers (symlinks to mongo-tools) and the Nextcloud capability check
run node instead of sh.

Thanks to xet7 !
2026-11-25 00:32:06 +02:00

56 lines
2.2 KiB
JavaScript

'use strict';
// Automatic network-interface and free-port discovery caused packaged startup
// failures. Packaged targets use explicit configuration again; their launchers
// may provide stable localhost defaults, but must not rewrite endpoints from the
// machine's current interfaces or occupied ports.
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const root = path.resolve(__dirname, '..');
const read = rel => fs.readFileSync(path.join(root, rel), 'utf8');
const launchers = [
'.github/workflows/AppImage.yml',
'.github/workflows/release-all.yml',
'.github/workflows/windows.yml',
'Dockerfile',
'releases/ferretdb/start-wekan.sh',
'releases/ferretdb/start-wekan.bat',
'releases/ferretdb/wekan-entrypoint.mjs',
'snap-src/bin/ferretdb-control',
'snap-src/bin/wekan-control',
'snap/hooks/configure',
'snapcraft.yaml',
];
for (const rel of launchers) {
assert.doesNotMatch(read(rel), /startup-network|AUTO_ROOT_URL|AUTO_PORT/,
`${rel} must not invoke automatic endpoint discovery`);
}
assert.equal(fs.existsSync(path.join(root, 'releases/ferretdb/startup-network.cjs')), false,
'bundles must not ship the automatic endpoint detector');
assert.equal(fs.existsSync(path.join(root, 'snap-src/bin/startup-network')), false,
'the Snap must not ship the automatic endpoint detector');
const shell = read('releases/ferretdb/start-wekan.sh');
assert.match(shell, /PORT="\$\{PORT:-8080\}"/,
'the Unix bundle retains its documented stable default');
assert.match(shell, /ROOT_URL="\$\{ROOT_URL:-http:\/\/localhost:\$PORT\}"/,
'an explicit ROOT_URL remains authoritative');
const batch = read('releases/ferretdb/start-wekan.bat');
assert.match(batch, /if not defined PORT set "PORT=8080"/);
assert.match(batch, /if not defined ROOT_URL set "ROOT_URL=http:\/\/localhost:%PORT%"/);
for (const rel of fs.readdirSync(root).filter(name => /^docker-compose.*\.yml$/.test(name))) {
const compose = read(rel);
assert.doesNotMatch(compose, /AUTO_ROOT_URL|AUTO_PORT|startup-network/,
`${rel} must use its declared environment instead of discovery`);
}
console.log('packagedStartupConfiguration: explicit endpoints and stable defaults passed');