mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 14:48:28 +00:00
fix(gateway): avoid unsafe param stringification
This commit is contained in:
@@ -67,12 +67,19 @@ function resolveAgentWorkspaceFileOrRespondError(
|
|||||||
name: string;
|
name: string;
|
||||||
} | null {
|
} | null {
|
||||||
const cfg = loadConfig();
|
const cfg = loadConfig();
|
||||||
const agentId = resolveAgentIdOrError(String(params.agentId ?? ""), cfg);
|
const rawAgentId = params.agentId;
|
||||||
|
const agentId = resolveAgentIdOrError(
|
||||||
|
typeof rawAgentId === "string" || typeof rawAgentId === "number" ? String(rawAgentId) : "",
|
||||||
|
cfg,
|
||||||
|
);
|
||||||
if (!agentId) {
|
if (!agentId) {
|
||||||
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, "unknown agent id"));
|
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, "unknown agent id"));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const name = String(params.name ?? "").trim();
|
const rawName = params.name;
|
||||||
|
const name = (
|
||||||
|
typeof rawName === "string" || typeof rawName === "number" ? String(rawName) : ""
|
||||||
|
).trim();
|
||||||
if (!ALLOWED_FILE_NAMES.has(name)) {
|
if (!ALLOWED_FILE_NAMES.has(name)) {
|
||||||
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, `unsupported file "${name}"`));
|
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, `unsupported file "${name}"`));
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user