fix(check): absorb latest main lint drift

This commit is contained in:
Peter Steinberger
2026-04-06 15:56:02 +01:00
parent d12029a15a
commit 378b2c2f5c
2 changed files with 37 additions and 15 deletions

View File

@@ -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})`);
}
}
}

View File

@@ -154,8 +154,12 @@ export function buildWebProviderSnapshotCacheKey(params: {
bundledAllowlistCompat?: boolean;
onlyPluginIds?: readonly string[];
origin?: PluginManifestRecord["origin"];
envKey: Record<string, string>;
envKey: string | Record<string, string>;
}): string {
const envKey =
typeof params.envKey === "string"
? params.envKey
: Object.entries(params.envKey).toSorted(([left], [right]) => left.localeCompare(right));
return JSON.stringify({
workspaceDir: params.workspaceDir ?? "",
bundledAllowlistCompat: params.bundledAllowlistCompat === true,
@@ -163,7 +167,7 @@ export function buildWebProviderSnapshotCacheKey(params: {
onlyPluginIds: [...new Set(params.onlyPluginIds ?? [])].toSorted((left, right) =>
left.localeCompare(right),
),
env: Object.entries(params.envKey).toSorted(([left], [right]) => left.localeCompare(right)),
env: envKey,
});
}