fix(qa): reject loose bundled plugin runtime indexes · openclaw/openclaw@ef5d6a6
vincentkoc
·
2026-06-17
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -72,6 +72,21 @@ function readPositiveInt(raw, fallback, name) {
|
72 | 72 | return parsed; |
73 | 73 | } |
74 | 74 | |
| 75 | +function readNonNegativeInt(raw, fallback, name) { |
| 76 | +const text = String(raw ?? "").trim(); |
| 77 | +if (!text) { |
| 78 | +return fallback; |
| 79 | +} |
| 80 | +if (!/^\d+$/u.test(text)) { |
| 81 | +throw new Error(`invalid ${name}: ${text}`); |
| 82 | +} |
| 83 | +const parsed = Number(text); |
| 84 | +if (!Number.isSafeInteger(parsed)) { |
| 85 | +throw new Error(`invalid ${name}: ${text}`); |
| 86 | +} |
| 87 | +return parsed; |
| 88 | +} |
| 89 | + |
75 | 90 | function readJson(file) { |
76 | 91 | return JSON.parse(fs.readFileSync(file, "utf8")); |
77 | 92 | } |
@@ -1427,7 +1442,7 @@ function tailText(text) {
|
1427 | 1442 | export async function main(argv = process.argv.slice(2)) { |
1428 | 1443 | const [command, pluginId, pluginDir, requiresConfigRaw, pluginIndexRaw, pluginRoot, provider] = |
1429 | 1444 | argv; |
1430 | | -const pluginIndex = Number.parseInt(pluginIndexRaw || "0", 10); |
| 1445 | +const pluginIndex = readNonNegativeInt(pluginIndexRaw, 0, "bundled plugin runtime index"); |
1431 | 1446 | |
1432 | 1447 | if (command === "plugin") { |
1433 | 1448 | await smokePlugin(pluginId, pluginDir, requiresConfigRaw === "1", pluginIndex, pluginRoot); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -257,6 +257,15 @@ describe("bundled plugin install/uninstall probe", () => {
|
257 | 257 | ); |
258 | 258 | }); |
259 | 259 | |
| 260 | +it("rejects loose bundled plugin runtime index args", () => { |
| 261 | +const root = makePackageRoot(); |
| 262 | + |
| 263 | +const result = runRuntimeSmoke(root, ["tts-openai-live", "", "", "", "1e3"]); |
| 264 | + |
| 265 | +expect(result.status).not.toBe(0); |
| 266 | +expect(result.stderr).toContain("invalid bundled plugin runtime index: 1e3"); |
| 267 | +}); |
| 268 | + |
260 | 269 | it("caps noisy runtime gateway logs", async () => { |
261 | 270 | const runtimeSmoke = await importRuntimeSmokeWithEnv({ |
262 | 271 | OPENCLAW_BUNDLED_PLUGIN_RUNTIME_GATEWAY_LOG_BYTES: "64", |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。