mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 11:17:40 +00:00
fix(security): harden gateway command/audit guardrails
This commit is contained in:
@@ -21,6 +21,13 @@ function normalizePart(value: unknown, fallback: string): string {
|
||||
export function resolveControlPlaneRateLimitKey(client: GatewayClient | null): string {
|
||||
const deviceId = normalizePart(client?.connect?.device?.id, "unknown-device");
|
||||
const clientIp = normalizePart(client?.clientIp, "unknown-ip");
|
||||
if (deviceId === "unknown-device" && clientIp === "unknown-ip") {
|
||||
// Last-resort fallback: avoid cross-client contention when upstream identity is missing.
|
||||
const connId = normalizePart(client?.connId, "");
|
||||
if (connId) {
|
||||
return `${deviceId}|${clientIp}|conn=${connId}`;
|
||||
}
|
||||
}
|
||||
return `${deviceId}|${clientIp}`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user