mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 19:40:42 +00:00
fix(check): absorb latest main lint drift
This commit is contained in:
@@ -52,29 +52,49 @@ export function isPrivateOrReservedIP(ip: string): boolean {
|
||||
}
|
||||
const [a, b] = octets;
|
||||
// 10.0.0.0/8
|
||||
if (a === 10) return true;
|
||||
if (a === 10) {
|
||||
return true;
|
||||
}
|
||||
// 172.16.0.0/12
|
||||
if (a === 172 && b >= 16 && b <= 31) return true;
|
||||
if (a === 172 && b >= 16 && b <= 31) {
|
||||
return true;
|
||||
}
|
||||
// 192.168.0.0/16
|
||||
if (a === 192 && b === 168) return true;
|
||||
if (a === 192 && b === 168) {
|
||||
return true;
|
||||
}
|
||||
// 127.0.0.0/8 (loopback)
|
||||
if (a === 127) return true;
|
||||
if (a === 127) {
|
||||
return true;
|
||||
}
|
||||
// 169.254.0.0/16 (link-local)
|
||||
if (a === 169 && b === 254) return true;
|
||||
if (a === 169 && b === 254) {
|
||||
return true;
|
||||
}
|
||||
// 0.0.0.0/8
|
||||
if (a === 0) return true;
|
||||
if (a === 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// IPv6 checks
|
||||
const normalized = ip.toLowerCase();
|
||||
// ::1 loopback
|
||||
if (normalized === "::1") return true;
|
||||
if (normalized === "::1") {
|
||||
return true;
|
||||
}
|
||||
// fe80::/10 link-local
|
||||
if (normalized.startsWith("fe80:") || normalized.startsWith("fe80")) return true;
|
||||
if (normalized.startsWith("fe80:") || normalized.startsWith("fe80")) {
|
||||
return true;
|
||||
}
|
||||
// fc00::/7 unique-local (fc00:: and fd00::)
|
||||
if (normalized.startsWith("fc") || normalized.startsWith("fd")) return true;
|
||||
if (normalized.startsWith("fc") || normalized.startsWith("fd")) {
|
||||
return true;
|
||||
}
|
||||
// :: unspecified
|
||||
if (normalized === "::") return true;
|
||||
if (normalized === "::") {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -130,9 +150,7 @@ export async function validateConsentUploadUrl(
|
||||
|
||||
for (const entry of resolved) {
|
||||
if (isPrivateOrReservedIP(entry.address)) {
|
||||
throw new Error(
|
||||
`Consent upload URL resolves to a private/reserved IP (${entry.address})`,
|
||||
);
|
||||
throw new Error(`Consent upload URL resolves to a private/reserved IP (${entry.address})`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user