mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 02:01:25 +00:00
Doctor/Security: fix telegram numeric ID + symlink config permission warnings (#19844)
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: e42bf1e48d
Co-authored-by: joshp123 <1497361+joshp123@users.noreply.github.com>
Co-authored-by: joshp123 <1497361+joshp123@users.noreply.github.com>
Reviewed-by: @joshp123
This commit is contained in:
16
src/channels/telegram/allow-from.test.ts
Normal file
16
src/channels/telegram/allow-from.test.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { isNumericTelegramUserId, normalizeTelegramAllowFromEntry } from "./allow-from.js";
|
||||
|
||||
describe("telegram allow-from helpers", () => {
|
||||
it("normalizes tg/telegram prefixes", () => {
|
||||
expect(normalizeTelegramAllowFromEntry(" TG:123 ")).toBe("123");
|
||||
expect(normalizeTelegramAllowFromEntry("telegram:@someone")).toBe("@someone");
|
||||
});
|
||||
|
||||
it("accepts signed numeric IDs", () => {
|
||||
expect(isNumericTelegramUserId("123456789")).toBe(true);
|
||||
expect(isNumericTelegramUserId("-1001234567890")).toBe(true);
|
||||
expect(isNumericTelegramUserId("@someone")).toBe(false);
|
||||
expect(isNumericTelegramUserId("12 34")).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -7,5 +7,5 @@ export function normalizeTelegramAllowFromEntry(raw: unknown): string {
|
||||
}
|
||||
|
||||
export function isNumericTelegramUserId(raw: string): boolean {
|
||||
return /^\d+$/.test(raw);
|
||||
return /^-?\d+$/.test(raw);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user