mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 09:01:22 +00:00
fix(security): harden avatar validation and size limits
This commit is contained in:
@@ -3,6 +3,11 @@ import { resolveAgentIdentity } from "../agents/identity.js";
|
||||
import { loadAgentIdentity } from "../commands/agents.config.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { normalizeAgentId } from "../routing/session-key.js";
|
||||
import {
|
||||
isAvatarHttpUrl,
|
||||
isAvatarImageDataUrl,
|
||||
looksLikeAvatarPath,
|
||||
} from "../shared/avatar-policy.js";
|
||||
|
||||
const MAX_ASSISTANT_NAME = 50;
|
||||
const MAX_ASSISTANT_AVATAR = 200;
|
||||
@@ -36,14 +41,7 @@ function coerceIdentityValue(value: string | undefined, maxLength: number): stri
|
||||
}
|
||||
|
||||
function isAvatarUrl(value: string): boolean {
|
||||
return /^https?:\/\//i.test(value) || /^data:image\//i.test(value);
|
||||
}
|
||||
|
||||
function looksLikeAvatarPath(value: string): boolean {
|
||||
if (/[\\/]/.test(value)) {
|
||||
return true;
|
||||
}
|
||||
return /\.(png|jpe?g|gif|webp|svg|ico)$/i.test(value);
|
||||
return isAvatarHttpUrl(value) || isAvatarImageDataUrl(value);
|
||||
}
|
||||
|
||||
function normalizeAvatarValue(value: string | undefined): string | undefined {
|
||||
|
||||
Reference in New Issue
Block a user