mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 10:21:24 +00:00
refactor(security): remove unused empty allowlist mode
This commit is contained in:
@@ -37,18 +37,6 @@ describe("isAllowedParsedChatSender", () => {
|
|||||||
expect(allowed).toBe(false);
|
expect(allowed).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("can explicitly allow when allowFrom is empty", () => {
|
|
||||||
const allowed = isAllowedParsedChatSender({
|
|
||||||
allowFrom: [],
|
|
||||||
sender: "+15551234567",
|
|
||||||
emptyAllowFrom: "allow",
|
|
||||||
normalizeSender: (sender) => sender,
|
|
||||||
parseAllowTarget,
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(allowed).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("allows wildcard entries", () => {
|
it("allows wildcard entries", () => {
|
||||||
const allowed = isAllowedParsedChatSender({
|
const allowed = isAllowedParsedChatSender({
|
||||||
allowFrom: ["*"],
|
allowFrom: ["*"],
|
||||||
|
|||||||
@@ -21,15 +21,12 @@ export function isAllowedParsedChatSender<TParsed extends ParsedChatAllowTarget>
|
|||||||
chatId?: number | null;
|
chatId?: number | null;
|
||||||
chatGuid?: string | null;
|
chatGuid?: string | null;
|
||||||
chatIdentifier?: string | null;
|
chatIdentifier?: string | null;
|
||||||
emptyAllowFrom?: "deny" | "allow";
|
|
||||||
normalizeSender: (sender: string) => string;
|
normalizeSender: (sender: string) => string;
|
||||||
parseAllowTarget: (entry: string) => TParsed;
|
parseAllowTarget: (entry: string) => TParsed;
|
||||||
}): boolean {
|
}): boolean {
|
||||||
const allowFrom = params.allowFrom.map((entry) => String(entry).trim());
|
const allowFrom = params.allowFrom.map((entry) => String(entry).trim());
|
||||||
if (allowFrom.length === 0) {
|
if (allowFrom.length === 0) {
|
||||||
// Fail closed by default. Callers can opt into legacy "empty = allow all"
|
return false;
|
||||||
// behavior explicitly when a surface intentionally treats an empty list as open.
|
|
||||||
return params.emptyAllowFrom === "allow";
|
|
||||||
}
|
}
|
||||||
if (allowFrom.includes("*")) {
|
if (allowFrom.includes("*")) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user