@patchstack/connect 0.3.26 → 0.3.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENT-INSTALL.md +21 -5
- package/dist/cli.js +192 -74
- package/dist/cli.js.map +1 -1
- package/dist/protect.cjs +33 -1
- package/dist/protect.cjs.map +1 -1
- package/dist/protect.edge.js +33 -1
- package/dist/protect.edge.js.map +2 -2
- package/dist/protect.js +33 -1
- package/dist/protect.js.map +1 -1
- package/package.json +1 -1
package/dist/protect.cjs
CHANGED
|
@@ -2084,6 +2084,26 @@ function warnUnsupportedMatchType(type) {
|
|
|
2084
2084
|
`[patchstack] Unsupported rule_v2 match type "${type}" \u2014 condition treated as no-match. Rules relying on it are not enforced by this engine.`
|
|
2085
2085
|
);
|
|
2086
2086
|
}
|
|
2087
|
+
function hostFromValue(value) {
|
|
2088
|
+
const raw = String(value ?? "").trim();
|
|
2089
|
+
if (raw === "") return "";
|
|
2090
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(raw) || raw.startsWith("//")) {
|
|
2091
|
+
try {
|
|
2092
|
+
return new URL(raw.startsWith("//") ? `http:${raw}` : raw).hostname;
|
|
2093
|
+
} catch {
|
|
2094
|
+
return raw;
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
if (raw.startsWith("[")) {
|
|
2098
|
+
const end = raw.indexOf("]");
|
|
2099
|
+
if (end > 0) return raw.slice(1, end);
|
|
2100
|
+
}
|
|
2101
|
+
const colon = raw.indexOf(":");
|
|
2102
|
+
if (colon > 0 && raw.indexOf(":", colon + 1) === -1 && /^\d+$/.test(raw.slice(colon + 1))) {
|
|
2103
|
+
return raw.slice(0, colon);
|
|
2104
|
+
}
|
|
2105
|
+
return raw;
|
|
2106
|
+
}
|
|
2087
2107
|
function isInternalHost(hostname) {
|
|
2088
2108
|
if (!hostname) return false;
|
|
2089
2109
|
let host = String(hostname).toLowerCase().replace(/^\[|\]$/g, "");
|
|
@@ -2173,8 +2193,20 @@ function expandIPv6(host) {
|
|
|
2173
2193
|
}
|
|
2174
2194
|
return out;
|
|
2175
2195
|
}
|
|
2196
|
+
var warnedScopes = /* @__PURE__ */ new Set();
|
|
2197
|
+
function warnUnrecognisedScope(when) {
|
|
2198
|
+
const key = Object.keys(when).sort().join(",");
|
|
2199
|
+
if (warnedScopes.has(key)) return;
|
|
2200
|
+
warnedScopes.add(key);
|
|
2201
|
+
console.warn(
|
|
2202
|
+
`[patchstack] Rule scope \`when: { ${key} }\` names no supported key \u2014 the engine understands \`method\` and \`path\`. The scope is IGNORED and the rule applies to every request.`
|
|
2203
|
+
);
|
|
2204
|
+
}
|
|
2176
2205
|
function ruleAppliesTo(when, resolver) {
|
|
2177
2206
|
try {
|
|
2207
|
+
if (when.method === void 0 && when.path === void 0 && Object.keys(when).length > 0) {
|
|
2208
|
+
warnUnrecognisedScope(when);
|
|
2209
|
+
}
|
|
2178
2210
|
if (when.method) {
|
|
2179
2211
|
const methods = (Array.isArray(when.method) ? when.method : [when.method]).map((m) => String(m).toUpperCase());
|
|
2180
2212
|
const actual = String(resolver.resolve("server.REQUEST_METHOD")[0] ?? "GET").toUpperCase();
|
|
@@ -2340,7 +2372,7 @@ function matchValue(type, value, matchVal, matchObj) {
|
|
|
2340
2372
|
}
|
|
2341
2373
|
}
|
|
2342
2374
|
case "internal_host":
|
|
2343
|
-
return isInternalHost(strValue);
|
|
2375
|
+
return isInternalHost(hostFromValue(strValue));
|
|
2344
2376
|
case "quotes":
|
|
2345
2377
|
// engine-php exposes `inline_js_xss` as an alias of `quotes`.
|
|
2346
2378
|
case "inline_js_xss":
|