feat: add multi-engine regex flavour support

This commit is contained in:
2026-07-27 11:43:51 +02:00
parent 7079cde15f
commit 7f3a91ad37
340 changed files with 643286 additions and 483 deletions

View File

@@ -13,12 +13,13 @@ import { createRequire } from "node:module";
import { fileURLToPath, pathToFileURL } from "node:url";
import { zipSync } from "fflate";
import { checksumLine, sha256 } from "./checksum-release.mjs";
import { assertNoUnexpectedLocalPaths } from "./release-path-hygiene.mjs";
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
const zipEpoch = new Date(1980, 0, 1, 0, 0, 0);
const gplVersion3TextSha256 =
"fb981668c18a279e285fc4d83fba1e836cc84dd4daa73c9697d3cfd2d8aca6e0";
const expectedApplicationVersion = "0.3.0";
const expectedApplicationVersion = "0.4.0";
const requiredRootFiles = [
"LICENSE",
"README.md",
@@ -268,7 +269,18 @@ function scanEntry(entry) {
) {
throw new Error(`Credential-like release path: ${entry.name}`);
}
if (!/\.(?:css|html|js|json|md|svg|txt)$/iu.test(entry.name)) return;
const knownVirtualHomes =
/^(?:assets\/php\.worker-[A-Za-z0-9_-]+\.js|engines\/cpp\/cpp-regex\.mjs|engines\/dotnet\/_framework\/dotnet\.native\.[a-z0-9]+\.js|engines\/perl\/emperl\.js|engines\/php\/engine-metadata\.json|engines\/php\/php-loader\.mjs|engines\/python\/pyodide(?:\.asm)?\.mjs)$/u.test(
entry.name,
)
? ["/home/web_user", "/home/pyodide"]
: [];
assertNoUnexpectedLocalPaths(entry.data, entry.name, {
allowedVirtualHomes: knownVirtualHomes,
});
if (!/\.(?:css|html|js|json|md|mjs|pl|rst|svg|txt)$/iu.test(entry.name)) {
return;
}
const text = entry.data.toString("utf8");
if (/-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/u.test(text)) {
throw new Error(`Private key material detected in ${entry.name}`);
@@ -276,13 +288,6 @@ function scanEntry(entry) {
if (/https?:\/\/[^/@\s]+:[^/@\s]+@/iu.test(text)) {
throw new Error(`Credential-bearing URL detected in ${entry.name}`);
}
if (
/(?:^|[\s"'`])(?:\/home\/|\/mnt\/|\/Users\/|[A-Za-z]:\\Users\\)/mu.test(
text,
)
) {
throw new Error(`Local absolute path detected in ${entry.name}`);
}
}
export function createDeterministicZip(inputEntries) {
@@ -392,20 +397,138 @@ async function collectReleaseEntries() {
"engines/java/SHA256SUMS",
"engines/java/engine-metadata.json",
"engines/java/java-regex.mjs",
"engines/cpp/LICENSE-Emscripten.txt",
"engines/cpp/LICENSE-compiler-rt.txt",
"engines/cpp/LICENSE-libcxx.txt",
"engines/cpp/LICENSE-libcxxabi.txt",
"engines/cpp/LICENSE-libunwind.txt",
"engines/cpp/LICENSE-musl.txt",
"engines/cpp/SHA256SUMS",
"engines/cpp/SOURCE-MANIFEST.json",
"engines/cpp/cpp-regex.mjs",
"engines/cpp/cpp-regex.wasm",
"engines/cpp/engine-metadata.json",
"engines/dotnet/LICENSE-dotnet.txt",
"engines/dotnet/SHA256SUMS",
"engines/dotnet/THIRD-PARTY-NOTICES.txt",
"engines/dotnet/_framework/dotnet.js",
"engines/dotnet/engine-metadata.json",
"engines/go/LICENSE-Go.txt",
"engines/go/SHA256SUMS",
"engines/go/engine-metadata.json",
"engines/go/go-regex.wasm",
"engines/go/wasm_exec.mjs",
"engines/perl/LICENSE-WebPerl-Artistic.txt",
"engines/perl/LICENSE-WebPerl-GPL.txt",
"engines/perl/LICENSE-Devel-StackTrace-Artistic-2.0.txt",
"engines/perl/LICENSE-Emscripten.txt",
"engines/perl/NOTICE.txt",
"engines/perl/SHA256SUMS",
"engines/perl/emperl.data",
"engines/perl/emperl.js",
"engines/perl/emperl.wasm",
"engines/perl/engine-metadata.json",
"engines/perl/perl-runtime.worker.js",
"engines/perl/regex_tools_bridge.pl",
"engines/php/LICENSE.Emscripten-4.0.19.txt",
"engines/php/LICENSE.Oniguruma-6.9.10.txt",
"engines/php/LICENSE.OpenSSL-1.1.1t.txt",
"engines/php/LICENSE.PCRE2-10.44.txt",
"engines/php/LICENSE.PHP-4.0.txt",
"engines/php/LICENSE.PHP-CLI-http-parser-MIT.txt",
"engines/php/LICENSE.PHP-Lexbor-Apache-2.0.txt",
"engines/php/LICENSE.PHP-Zend-2.0.txt",
"engines/php/LICENSE.PHP-bcmath-LGPL-2.1.txt",
"engines/php/LICENSE.PHP-libavifinfo-BSD-2-Clause.txt",
"engines/php/LICENSE.PHP-libmagic-BSD.txt",
"engines/php/LICENSE.PHP-libmbfl-LGPL-2.1.txt",
"engines/php/LICENSE.PHP-timelib-MIT.txt",
"engines/php/LICENSE.PHP-uriparser-BSD-3-Clause.txt",
"engines/php/LICENSE.curl-7.69.1.txt",
"engines/php/LICENSE.ini-ISC.txt",
"engines/php/LICENSE.libaom-3.12.1.txt",
"engines/php/LICENSE.libavif-1.3.0.txt",
"engines/php/LICENSE.libcxx.txt",
"engines/php/LICENSE.libcxxabi.txt",
"engines/php/LICENSE.libgd-2.3.3.txt",
"engines/php/LICENSE.libiconv-1.17-LGPL-2.1.txt",
"engines/php/LICENSE.libjpeg-turbo-3.0.3.txt",
"engines/php/LICENSE.libpng-1.6.39.txt",
"engines/php/LICENSE.libwebp.txt",
"engines/php/LICENSE.libxml2-2.9.10.txt",
"engines/php/LICENSE.libyuv.txt",
"engines/php/LICENSE.libzip-1.9.2.txt",
"engines/php/LICENSE.llvm-compiler-rt.txt",
"engines/php/LICENSE.musl.txt",
"engines/php/LICENSE.php-wasm-GPL-2.0-or-later.txt",
"engines/php/LICENSE.wasm-feature-detect-Apache-2.0.txt",
"engines/php/LICENSE.zlib-1.2.13.txt",
"engines/php/NOTICE.IANA-TZDATA-2026.1.txt",
"engines/php/NOTICE.PHP-Lexbor.txt",
"engines/php/NOTICE.PHP-REDIST-BINS.txt",
"engines/php/NOTICE.PHP-public-domain-hash-code.txt",
"engines/php/NOTICE.SQLite-3.51.0.txt",
"engines/php/NOTICE.dlmalloc-2.8.6.txt",
"engines/php/PATENTS.PHP-libavifinfo.txt",
"engines/php/PATENTS.libaom-3.12.1.txt",
"engines/php/PATENTS.libwebp.txt",
"engines/php/SHA256SUMS",
"engines/php/engine-metadata.json",
"engines/php/native-components.json",
"engines/php/php-loader.mjs",
"engines/php/php.wasm",
"engines/pcre2/LICENSE.txt",
"engines/pcre2/SHA256SUMS",
"engines/pcre2/engine-metadata.json",
"engines/pcre2/pcre2.mjs",
"engines/pcre2/pcre2.wasm",
"engines/python/LICENSE.cpython.txt",
"engines/python/LICENSE.bzip2.txt",
"engines/python/LICENSE.emscripten-mini-lz4.txt",
"engines/python/LICENSE.emscripten.txt",
"engines/python/LICENSE.expat.txt",
"engines/python/LICENSE.hacl-mit.txt",
"engines/python/LICENSE.hiwire.txt",
"engines/python/LICENSE.libffi.txt",
"engines/python/LICENSE.libmpdec.txt",
"engines/python/LICENSE.llvm-compiler-rt.txt",
"engines/python/LICENSE.llvm-libcxx.txt",
"engines/python/LICENSE.llvm-libcxxabi.txt",
"engines/python/LICENSE.llvm-libunwind.txt",
"engines/python/LICENSE.pyodide.txt",
"engines/python/LICENSE.pyodide-stacktrace-vendors.txt",
"engines/python/LICENSE.sqlite.txt",
"engines/python/LICENSE.xz.txt",
"engines/python/LICENSE.zlib.txt",
"engines/python/LICENSE.zstd.txt",
"engines/python/NOTICE.cpython-bundled.rst",
"engines/python/NOTICE.emscripten-dlmalloc.txt",
"engines/python/NOTICE.emscripten-musl.txt",
"engines/python/SHA256SUMS",
"engines/python/SOURCE-MANIFEST.json",
"engines/python/engine-metadata.json",
"engines/python/pyodide-lock.json",
"engines/python/pyodide.asm.mjs",
"engines/python/pyodide.asm.wasm",
"engines/python/pyodide.mjs",
"engines/python/python_stdlib.zip",
"engines/ruby/LICENSE.browser-wasi-shim-Apache-2.0.txt",
"engines/ruby/LICENSE.browser-wasi-shim-MIT.txt",
"engines/ruby/LICENSE.ruby-wasm.txt",
"engines/ruby/LICENSE.tslib.txt",
"engines/ruby/NOTICE.txt",
"engines/ruby/SHA256SUMS",
"engines/ruby/engine-metadata.json",
"engines/ruby/ruby.wasm",
"engines/rust/LICENSE-Apache-2.0.txt",
"engines/rust/LICENSE-MIT.txt",
"engines/rust/LICENSE-Unicode-3.0.txt",
"engines/rust/RUST-STDLIB-COPYRIGHT.html",
"engines/rust/SHA256SUMS",
"engines/rust/THIRD_PARTY_LICENSES.txt",
"engines/rust/engine-metadata.json",
"engines/rust/rust-regex.mjs",
"engines/rust/rust-regex_bg.wasm",
"LICENSES/Emscripten-MIT.txt",
"LICENSES/PCRE2.txt",
"LICENSES/build/rolldown-1.1.5/LICENSE",
@@ -418,6 +541,18 @@ async function collectReleaseEntries() {
if (![...names].some((name) => name.startsWith("assets/"))) {
throw new Error("Release has no production assets.");
}
for (const requiredDotNetPattern of [
/^engines\/dotnet\/_framework\/RegexTools\.DotNet\..+\.wasm$/u,
/^engines\/dotnet\/_framework\/System\.Text\.RegularExpressions\..+\.wasm$/u,
/^engines\/dotnet\/_framework\/dotnet\.native\..+\.wasm$/u,
/^engines\/dotnet\/_framework\/dotnet\.runtime\..+\.js$/u,
]) {
if (![...names].some((name) => requiredDotNetPattern.test(name))) {
throw new Error(
`Required .NET runtime asset is missing: ${requiredDotNetPattern}`,
);
}
}
if (![...names].some((name) => name.startsWith("LICENSES/"))) {
throw new Error("Release has no third-party licence directory.");
}