mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 22:24:31 +00:00
fix(configure): reject literal "undefined" and "null" gateway auth tokens (#13767)
* fix(configure): reject literal "undefined" and "null" gateway auth tokens * fix(configure): reject literal "undefined" and "null" gateway auth tokens * fix(configure): validate gateway password prompt and harden token coercion (#13767) (thanks @omair445) * test: remove unused vitest imports in baseline lint fixtures (#13767) --------- Co-authored-by: Luna AI <luna@coredirection.ai> Co-authored-by: Peter Steinberger <steipete@gmail.com>
This commit is contained in:
@@ -73,7 +73,27 @@ export function normalizeGatewayTokenInput(value: unknown): string {
|
||||
if (typeof value !== "string") {
|
||||
return "";
|
||||
}
|
||||
return value.trim();
|
||||
const trimmed = value.trim();
|
||||
// Reject the literal string "undefined" — a common bug when JS undefined
|
||||
// gets coerced to a string via template literals or String(undefined).
|
||||
if (trimmed === "undefined" || trimmed === "null") {
|
||||
return "";
|
||||
}
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
export function validateGatewayPasswordInput(value: unknown): string | undefined {
|
||||
if (typeof value !== "string") {
|
||||
return "Required";
|
||||
}
|
||||
const trimmed = value.trim();
|
||||
if (!trimmed) {
|
||||
return "Required";
|
||||
}
|
||||
if (trimmed === "undefined" || trimmed === "null") {
|
||||
return 'Cannot be the literal string "undefined" or "null"';
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function printWizardHeader(runtime: RuntimeEnv) {
|
||||
|
||||
Reference in New Issue
Block a user