@nocobase/utils 2.3.0-beta.8 → 2.3.0-beta.9
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/lib/server-request.d.ts +1 -0
- package/lib/server-request.js +7 -1
- package/package.json +2 -2
package/lib/server-request.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export declare function matchesDomainPattern(hostname: string, pattern: string):
|
|
|
18
18
|
*
|
|
19
19
|
* Throws an error if:
|
|
20
20
|
* - The URL scheme is not http or https.
|
|
21
|
+
* - SERVER_REQUEST_DISALLOW_IP is true and the host is a literal IP address.
|
|
21
22
|
* - SERVER_REQUEST_WHITELIST is set and the host does not match any entry.
|
|
22
23
|
*
|
|
23
24
|
* Silently returns for relative URLs (no scheme) so that internal API calls
|
package/lib/server-request.js
CHANGED
|
@@ -189,13 +189,19 @@ function checkUrlAgainstWhitelist(url) {
|
|
|
189
189
|
);
|
|
190
190
|
}
|
|
191
191
|
const host = getNormalizedHost(parsed);
|
|
192
|
+
if (process.env.SERVER_REQUEST_DISALLOW_IP === "true" && import_ipaddr.default.isValid(host)) {
|
|
193
|
+
throw new Error(`Outbound request to "${host}" is blocked because SERVER_REQUEST_DISALLOW_IP is enabled.`);
|
|
194
|
+
}
|
|
192
195
|
const whitelist = process.env.SERVER_REQUEST_WHITELIST;
|
|
193
196
|
if (!whitelist || !whitelist.trim()) {
|
|
194
197
|
warnIfSsrfRiskTarget(host);
|
|
195
198
|
return;
|
|
196
199
|
}
|
|
197
200
|
const entries = whitelist.split(",").map((e) => e.trim()).filter(Boolean);
|
|
198
|
-
if (entries.length === 0)
|
|
201
|
+
if (entries.length === 0) {
|
|
202
|
+
warnIfSsrfRiskTarget(host);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
199
205
|
for (const entry of entries) {
|
|
200
206
|
if (matchesEntry(host, entry)) return;
|
|
201
207
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/utils",
|
|
3
|
-
"version": "2.3.0-beta.
|
|
3
|
+
"version": "2.3.0-beta.9",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"sanitize-html": "2.17.5",
|
|
23
23
|
"ses": "^1.14.0"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "c215e60ed704afe6c086bd96304f4b0d3b46d02e"
|
|
26
26
|
}
|