a7711d2dc3
新增 pingora-gateway 独立二进制 crate,覆盖路由、静态资源、压缩、接流保护、TLS 直连和访问日志能力。 新增 Nginx canary、realpath canary、direct preflight、direct live、direct enable 和 rollback 脚本。 新增 Pingora 切流证据包、命令证据、manifest 验真、根目录总审计和 release readiness 聚合门禁。 完善 API release、Jenkins、systemd、health patrol、生产部署和发布包自包含校验。 更新 Pingora 试点文档、Nginx README 与 Hermes 共享记忆。
73 lines
1.8 KiB
JavaScript
73 lines
1.8 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import { spawnSync } from 'node:child_process';
|
|
|
|
const CANARY_LIVE_SCRIPT = 'scripts/check-pingora-canary-live.mjs';
|
|
const failures = [];
|
|
|
|
main();
|
|
|
|
if (failures.length > 0) {
|
|
console.error('[check:pingora-canary-live-guard] FAILED');
|
|
for (const failure of failures) {
|
|
console.error(`- ${failure}`);
|
|
}
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log('[check:pingora-canary-live-guard] OK');
|
|
|
|
function main() {
|
|
assertRejectsControlCharacter('--base-url', [
|
|
'--base-url',
|
|
'http://127.0.0.1\n--fake-flag',
|
|
]);
|
|
assertRejectsControlCharacter('--prefix', [
|
|
'--base-url',
|
|
'http://127.0.0.1',
|
|
'--prefix',
|
|
'/__genarrative_pingora_canary\nX-Injected: yes',
|
|
]);
|
|
assertRejectsControlCharacter('--host', [
|
|
'--base-url',
|
|
'http://127.0.0.1',
|
|
'--host',
|
|
'example.com\nX-Injected: yes',
|
|
]);
|
|
assertRejectsControlCharacter('--path', [
|
|
'--base-url',
|
|
'http://127.0.0.1',
|
|
'--path',
|
|
'/api/creation-entry/config\nX-Injected: yes',
|
|
]);
|
|
assertRejectsControlCharacter('--timeout-ms', [
|
|
'--base-url',
|
|
'http://127.0.0.1',
|
|
'--timeout-ms',
|
|
'5000\n1',
|
|
]);
|
|
}
|
|
|
|
function assertRejectsControlCharacter(label, args) {
|
|
const result = spawnSync('node', [CANARY_LIVE_SCRIPT, ...args], {
|
|
cwd: process.cwd(),
|
|
encoding: 'utf8',
|
|
env: process.env,
|
|
});
|
|
if ((result.status ?? 0) === 0) {
|
|
failures.push(`${label} 带控制字符时必须在发起 canary 请求前失败。`);
|
|
return;
|
|
}
|
|
assertIncludes(
|
|
`${result.stdout}\n${result.stderr}`,
|
|
`${label} 不能包含换行或 NUL 字符`,
|
|
`${label} 带控制字符时必须给出明确错误。`,
|
|
);
|
|
}
|
|
|
|
function assertIncludes(value, expected, reason) {
|
|
if (!String(value).includes(expected)) {
|
|
failures.push(`${reason} 缺少: ${expected}`);
|
|
}
|
|
}
|