CH-J Server Managerbainisteoireacht freastalaí SSH
Roghchlár
Foinse foilsithe

CH-J Server Manager

Brabhsáil comhadlanna agus comhaid chun feidhmchlár áirithe a scaoileadh.

Íosluchtaigh foinse ZIP
CH-J / Server Manager 339 Comhaid
core-20261014T184258Z-3fbed0b93fdf Suimigh: Dáta gan taifeadadh · Tógtha:
Comhaid
urlPolicy.js Suimigh: Dáta gan taifeadadh 1.5 KB · 40 líne
Íosluchtaigh comhad
1"use strict";
3function normalizeBaseUrl(value) {
4 const url = new URL(String(value || ""));
5 if (url.protocol !== "https:") throw new Error("Update URL must use HTTPS.");
6 if (url.username || url.password || url.hash || url.search) throw new Error("Invalid update base URL.");
7 url.pathname = `${url.pathname.replace(/\/+$/, "")}/`;
8 return url;
9}
11function assertAllowedUrl(candidate, allowedBaseUrls, options = {}) {
12 const raw = String(candidate || "").trim();
13 if (!raw) throw new Error("Missing URL.");
14 const bases = allowedBaseUrls.map(normalizeBaseUrl);
16 if (raw.startsWith("/")) {
17 if (!options.baseUrl) throw new Error("Relative URL requires a base URL.");
18 return assertAllowedUrl(new URL(raw.replace(/^\/+/, ""), normalizeBaseUrl(options.baseUrl)).toString(), allowedBaseUrls, options);
19 }
21 const url = new URL(raw);
22 if (url.username || url.password || url.hash) throw new Error("URL credentials and fragments are not allowed.");
23 const matchedBase = bases.find((base) => (
24 url.protocol === base.protocol
25 && url.hostname === base.hostname
26 && url.port === base.port
27 && url.pathname.startsWith(base.pathname)
28 ));
29 if (!matchedBase) throw new Error("URL is outside the update allowlist.");
31 if (options.pathSegment && !url.pathname.startsWith(`${matchedBase.pathname}${options.pathSegment}`)) {
32 throw new Error("URL path is outside the allowed update area.");
33 }
34 return url;
37module.exports = {
38 assertAllowedUrl,
39 normalizeBaseUrl
40};
SHA-256db15c1e8b5a134391637a8de3efca895dcbf77095a5eaf58acba061b69775030

CH-J Proprietary Software License 1.14 · Tá Foinse ar fáil faoin CH-J Proprietary Software License 1.14. Ní chuireann a infhaighteacht a athrú ar na téarmaí ceadúnais nó cearta breise a dheonú.

Cartlann SHA-2563df08cf5e899262a6ce92d7ec2caf5c42b683f1f2b57055662b845ff7dde67a8