mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-28 00:52:57 +00:00
fix(matrix): reject malformed integer cli values
This commit is contained in:
@@ -386,6 +386,20 @@ describe("matrix CLI verification commands", () => {
|
||||
expect(consoleLogMock).toHaveBeenCalledWith("Backup: active and trusted on this device");
|
||||
});
|
||||
|
||||
it("rejects malformed Matrix self-verification timeout values", async () => {
|
||||
const program = buildProgram();
|
||||
|
||||
await program.parseAsync(["matrix", "verify", "self", "--timeout-ms", "5000ms"], {
|
||||
from: "user",
|
||||
});
|
||||
|
||||
expect(process.exitCode).toBe(1);
|
||||
expect(consoleErrorMock).toHaveBeenCalledWith(
|
||||
"Self-verification failed: --timeout-ms must be an integer",
|
||||
);
|
||||
expect(runMatrixSelfVerificationMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("requests Matrix self-verification and prints the follow-up SAS commands", async () => {
|
||||
requestMatrixVerificationMock.mockResolvedValue(
|
||||
mockMatrixVerificationSummary({
|
||||
|
||||
@@ -234,6 +234,9 @@ function parseOptionalInt(value: string | undefined, fieldName: string): number
|
||||
if (!trimmed) {
|
||||
return undefined;
|
||||
}
|
||||
if (!/^-?\d+$/.test(trimmed)) {
|
||||
throw new Error(`${fieldName} must be an integer`);
|
||||
}
|
||||
const parsed = Number.parseInt(trimmed, 10);
|
||||
if (!Number.isFinite(parsed)) {
|
||||
throw new Error(`${fieldName} must be an integer`);
|
||||
|
||||
Reference in New Issue
Block a user