fix: patch production dependencies and add release validation

This commit is contained in:
whyour committed 2026-10-10 01:16:07 +08:00
1 parent 68ffa106f8
commit 5038d2d9a0
5 files changed
+804 -452

No files matched your search

+149
View File
@@ -0,0 +1,149 @@
name: Release readiness
on:
pull_request:
paths:
- '.github/workflows/release-readiness.yml'
workflow_dispatch:
permissions:
contents: read
concurrency:
group: release-readiness-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
regression:
uses: ./.github/workflows/validate.yml
static:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- uses: pnpm/action-setup@v6
with:
version: '8.3.1'
- uses: actions/setup-node@v6
with:
node-version: '20'
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm audit --prod --audit-level high
- run: pnpm build:front && pnpm build:back && pnpm build:info
- uses: actions/upload-artifact@v6
with:
name: release-readiness-static
path: static/
include-hidden-files: true
if-no-files-found: error
sqlite-install:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- uses: pnpm/action-setup@v6
with:
version: '8.3.1'
- uses: actions/setup-node@v6
with:
node-version: '20'
cache: pnpm
- run: pnpm install --prod --frozen-lockfile
- name: Verify precompiled SQLite and production protocols
run: node scripts/verify-production-dependencies.cjs
- name: Rebuild SQLite from source
env:
npm_config_build_from_source: 'true'
PYTHON: /usr/bin/python3
run: |
export npm_config_node_gyp="$(node -p 'require("node:module").createRequire(require.resolve("sqlite3/package.json")).resolve("node-gyp/bin/node-gyp.js")')"
pnpm rebuild @whyour/sqlite3
- name: Verify source-built SQLite and production protocols
run: node scripts/verify-production-dependencies.cjs
images:
needs: [regression, static, sqlite-install]
runs-on: ubuntu-22.04
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
- image: alpine
file: docker/Dockerfile
cache: alpine
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x,linux/386
- image: debian
file: docker/Dockerfile.debian
cache: debian
platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
- image: alpine-python3.10
file: docker/Dockerfile.310
cache: alpine-python3.10
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x,linux/386
- image: debian-python3.10
file: docker/Dockerfile.debian310
cache: debian-python3.10
platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Record source
id: source
env:
SOURCE_URL: ${{ github.event.pull_request.head.repo.clone_url || format('https://github.com/{0}.git', github.repository) }}
SOURCE_BRANCH: ${{ github.head_ref || github.ref_name }}
run: |
echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
echo "url=$SOURCE_URL" >> "$GITHUB_OUTPUT"
echo "branch=$SOURCE_BRANCH" >> "$GITHUB_OUTPUT"
- uses: actions/download-artifact@v7
with:
name: release-readiness-static
path: static/
- uses: docker/setup-qemu-action@v4
with:
cache-image: false
- uses: docker/setup-buildx-action@v4
- name: Build every release architecture
uses: docker/build-push-action@v7
with:
context: .
file: ${{ matrix.file }}
platforms: ${{ matrix.platforms }}
build-args: |
QL_URL=${{ steps.source.outputs.url }}
QL_BRANCH=${{ steps.source.outputs.branch }}
SOURCE_COMMIT=${{ steps.source.outputs.sha }}
push: false
provenance: false
sbom: false
cache-from: type=registry,ref=whyour/qinglong:cache-${{ matrix.cache }}
- name: Load native image for runtime verification
uses: docker/build-push-action@v7
with:
context: .
file: ${{ matrix.file }}
platforms: linux/amd64
build-args: |
QL_URL=${{ steps.source.outputs.url }}
QL_BRANCH=${{ steps.source.outputs.branch }}
SOURCE_COMMIT=${{ steps.source.outputs.sha }}
tags: qinglong-readiness:${{ matrix.image }}
load: true
push: false
provenance: false
sbom: false
- name: Verify native production runtime without external networking
run: |
docker run --rm --network none --entrypoint node \
qinglong-readiness:${{ matrix.image }} \
scripts/verify-production-dependencies.cjs
@@ -0,0 +1,35 @@
# Production dependency validation
Date: 2026-10-10. Source baseline: `68ffa106f80a2080ddd9b48affe0d7a7489e4d05` on `develop`.
The baseline frozen production lockfile reported 4 Critical, 48 High, 56 Moderate and 14 Low advisory matches across 410 dependencies. After the targeted updates, `pnpm audit --prod --json` reports zero matches at every severity across 368 dependencies. These counts describe the dependency advisory database at the time of verification; they are not a replacement for application security review.
## Changes
- Update the HTTP parser, compression, upload, YAML, Lodash, Sequelize, gRPC and Undici dependencies to patched versions while retaining their supported release lines. Use Undici 7 for the existing Node 20 runtime, rather than Undici 8's newer Node requirement.
- Upgrade Nodemailer to 10.0.16, including the address parser and OAuth2 TLS fixes. Nodemailer 10 requires Node 20; backend type checking and local message generation are included in validation.
- Pin patched indirect dependencies with scoped pnpm overrides. Keep old path-to-regexp, Joi, brace-expansion, picomatch and Undici consumers on compatible release lines.
- Remove the unused direct `http-proxy-middleware` production dependency. There are no imports or calls in the backend, frontend, CLI or shell sources. This removes its `micromatch -> braces` chain from the production graph; braces 3.0.3 has no upstream patch. Umi's development proxy remains managed by Umi's own development dependencies.
- Upgrade the SQLite installation chain to `@mapbox/node-pre-gyp@2.0.3` and `tar@7.5.22`. Retain the existing `@whyour/sqlite3@1.1.2` binary package and N-API ABI. The SQLite source extractor uses the supported synchronous `tar.extract` API.
- Replace nested UUID 8 with UUID 11.1.1 for Sequelize and SockJS. Database transactions and a real SockJS/WebSocket exchange verify their production use of the UUID API.
No advisory ignore list or risk acceptance exception was added. Development dependencies are outside the production audit claim.
## Local verification
- Independent Node 20.20.2 installation using the frozen lockfile; no shared node_modules.
- SQLite precompiled download and extraction through the upgraded node-pre-gyp/tar chain succeeded on macOS arm64.
- Forced SQLite source compilation using node-gyp 12.4.0 succeeded on macOS arm64, followed by the same production protocol checks. The local SDK required its C++ include directory to be supplied explicitly; no global toolchain setting was changed.
- Complete regression: 497 passed, 7 platform-dependent skips, zero failures.
- Backend TypeScript and frontend production builds passed. The existing frontend bundle-size advisory remains.
- `scripts/verify-production-dependencies.cjs` exercises real SQLite reads, Sequelize transactions and updates, protobuf serialization, a local gRPC request, a local SockJS/WebSocket exchange, the Undici ProxyAgent API, JWT signature verification and Nodemailer message generation. Mail uses an in-memory transport; it does not contact recipients or an SMTP service.
## Release verification
The `Release readiness` workflow builds the same four Dockerfile variants and all 24 variant/architecture combinations used by the release workflow, including both Python 3.10 variants. It uses the candidate source SHA and the candidate static artifact, then loads each amd64 image and runs the production dependency check inside it with external networking disabled.
A separate Linux job tests both precompiled SQLite installation and forced source compilation using the SQLite package's declared node-gyp, rather than pnpm 8's bundled older node-gyp. This distinction matters on Python 3.12 and newer.
The workflow does not push images, tags, npm packages, CDN metadata or static mirrors. It runs when a pull request introduces or changes the readiness workflow; subsequent candidates can invoke it manually. A successful run is required evidence for this dependency update, not evidence that a formal version has already been published.
Linux source compilation and the complete image matrix still require CI confirmation; results will be recorded after the candidate run completes.
+33 -13
View File
@@ -74,20 +74,41 @@
"overrides": { "overrides": {
"sqlite3": "npm:@whyour/sqlite3@1.1.2", "sqlite3": "npm:@whyour/sqlite3@1.1.2",
"@codemirror/state": "6.5.4", "@codemirror/state": "6.5.4",
"@codemirror/view": "6.39.16" "@codemirror/view": "6.39.16",
"@mapbox/node-pre-gyp": "2.0.3",
"tar": "7.5.22",
"protobufjs": "7.6.6",
"websocket-driver": "0.7.5",
"proxy-addr": "2.0.8",
"validator": "13.15.35",
"jws@3": "3.2.3",
"path-to-regexp@<1": "0.1.13",
"brace-expansion@1": "1.1.21",
"picomatch@2": "2.3.2",
"undici@6": "6.29.0",
"joi@17": "17.13.8",
"qs": "6.16.0",
"dottie": "2.0.7",
"@protobufjs/utf8": "1.1.2",
"moment": "2.31.0",
"on-headers": "1.1.0",
"follow-redirects": "1.16.0",
"lodash": "4.18.1",
"body-parser@1": "1.20.6",
"uuid@8": "11.1.1"
} }
}, },
"dependencies": { "dependencies": {
"@ant-design/plots": "^2.6.8", "@ant-design/plots": "^2.6.8",
"@bufbuild/protobuf": "^2.10.0", "@bufbuild/protobuf": "^2.10.0",
"@grpc/grpc-js": "^1.14.0", "@grpc/grpc-js": "^1.14.6",
"@grpc/proto-loader": "^0.8.0", "@grpc/proto-loader": "^0.8.0",
"@keyv/sqlite": "^4.0.1", "@keyv/sqlite": "^4.0.1",
"@otplib/preset-default": "^12.0.1", "@otplib/preset-default": "^12.0.1",
"body-parser": "^1.20.3", "body-parser": "^1.20.6",
"celebrate": "^15.0.3", "celebrate": "^15.0.3",
"chokidar": "^4.0.1", "chokidar": "^4.0.1",
"compression": "^1.7.4", "compression": "^1.8.2",
"cors": "^2.8.5", "cors": "^2.8.5",
"cron-parser": "^5.4.0", "cron-parser": "^5.4.0",
"cross-spawn": "^7.0.6", "cross-spawn": "^7.0.6",
@@ -99,28 +120,27 @@
"express-urlrewrite": "^2.0.3", "express-urlrewrite": "^2.0.3",
"helmet": "^8.1.0", "helmet": "^8.1.0",
"hpagent": "^1.2.0", "hpagent": "^1.2.0",
"http-proxy-middleware": "^3.0.3",
"iconv-lite": "^0.6.3", "iconv-lite": "^0.6.3",
"ip2region": "2.3.0", "ip2region": "2.3.0",
"js-yaml": "^4.1.0", "js-yaml": "^4.3.2",
"jsonwebtoken": "^9.0.2", "jsonwebtoken": "^9.0.2",
"keyv": "^5.2.3", "keyv": "^5.2.3",
"lodash": "^4.17.21", "lodash": "^4.18.1",
"multer": "2.1.1", "multer": "2.4.0",
"node-cron": "4.6.0", "node-cron": "4.6.0",
"nodemailer": "^8.0.1", "nodemailer": "^10.0.16",
"p-queue-cjs": "7.3.4", "p-queue-cjs": "7.3.4",
"proper-lockfile": "^4.1.2", "proper-lockfile": "^4.1.2",
"ps-tree": "^1.2.0", "ps-tree": "^1.2.0",
"reflect-metadata": "^0.2.2", "reflect-metadata": "^0.2.2",
"request-ip": "3.3.0", "request-ip": "3.3.0",
"sequelize": "^6.37.5", "sequelize": "^6.37.8",
"sockjs": "^0.3.24", "sockjs": "^0.3.24",
"sqlite3": "npm:@whyour/sqlite3@1.1.2", "sqlite3": "npm:@whyour/sqlite3@1.1.2",
"toad-scheduler": "^3.0.1", "toad-scheduler": "^3.0.1",
"typedi": "^0.10.0", "typedi": "^0.10.0",
"undici": "^7.9.0", "undici": "^7.30.0",
"uuid": "^11.0.3", "uuid": "^11.1.1",
"winston": "^3.17.0", "winston": "^3.17.0",
"winston-daily-rotate-file": "^5.0.0" "winston-daily-rotate-file": "^5.0.0"
}, },
@@ -169,7 +189,7 @@
"concurrently": "^7.0.0", "concurrently": "^7.0.0",
"file-saver": "2.0.2", "file-saver": "2.0.2",
"lint-staged": "^13.0.3", "lint-staged": "^13.0.3",
"moment": "2.30.1", "moment": "2.31.0",
"monaco-editor": "0.33.0", "monaco-editor": "0.33.0",
"nodemon": "^3.0.1", "nodemon": "^3.0.1",
"prettier": "^2.5.1", "prettier": "^2.5.1",
+396 -439
View File
File diff suppressed because it is too large. Load diff
+191
View File
@@ -0,0 +1,191 @@
#!/usr/bin/env node
'use strict';
const assert = require('node:assert/strict');
const { createServer } = require('node:http');
const sqlite3 = require('sqlite3');
const { Sequelize, DataTypes } = require('sequelize');
const jwt = require('jsonwebtoken');
const protobuf = require('node:module').createRequire(
require.resolve('@grpc/proto-loader'),
)('protobufjs');
const grpc = require('@grpc/grpc-js');
const sockjs = require('sockjs');
const { WebSocket, ProxyAgent } = require('undici');
const nodemailer = require('nodemailer');
async function verifyDatabase() {
const db = new sqlite3.Database(':memory:');
try {
const row = await new Promise((resolve, reject) =>
db.get('SELECT sqlite_version() AS version', (error, row) =>
error ? reject(error) : resolve(row),
),
);
assert.match(row.version, /^\d+\.\d+\.\d+$/);
} finally {
await new Promise((resolve, reject) =>
db.close((error) => (error ? reject(error) : resolve())),
);
}
const orm = new Sequelize({
dialect: 'sqlite',
storage: ':memory:',
logging: false,
});
try {
const Task = orm.define('ReadinessTask', {
name: DataTypes.STRING,
payload: DataTypes.JSON,
});
await orm.sync();
await orm.transaction(async (transaction) => {
await Task.create(
{ name: 'readiness', payload: { status: 'ready' } },
{ transaction },
);
});
const task = await Task.findOne({ where: { name: 'readiness' } });
assert.deepEqual(task.get('payload'), { status: 'ready' });
await task.update({ name: 'verified' });
assert.equal(await Task.count({ where: { name: 'verified' } }), 1);
} finally {
await orm.close();
}
}
async function verifyGrpc() {
const Message = protobuf.Root.fromJSON({
nested: {
Message: { fields: { value: { type: 'string', id: 1 } } },
},
}).lookupType('Message');
const serialize = (value) => Buffer.from(Message.encode(value).finish());
const deserialize = (value) => Message.toObject(Message.decode(value));
const definition = {
echo: {
path: '/readiness.Echo/Echo',
requestStream: false,
responseStream: false,
requestSerialize: serialize,
requestDeserialize: deserialize,
responseSerialize: serialize,
responseDeserialize: deserialize,
},
};
const server = new grpc.Server();
server.addService(definition, {
echo: (call, callback) => callback(null, call.request),
});
const port = await new Promise((resolve, reject) =>
server.bindAsync(
'127.0.0.1:0',
grpc.ServerCredentials.createInsecure(),
(error, port) => (error ? reject(error) : resolve(port)),
),
);
const Client = grpc.makeGenericClientConstructor(definition, 'Echo');
const client = new Client(
`127.0.0.1:${port}`,
grpc.credentials.createInsecure(),
);
try {
const response = await new Promise((resolve, reject) =>
client.echo(
{ value: 'ready' },
{ deadline: Date.now() + 5000 },
(error, response) => (error ? reject(error) : resolve(response)),
),
);
assert.equal(response.value, 'ready');
} finally {
client.close();
server.forceShutdown();
}
}
async function verifyWebsocket() {
const server = createServer();
const transport = sockjs.createServer({
prefix: '/readiness',
log: () => {},
});
transport.on('connection', (connection) =>
connection.on('data', (message) => connection.write(message)),
);
transport.installHandlers(server);
await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
const client = new WebSocket(
`ws://127.0.0.1:${server.address().port}/readiness/000/fixture/websocket`,
);
try {
await new Promise((resolve, reject) => {
const timer = setTimeout(
() => reject(new Error('WebSocket echo timed out')),
5000,
);
client.addEventListener('error', () => {
clearTimeout(timer);
reject(new Error('WebSocket connection failed'));
});
client.addEventListener('message', ({ data }) => {
if (data === 'o') client.send(JSON.stringify(['dependency-readiness']));
else {
try {
assert.equal(data, 'a["dependency-readiness"]');
clearTimeout(timer);
resolve();
} catch (error) {
clearTimeout(timer);
reject(error);
}
}
});
});
} finally {
client.close();
server.closeAllConnections();
await new Promise((resolve) => server.close(resolve));
}
const proxy = new ProxyAgent('http://127.0.0.1:1');
await proxy.close();
}
async function verifyMailAndJwt() {
const token = jwt.sign({ readiness: true }, 'local-fixture-secret', {
expiresIn: 60,
});
assert.equal(jwt.verify(token, 'local-fixture-secret').readiness, true);
assert.throws(() => jwt.verify(token, 'different-local-fixture-secret'));
const mail = nodemailer.createTransport({
streamTransport: true,
buffer: true,
});
try {
const message = await mail.sendMail({
from: 'Qinglong <readiness@localhost>',
to: 'fixture@localhost',
subject: 'Dependency readiness',
text: 'Local fixture only',
});
assert.match(message.message.toString(), /Local fixture only/);
assert.deepEqual(message.envelope.to, ['fixture@localhost']);
} finally {
mail.close();
}
}
(async () => {
for (const verify of [
verifyDatabase,
verifyGrpc,
verifyWebsocket,
verifyMailAndJwt,
]) {
await verify();
console.log(`${verify.name}: passed`);
}
})().catch((error) => {
console.error(error);
process.exitCode = 1;
});