install-node.sh no longer runs `curl https://rpm.nodesource.com/setup_N.x | bash` (an unverified remote script). `pkg-cache-repos.sh nodesource N` writes the same nodesource-nodejs repo (origin URL in the shipped image, gpgcheck=1) with the signing key committed in keys/pkg-cache/RPM-GPG-KEY-nodesource. With PKG_CACHE the repo goes through the internal cache (https://192.168.1.40/nodesource/, origin as 2nd baseurl) and the RUN restores the origin files at the end. The unused N|Solid repo (18/20/22) is no longer added. pkg-cache-repos.sh + keys/pkg-cache synced byte-identical from cloud-apache-container branch ci/pkg-cache-more-upstreams (canonical). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
41 lines
2.0 KiB
Bash
Executable File
41 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Install Node.js <major> from NodeSource, then refuse a build whose version is
|
|
# below the newest security release for that line. NodeSource mirrors can lag
|
|
# a release, and without this check a stale mirror ships a vulnerable image
|
|
# that looks like a normal successful build.
|
|
# usage: install-node.sh <major>
|
|
set -euo pipefail
|
|
major="${1:?usage: install-node.sh <major>}"
|
|
case "$major" in ''|*[!0-9]*) echo "bad Node major: $major" >&2; exit 64;; esac
|
|
|
|
# Minimum acceptable version per line. Raise these when Node.js publishes a
|
|
# security release. 18 and 20 are end of life and get no fixes upstream.
|
|
declare -A MIN=(
|
|
[22]=22.23.4 # 2026-10-20 security release (CVE-2026-111497 Brotli, +9)
|
|
[24]=24.22.1
|
|
[26]=26.12.1
|
|
)
|
|
|
|
# NodeSource repo written by pkg-cache-repos.sh with the signing key committed
|
|
# in keys/pkg-cache/ (replaces `curl setup_N.x | bash`, an unverified remote
|
|
# script). With PKG_CACHE (CI, cache reachable) the repo goes through the
|
|
# internal cache with the origin as 2nd baseurl; the caller's RUN must end with
|
|
# `pkg-cache-repos.sh restore`. RPMs are GPG-checked either way.
|
|
/usr/local/sbin/pkg-cache-repos.sh nodesource "$major"
|
|
dnf install -y nodejs
|
|
# npm 12 dropped Node 18/20; on those lines keep the npm Node ships with
|
|
# (what the old per-version scripts did, silently, before this one failed hard).
|
|
npm install -g npm@latest || echo "WARNING: npm@latest does not support Node $major; keeping bundled npm $(npm --version)" >&2
|
|
|
|
have="$(node -p 'process.versions.node')"
|
|
case "$have" in "$major".*) ;; *) echo "ERROR: wanted Node $major, got $have" >&2; exit 1;; esac
|
|
if [ -n "${MIN[$major]:-}" ]; then
|
|
if [ "$(printf '%s\n%s\n' "${MIN[$major]}" "$have" | sort -V | head -1)" != "${MIN[$major]}" ]; then
|
|
echo "ERROR: Node $have is below the security floor ${MIN[$major]} for line $major (mirror behind?)" >&2
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "WARNING: Node $major is end of life; this image gets no Node.js security fixes." >&2
|
|
fi
|
|
echo "node $have, npm $(npm --version)"
|