n8n-core 2.26.2 → 2.27.0
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/dist/binary-data/binary-data.service.js +2 -2
- package/dist/binary-data/binary-data.service.js.map +1 -1
- package/dist/binary-data/index.d.ts +1 -1
- package/dist/binary-data/index.js +1 -2
- package/dist/binary-data/index.js.map +1 -1
- package/dist/binary-data/object-store/object-store.service.ee.d.ts +2 -1
- package/dist/binary-data/object-store/object-store.service.ee.js +37 -16
- package/dist/binary-data/object-store/object-store.service.ee.js.map +1 -1
- package/dist/binary-data/object-store.manager.js +2 -2
- package/dist/binary-data/object-store.manager.js.map +1 -1
- package/dist/binary-data/utils.d.ts +1 -3
- package/dist/binary-data/utils.js +0 -20
- package/dist/binary-data/utils.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/credentials.js +1 -1
- package/dist/credentials.js.map +1 -1
- package/dist/execution-engine/active-workflow-triggers.d.ts +30 -0
- package/dist/execution-engine/active-workflow-triggers.js +272 -0
- package/dist/execution-engine/active-workflow-triggers.js.map +1 -0
- package/dist/execution-engine/index.d.ts +12 -11
- package/dist/execution-engine/index.js +14 -13
- package/dist/execution-engine/index.js.map +1 -1
- package/dist/execution-engine/node-execution-context/base-execute-context.d.ts +2 -2
- package/dist/execution-engine/node-execution-context/base-execute-context.js +3 -3
- package/dist/execution-engine/node-execution-context/base-execute-context.js.map +1 -1
- package/dist/execution-engine/node-execution-context/execute-context.js +2 -2
- package/dist/execution-engine/node-execution-context/execute-context.js.map +1 -1
- package/dist/execution-engine/node-execution-context/execute-single-context.js +1 -1
- package/dist/execution-engine/node-execution-context/execute-single-context.js.map +1 -1
- package/dist/execution-engine/node-execution-context/hook-context.js +2 -2
- package/dist/execution-engine/node-execution-context/hook-context.js.map +1 -1
- package/dist/execution-engine/node-execution-context/index.d.ts +1 -1
- package/dist/execution-engine/node-execution-context/index.js +2 -2
- package/dist/execution-engine/node-execution-context/index.js.map +1 -1
- package/dist/execution-engine/node-execution-context/node-execution-context.d.ts +3 -3
- package/dist/execution-engine/node-execution-context/node-execution-context.js +2 -2
- package/dist/execution-engine/node-execution-context/node-execution-context.js.map +1 -1
- package/dist/execution-engine/node-execution-context/poll-context.js +2 -2
- package/dist/execution-engine/node-execution-context/poll-context.js.map +1 -1
- package/dist/execution-engine/node-execution-context/trigger-context.js +3 -3
- package/dist/execution-engine/node-execution-context/trigger-context.js.map +1 -1
- package/dist/execution-engine/node-execution-context/utils/binary-helper-functions.d.ts +0 -1
- package/dist/execution-engine/node-execution-context/utils/binary-helper-functions.js +4 -15
- package/dist/execution-engine/node-execution-context/utils/binary-helper-functions.js.map +1 -1
- package/dist/execution-engine/node-execution-context/utils/extract-value.js +10 -8
- package/dist/execution-engine/node-execution-context/utils/extract-value.js.map +1 -1
- package/dist/execution-engine/node-execution-context/utils/get-input-connection-data.js +1 -1
- package/dist/execution-engine/node-execution-context/utils/get-input-connection-data.js.map +1 -1
- package/dist/execution-engine/node-execution-context/utils/normalize-items.js +3 -3
- package/dist/execution-engine/node-execution-context/utils/normalize-items.js.map +1 -1
- package/dist/execution-engine/node-execution-context/utils/request-helpers/authentication.js +5 -5
- package/dist/execution-engine/node-execution-context/utils/request-helpers/authentication.js.map +1 -1
- package/dist/execution-engine/node-execution-context/utils/request-helpers/factory.js +2 -2
- package/dist/execution-engine/node-execution-context/utils/request-helpers/factory.js.map +1 -1
- package/dist/execution-engine/node-execution-context/utils/request-helpers/index.d.ts +0 -1
- package/dist/execution-engine/node-execution-context/utils/request-helpers/index.js +2 -1
- package/dist/execution-engine/node-execution-context/utils/request-helpers/index.js.map +1 -1
- package/dist/execution-engine/node-execution-context/utils/request-helpers/legacy-request-adapter.d.ts +1 -1
- package/dist/execution-engine/node-execution-context/utils/request-helpers/legacy-request-adapter.js +18 -22
- package/dist/execution-engine/node-execution-context/utils/request-helpers/legacy-request-adapter.js.map +1 -1
- package/dist/execution-engine/node-execution-context/utils/request-helpers/oauth.js +19 -11
- package/dist/execution-engine/node-execution-context/utils/request-helpers/oauth.js.map +1 -1
- package/dist/execution-engine/node-execution-context/utils/request-helpers/pagination.js +4 -5
- package/dist/execution-engine/node-execution-context/utils/request-helpers/pagination.js.map +1 -1
- package/dist/execution-engine/node-execution-context/utils/webhook-helper-functions.js +7 -4
- package/dist/execution-engine/node-execution-context/utils/webhook-helper-functions.js.map +1 -1
- package/dist/execution-engine/node-execution-context/webhook-context.d.ts +2 -1
- package/dist/execution-engine/node-execution-context/webhook-context.js +11 -4
- package/dist/execution-engine/node-execution-context/webhook-context.js.map +1 -1
- package/dist/execution-engine/scheduled-task-manager.d.ts +5 -1
- package/dist/execution-engine/scheduled-task-manager.js +42 -1
- package/dist/execution-engine/scheduled-task-manager.js.map +1 -1
- package/dist/execution-engine/ssh-clients-manager.js +1 -1
- package/dist/execution-engine/ssh-clients-manager.js.map +1 -1
- package/dist/execution-engine/triggers-and-pollers.js +3 -3
- package/dist/execution-engine/triggers-and-pollers.js.map +1 -1
- package/dist/execution-engine/workflow-active-triggers-state.d.ts +11 -0
- package/dist/execution-engine/workflow-active-triggers-state.js +31 -0
- package/dist/execution-engine/workflow-active-triggers-state.js.map +1 -0
- package/dist/execution-engine/workflow-execute.d.ts +2 -0
- package/dist/execution-engine/workflow-execute.js +45 -18
- package/dist/execution-engine/workflow-execute.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/instance-settings/instance-settings.js +1 -1
- package/dist/instance-settings/instance-settings.js.map +1 -1
- package/dist/interfaces.d.ts +1 -4
- package/dist/nodes-loader/directory-loader.js +4 -2
- package/dist/nodes-loader/directory-loader.js.map +1 -1
- package/dist/nodes-loader/package-directory-loader.js +1 -1
- package/dist/nodes-loader/package-directory-loader.js.map +1 -1
- package/dist/storage.config.d.ts +3 -3
- package/dist/storage.config.js +3 -2
- package/dist/storage.config.js.map +1 -1
- package/package.json +15 -21
- package/dist/execution-engine/active-workflows.d.ts +0 -26
- package/dist/execution-engine/active-workflows.js +0 -180
- package/dist/execution-engine/active-workflows.js.map +0 -1
- package/dist/execution-engine/node-execution-context/utils/parse-incoming-message.d.ts +0 -16
- package/dist/execution-engine/node-execution-context/utils/parse-incoming-message.js +0 -75
- package/dist/execution-engine/node-execution-context/utils/parse-incoming-message.js.map +0 -1
- package/dist/execution-engine/node-execution-context/utils/request-helpers/axios-config.d.ts +0 -1
- package/dist/execution-engine/node-execution-context/utils/request-helpers/axios-config.js +0 -35
- package/dist/execution-engine/node-execution-context/utils/request-helpers/axios-config.js.map +0 -1
- package/dist/execution-engine/node-execution-context/utils/request-helpers/axios-utils.d.ts +0 -24
- package/dist/execution-engine/node-execution-context/utils/request-helpers/axios-utils.js +0 -257
- package/dist/execution-engine/node-execution-context/utils/request-helpers/axios-utils.js.map +0 -1
- package/dist/execution-engine/node-execution-context/utils/request-helpers/http-request.d.ts +0 -7
- package/dist/execution-engine/node-execution-context/utils/request-helpers/http-request.js +0 -146
- package/dist/execution-engine/node-execution-context/utils/request-helpers/http-request.js.map +0 -1
- package/dist/execution-engine/node-execution-context/utils/request-helpers/outbound-user-agent.d.ts +0 -4
- package/dist/execution-engine/node-execution-context/utils/request-helpers/outbound-user-agent.js +0 -40
- package/dist/execution-engine/node-execution-context/utils/request-helpers/outbound-user-agent.js.map +0 -1
- package/dist/http-proxy.d.ts +0 -6
- package/dist/http-proxy.js +0 -109
- package/dist/http-proxy.js.map +0 -1
- package/dist/ssrf/dns-resolver.d.ts +0 -13
- package/dist/ssrf/dns-resolver.js +0 -93
- package/dist/ssrf/dns-resolver.js.map +0 -1
- package/dist/ssrf/hostname-matcher.d.ts +0 -6
- package/dist/ssrf/hostname-matcher.js +0 -38
- package/dist/ssrf/hostname-matcher.js.map +0 -1
- package/dist/ssrf/in-memory-dns-cache.service.d.ts +0 -11
- package/dist/ssrf/in-memory-dns-cache.service.js +0 -61
- package/dist/ssrf/in-memory-dns-cache.service.js.map +0 -1
- package/dist/ssrf/index.d.ts +0 -5
- package/dist/ssrf/index.js +0 -10
- package/dist/ssrf/index.js.map +0 -1
- package/dist/ssrf/ip-range-builder.d.ts +0 -10
- package/dist/ssrf/ip-range-builder.js +0 -52
- package/dist/ssrf/ip-range-builder.js.map +0 -1
- package/dist/ssrf/ssrf-blocked-ip.error.d.ts +0 -6
- package/dist/ssrf/ssrf-blocked-ip.error.js +0 -21
- package/dist/ssrf/ssrf-blocked-ip.error.js.map +0 -1
- package/dist/ssrf/ssrf-protection.service.d.ts +0 -30
- package/dist/ssrf/ssrf-protection.service.js +0 -159
- package/dist/ssrf/ssrf-protection.service.js.map +0 -1
package/dist/http-proxy.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createHttpProxyAgent = createHttpProxyAgent;
|
|
7
|
-
exports.createHttpsProxyAgent = createHttpsProxyAgent;
|
|
8
|
-
exports.installGlobalProxyAgent = installGlobalProxyAgent;
|
|
9
|
-
exports.uninstallGlobalProxyAgent = uninstallGlobalProxyAgent;
|
|
10
|
-
const http_1 = __importDefault(require("http"));
|
|
11
|
-
const http_proxy_agent_1 = require("http-proxy-agent");
|
|
12
|
-
const https_1 = __importDefault(require("https"));
|
|
13
|
-
const https_proxy_agent_1 = require("https-proxy-agent");
|
|
14
|
-
const n8n_workflow_1 = require("n8n-workflow");
|
|
15
|
-
const proxy_from_env_1 = __importDefault(require("proxy-from-env"));
|
|
16
|
-
function buildTargetUrl(hostname, port, protocol) {
|
|
17
|
-
const defaultPort = protocol === 'https' ? 443 : 80;
|
|
18
|
-
const portSuffix = port === defaultPort ? '' : `:${port}`;
|
|
19
|
-
return `${protocol}://${hostname}${portSuffix}`;
|
|
20
|
-
}
|
|
21
|
-
function extractHostInfo(options, defaultPort) {
|
|
22
|
-
const hostname = options.hostname ?? options.host ?? 'localhost';
|
|
23
|
-
const port = typeof options.port === 'string' ? parseInt(options.port, 10) : (options.port ?? defaultPort);
|
|
24
|
-
return { hostname: String(hostname), port: Number(port) };
|
|
25
|
-
}
|
|
26
|
-
function getOrCreateProxyAgent(cache, proxyUrl, createAgent) {
|
|
27
|
-
let proxyAgent = cache.get(proxyUrl);
|
|
28
|
-
if (!proxyAgent) {
|
|
29
|
-
proxyAgent = createAgent(proxyUrl);
|
|
30
|
-
cache.set(proxyUrl, proxyAgent);
|
|
31
|
-
}
|
|
32
|
-
return proxyAgent;
|
|
33
|
-
}
|
|
34
|
-
function createFallbackAgent(agentClass) {
|
|
35
|
-
return new agentClass();
|
|
36
|
-
}
|
|
37
|
-
class HttpProxyManager extends http_1.default.Agent {
|
|
38
|
-
constructor() {
|
|
39
|
-
super(...arguments);
|
|
40
|
-
this.proxyAgentCache = new Map();
|
|
41
|
-
this.fallbackAgent = createFallbackAgent(http_1.default.Agent);
|
|
42
|
-
}
|
|
43
|
-
addRequest(req, options) {
|
|
44
|
-
const { hostname, port } = extractHostInfo(options, 80);
|
|
45
|
-
const targetUrl = buildTargetUrl(hostname, port, 'http');
|
|
46
|
-
const proxyUrl = proxy_from_env_1.default.getProxyForUrl(targetUrl);
|
|
47
|
-
if (proxyUrl) {
|
|
48
|
-
const proxyAgent = getOrCreateProxyAgent(this.proxyAgentCache, proxyUrl, (url) => new http_proxy_agent_1.HttpProxyAgent(url));
|
|
49
|
-
return proxyAgent.addRequest(req, options);
|
|
50
|
-
}
|
|
51
|
-
return this.fallbackAgent.addRequest(req, options);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
class HttpsProxyManager extends https_1.default.Agent {
|
|
55
|
-
constructor() {
|
|
56
|
-
super(...arguments);
|
|
57
|
-
this.proxyAgentCache = new Map();
|
|
58
|
-
this.fallbackAgent = createFallbackAgent(https_1.default.Agent);
|
|
59
|
-
}
|
|
60
|
-
addRequest(req, options) {
|
|
61
|
-
const { hostname, port } = extractHostInfo(options, 443);
|
|
62
|
-
const targetUrl = buildTargetUrl(hostname, port, 'https');
|
|
63
|
-
const proxyUrl = proxy_from_env_1.default.getProxyForUrl(targetUrl);
|
|
64
|
-
if (proxyUrl) {
|
|
65
|
-
const proxyAgent = getOrCreateProxyAgent(this.proxyAgentCache, proxyUrl, (url) => new https_proxy_agent_1.HttpsProxyAgent(url));
|
|
66
|
-
return proxyAgent.addRequest(req, options);
|
|
67
|
-
}
|
|
68
|
-
return this.fallbackAgent.addRequest(req, options);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
function createHttpProxyAgent(customProxyUrl = null, targetUrl, options) {
|
|
72
|
-
const proxyUrl = customProxyUrl ?? proxy_from_env_1.default.getProxyForUrl(targetUrl);
|
|
73
|
-
if (proxyUrl) {
|
|
74
|
-
return new http_proxy_agent_1.HttpProxyAgent(proxyUrl, options);
|
|
75
|
-
}
|
|
76
|
-
return new http_1.default.Agent(options);
|
|
77
|
-
}
|
|
78
|
-
function createHttpsProxyAgent(customProxyUrl = null, targetUrl, options) {
|
|
79
|
-
const proxyUrl = customProxyUrl ?? proxy_from_env_1.default.getProxyForUrl(targetUrl);
|
|
80
|
-
if (proxyUrl) {
|
|
81
|
-
return new https_proxy_agent_1.HttpsProxyAgent(proxyUrl, options);
|
|
82
|
-
}
|
|
83
|
-
return new https_1.default.Agent(options);
|
|
84
|
-
}
|
|
85
|
-
function hasProxyEnvironmentVariables() {
|
|
86
|
-
return Boolean(process.env.HTTP_PROXY ??
|
|
87
|
-
process.env.http_proxy ??
|
|
88
|
-
process.env.HTTPS_PROXY ??
|
|
89
|
-
process.env.https_proxy ??
|
|
90
|
-
process.env.ALL_PROXY ??
|
|
91
|
-
process.env.all_proxy);
|
|
92
|
-
}
|
|
93
|
-
function installGlobalProxyAgent() {
|
|
94
|
-
if (hasProxyEnvironmentVariables()) {
|
|
95
|
-
n8n_workflow_1.LoggerProxy.debug('Installing global HTTP proxy agents', {
|
|
96
|
-
HTTP_PROXY: process.env.HTTP_PROXY ?? process.env.http_proxy,
|
|
97
|
-
HTTPS_PROXY: process.env.HTTPS_PROXY ?? process.env.https_proxy,
|
|
98
|
-
NO_PROXY: process.env.NO_PROXY ?? process.env.no_proxy,
|
|
99
|
-
ALL_PROXY: process.env.ALL_PROXY ?? process.env.all_proxy,
|
|
100
|
-
});
|
|
101
|
-
http_1.default.globalAgent = new HttpProxyManager();
|
|
102
|
-
https_1.default.globalAgent = new HttpsProxyManager();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
function uninstallGlobalProxyAgent() {
|
|
106
|
-
http_1.default.globalAgent = new http_1.default.Agent();
|
|
107
|
-
https_1.default.globalAgent = new https_1.default.Agent();
|
|
108
|
-
}
|
|
109
|
-
//# sourceMappingURL=http-proxy.js.map
|
package/dist/http-proxy.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-proxy.js","sourceRoot":"","sources":["../src/http-proxy.ts"],"names":[],"mappings":";;;;;AA8FA,oDAYC;AAED,sDAYC;AAaD,0DAYC;AAED,8DAGC;AAtJD,gDAAwB;AACxB,uDAAkD;AAClD,kDAA0B;AAC1B,yDAAoD;AACpD,+CAA2C;AAC3C,oEAA0C;AAM1C,SAAS,cAAc,CAAC,QAAgB,EAAE,IAAY,EAAE,QAA0B;IACjF,MAAM,WAAW,GAAG,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACpD,MAAM,UAAU,GAAG,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;IAC1D,OAAO,GAAG,QAAQ,MAAM,QAAQ,GAAG,UAAU,EAAE,CAAC;AACjD,CAAC;AAED,SAAS,eAAe,CACvB,OAA4B,EAC5B,WAAmB;IAEnB,MAAM,QAAQ,GAAG,OAAO,CAAC,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AAE,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS;SACzD,CAAC,CAAC;QAEH,cAAI,CAAC,WAAW,GAAG,IAAI,gBAAgB,EAAE,CAAC;QAC1C,eAAK,CAAC,WAAW,GAAG,IAAI,iBAAiB,EAAE,CAAC;IAC7C,CAAC;AACF,CAAC;AAED,SAAgB,yBAAyB;IACxC,cAAI,CAAC,WAAW,GAAG,IAAI,cAAI,CAAC,KAAK,EAAE,CAAC;IACpC,eAAK,CAAC,WAAW,GAAG,IAAI,eAAK,CAAC,KAAK,EAAE,CAAC;AACvC,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { LookupAddress, LookupOptions } from 'node:dns';
|
|
2
|
-
import { InMemoryDnsCache } from './in-memory-dns-cache.service';
|
|
3
|
-
export type DnsLookupOptions = Pick<LookupOptions, 'all' | 'family' | 'order' | 'verbatim' | 'hints'>;
|
|
4
|
-
export declare class DnsResolver {
|
|
5
|
-
private readonly dnsCache;
|
|
6
|
-
private readonly inFlightByCacheKey;
|
|
7
|
-
constructor(dnsCache: InMemoryDnsCache);
|
|
8
|
-
lookup(hostname: string, options?: DnsLookupOptions): Promise<LookupAddress[]>;
|
|
9
|
-
private doLookup;
|
|
10
|
-
private buildCacheKey;
|
|
11
|
-
private normalizeOptions;
|
|
12
|
-
private normalizeIpFamily;
|
|
13
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.DnsResolver = void 0;
|
|
13
|
-
const di_1 = require("@n8n/di");
|
|
14
|
-
const node_dns_1 = require("node:dns");
|
|
15
|
-
const in_memory_dns_cache_service_1 = require("./in-memory-dns-cache.service");
|
|
16
|
-
const LOOKUP_CACHE_TTL_SECONDS = 1;
|
|
17
|
-
let DnsResolver = class DnsResolver {
|
|
18
|
-
constructor(dnsCache) {
|
|
19
|
-
this.dnsCache = dnsCache;
|
|
20
|
-
this.inFlightByCacheKey = new Map();
|
|
21
|
-
}
|
|
22
|
-
async lookup(hostname, options = {}) {
|
|
23
|
-
const normalized = this.normalizeOptions(options);
|
|
24
|
-
const cacheKey = this.buildCacheKey(hostname, normalized);
|
|
25
|
-
const cached = await this.dnsCache.get(cacheKey);
|
|
26
|
-
if (cached)
|
|
27
|
-
return cached;
|
|
28
|
-
const existing = this.inFlightByCacheKey.get(cacheKey);
|
|
29
|
-
if (existing)
|
|
30
|
-
return await existing;
|
|
31
|
-
const lookupPromise = (async () => {
|
|
32
|
-
const addresses = await this.doLookup(hostname, normalized);
|
|
33
|
-
if (addresses.length > 0) {
|
|
34
|
-
await this.dnsCache.set(cacheKey, addresses, LOOKUP_CACHE_TTL_SECONDS);
|
|
35
|
-
}
|
|
36
|
-
return addresses;
|
|
37
|
-
})();
|
|
38
|
-
this.inFlightByCacheKey.set(cacheKey, lookupPromise);
|
|
39
|
-
return await lookupPromise.finally(() => {
|
|
40
|
-
this.inFlightByCacheKey.delete(cacheKey);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
async doLookup(hostname, options) {
|
|
44
|
-
if (options.all) {
|
|
45
|
-
const records = await node_dns_1.promises.lookup(hostname, {
|
|
46
|
-
all: true,
|
|
47
|
-
family: options.family,
|
|
48
|
-
order: options.order,
|
|
49
|
-
verbatim: options.verbatim,
|
|
50
|
-
hints: options.hints,
|
|
51
|
-
});
|
|
52
|
-
return records;
|
|
53
|
-
}
|
|
54
|
-
const record = await node_dns_1.promises.lookup(hostname, {
|
|
55
|
-
all: false,
|
|
56
|
-
family: options.family,
|
|
57
|
-
order: options.order,
|
|
58
|
-
verbatim: options.verbatim,
|
|
59
|
-
hints: options.hints,
|
|
60
|
-
});
|
|
61
|
-
return [record];
|
|
62
|
-
}
|
|
63
|
-
buildCacheKey(hostname, options) {
|
|
64
|
-
const order = options.order ?? '-';
|
|
65
|
-
const verbatim = options.verbatim === undefined ? '-' : options.verbatim ? '1' : '0';
|
|
66
|
-
return `${hostname}|a:${options.all ? '1' : '0'}|f:${options.family}|o:${order}|v:${verbatim}|h:${options.hints ?? 0}`;
|
|
67
|
-
}
|
|
68
|
-
normalizeOptions(options) {
|
|
69
|
-
const all = options.all === true;
|
|
70
|
-
const family = this.normalizeIpFamily(options.family);
|
|
71
|
-
const order = options.order;
|
|
72
|
-
const verbatim = options.verbatim;
|
|
73
|
-
return { all, family, order, verbatim, hints: options.hints };
|
|
74
|
-
}
|
|
75
|
-
normalizeIpFamily(family) {
|
|
76
|
-
if (family === 4 || family === 6 || family === 0) {
|
|
77
|
-
return family;
|
|
78
|
-
}
|
|
79
|
-
if (family === 'IPv4') {
|
|
80
|
-
return 4;
|
|
81
|
-
}
|
|
82
|
-
if (family === 'IPv6') {
|
|
83
|
-
return 6;
|
|
84
|
-
}
|
|
85
|
-
return 0;
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
exports.DnsResolver = DnsResolver;
|
|
89
|
-
exports.DnsResolver = DnsResolver = __decorate([
|
|
90
|
-
(0, di_1.Service)(),
|
|
91
|
-
__metadata("design:paramtypes", [in_memory_dns_cache_service_1.InMemoryDnsCache])
|
|
92
|
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AQ,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,OAAO,CAAC,MAAM,MAAM,KAAK,MAAM,QAAQ,MAAM,OAAO,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC;IACxH,CAAC;IAEO,gBAAgB,CAAC,OAAyB;QACjD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,KAAK,IAAI,CAAC;QACjC,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACtD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC5B,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QAClC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;IAC/D,CAAC;IAEO,iBAAiB,CAAC,MAAkC;QAC3D,IAAI,MAAM,KAAK,CAAC,IAAI,MAAM,KAAK,CAAC,IAAI,MAAM,KAAK,CAAC,EAAE,CAAC;YAClD,OAAO,MAAM,CAAC;QACf,CAAC;QACD,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;YACvB,OAAO,CAAC,CAAC;QACV,CAAC;QACD,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;YACvB,OAAO,CAAC,CAAC;QACV,CAAC;QACD,OAAO,CAAC,CAAC;IACV,CAAC;CACD,CAAA;AAtFY,kCAAW;sBAAX,WAAW;IADvB,IAAA,YAAO,GAAE;qCAI8B,8CAAgB;GAH3C,WAAW,CAsFvB"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HostnameMatcher = void 0;
|
|
4
|
-
class HostnameMatcher {
|
|
5
|
-
constructor(patterns) {
|
|
6
|
-
this.parsed = patterns
|
|
7
|
-
.map((p) => this.normalizeHostname(p))
|
|
8
|
-
.filter(Boolean)
|
|
9
|
-
.map((value) => {
|
|
10
|
-
if (value.startsWith('*.')) {
|
|
11
|
-
const suffix = value.slice(1);
|
|
12
|
-
return { isWildcard: true, suffix };
|
|
13
|
-
}
|
|
14
|
-
return { isWildcard: false, value };
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
matches(hostname) {
|
|
18
|
-
const normalizedHostname = this.normalizeHostname(hostname);
|
|
19
|
-
for (const pattern of this.parsed) {
|
|
20
|
-
if (pattern.isWildcard) {
|
|
21
|
-
if (normalizedHostname.endsWith(pattern.suffix) &&
|
|
22
|
-
normalizedHostname.length > pattern.suffix.length) {
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
if (normalizedHostname === pattern.value) {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
normalizeHostname(hostname) {
|
|
34
|
-
return hostname.trim().toLowerCase();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.HostnameMatcher = HostnameMatcher;
|
|
38
|
-
//# sourceMappingURL=hostname-matcher.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hostname-matcher.js","sourceRoot":"","sources":["../../src/ssrf/hostname-matcher.ts"],"names":[],"mappings":";;;AAiBA,MAAa,eAAe;IAG3B,YAAY,QAA2B;QACtC,IAAI,CAAC,MAAM,GAAG,QAAQ;aACpB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;aACrC,MAAM,CAAC,OAAO,CAAC;aACf,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACd,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC5B,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAC9B,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;YACrC,CAAC;YACD,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QACrC,CAAC,CAAC,CAAC;IACL,CAAC;IAKD,OAAO,CAAC,QAAgB;QACvB,MAAM,kBAAkB,GAAG,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QAE5D,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACnC,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBAGxB,IACC,kBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC;oBAC3C,kBAAkB,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAChD,CAAC;oBACF,OAAO,IAAI,CAAC;gBACb,CAAC;gBACD,SAAS;YACV,CAAC;YAGD,IAAI,kBAAkB,KAAK,OAAO,CAAC,KAAK,EAAE,CAAC;gBAC1C,OAAO,IAAI,CAAC;YACb,CAAC;QACF,CAAC;QAED,OAAO,KAAK,CAAC;IACd,CAAC;IAEO,iBAAiB,CAAC,QAAgB;QACzC,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACtC,CAAC;CACD;AA/CD,0CA+CC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { SsrfProtectionConfig } from '@n8n/config';
|
|
2
|
-
import { LookupAddress } from 'node:dns';
|
|
3
|
-
export declare class InMemoryDnsCache {
|
|
4
|
-
private readonly ssrfConfig;
|
|
5
|
-
private cache;
|
|
6
|
-
constructor(ssrfConfig: SsrfProtectionConfig);
|
|
7
|
-
private ensureCache;
|
|
8
|
-
get(hostname: string): Promise<LookupAddress[] | undefined>;
|
|
9
|
-
set(hostname: string, ips: LookupAddress[], ttl: number): Promise<void>;
|
|
10
|
-
clear(): Promise<void>;
|
|
11
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.InMemoryDnsCache = void 0;
|
|
16
|
-
const config_1 = require("@n8n/config");
|
|
17
|
-
const constants_1 = require("@n8n/constants");
|
|
18
|
-
const di_1 = require("@n8n/di");
|
|
19
|
-
const cache_manager_1 = require("cache-manager");
|
|
20
|
-
const n8n_workflow_1 = require("n8n-workflow");
|
|
21
|
-
const node_assert_1 = __importDefault(require("node:assert"));
|
|
22
|
-
let InMemoryDnsCache = class InMemoryDnsCache {
|
|
23
|
-
constructor(ssrfConfig) {
|
|
24
|
-
this.ssrfConfig = ssrfConfig;
|
|
25
|
-
}
|
|
26
|
-
async ensureCache() {
|
|
27
|
-
if (!this.cache) {
|
|
28
|
-
const sizeCalculation = (item) => {
|
|
29
|
-
const str = (0, n8n_workflow_1.jsonStringify)(item, { replaceCircularRefs: true });
|
|
30
|
-
return new TextEncoder().encode(str).length;
|
|
31
|
-
};
|
|
32
|
-
this.cache = await (0, cache_manager_1.caching)('memory', {
|
|
33
|
-
maxSize: this.ssrfConfig.dnsCacheMaxSize,
|
|
34
|
-
sizeCalculation,
|
|
35
|
-
ttl: 0,
|
|
36
|
-
ttlResolution: 0,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
return this.cache;
|
|
40
|
-
}
|
|
41
|
-
async get(hostname) {
|
|
42
|
-
const cache = await this.ensureCache();
|
|
43
|
-
return await cache.get(hostname);
|
|
44
|
-
}
|
|
45
|
-
async set(hostname, ips, ttl) {
|
|
46
|
-
(0, node_assert_1.default)(ttl > 0, 'DNS cache TTL must be greater than 0');
|
|
47
|
-
const cache = await this.ensureCache();
|
|
48
|
-
const ttlMs = ttl * constants_1.Time.seconds.toMilliseconds;
|
|
49
|
-
await cache.set(hostname, ips, ttlMs);
|
|
50
|
-
}
|
|
51
|
-
async clear() {
|
|
52
|
-
const cache = await this.ensureCache();
|
|
53
|
-
await cache.reset();
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
exports.InMemoryDnsCache = InMemoryDnsCache;
|
|
57
|
-
exports.InMemoryDnsCache = InMemoryDnsCache = __decorate([
|
|
58
|
-
(0, di_1.Service)(),
|
|
59
|
-
__metadata("design:paramtypes", [config_1.SsrfProtectionConfig])
|
|
60
|
-
], InMemoryDnsCache);
|
|
61
|
-
//# sourceMappingURL=in-memory-dns-cache.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"in-memory-dns-cache.service.js","sourceRoot":"","sources":["../../src/ssrf/in-memory-dns-cache.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wCAAmD;AACnD,8CAAsC;AACtC,gCAAkC;AAElC,iDAAwC;AACxC,+CAA6C;AAC7C,8DAAiC;AAO1B,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAG5B,YAA6B,UAAgC;QAAhC,eAAU,GAAV,UAAU,CAAsB;IAAG,CAAC;IAEzD,KAAK,CAAC,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AA;AA7CY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,YAAO,GAAE;qCAIgC,6BAAoB;GAHjD,gBAAgB,CA6C5B"}
|
package/dist/ssrf/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { DnsResolver } from './dns-resolver';
|
|
2
|
-
export type { DnsLookupOptions } from './dns-resolver';
|
|
3
|
-
export { SsrfBlockedIpError } from './ssrf-blocked-ip.error';
|
|
4
|
-
export { SsrfProtectionService } from './ssrf-protection.service';
|
|
5
|
-
export type { SsrfBridge, SsrfCheckResult } from './ssrf-protection.service';
|
package/dist/ssrf/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SsrfProtectionService = exports.SsrfBlockedIpError = exports.DnsResolver = void 0;
|
|
4
|
-
var dns_resolver_1 = require("./dns-resolver");
|
|
5
|
-
Object.defineProperty(exports, "DnsResolver", { enumerable: true, get: function () { return dns_resolver_1.DnsResolver; } });
|
|
6
|
-
var ssrf_blocked_ip_error_1 = require("./ssrf-blocked-ip.error");
|
|
7
|
-
Object.defineProperty(exports, "SsrfBlockedIpError", { enumerable: true, get: function () { return ssrf_blocked_ip_error_1.SsrfBlockedIpError; } });
|
|
8
|
-
var ssrf_protection_service_1 = require("./ssrf-protection.service");
|
|
9
|
-
Object.defineProperty(exports, "SsrfProtectionService", { enumerable: true, get: function () { return ssrf_protection_service_1.SsrfProtectionService; } });
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
package/dist/ssrf/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ssrf/index.ts"],"names":[],"mappings":";;;AAAA,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AAEpB,iEAA6D;AAApD,2HAAA,kBAAkB,OAAA;AAC3B,qEAAkE;AAAzD,gIAAA,qBAAqB,OAAA"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BlockList } from 'node:net';
|
|
2
|
-
export interface IpRangeIssue {
|
|
3
|
-
entry: string;
|
|
4
|
-
error: string;
|
|
5
|
-
}
|
|
6
|
-
export interface IpRangeBuildResult {
|
|
7
|
-
list: BlockList;
|
|
8
|
-
issues: IpRangeIssue[];
|
|
9
|
-
}
|
|
10
|
-
export declare function buildIpRangeList(cidrRanges: readonly string[]): IpRangeBuildResult;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildIpRangeList = buildIpRangeList;
|
|
4
|
-
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
-
const node_net_1 = require("node:net");
|
|
6
|
-
const zod_1 = require("zod");
|
|
7
|
-
function buildIpRangeList(cidrRanges) {
|
|
8
|
-
const list = new node_net_1.BlockList();
|
|
9
|
-
const issues = [];
|
|
10
|
-
for (const rawEntry of cidrRanges) {
|
|
11
|
-
const entry = rawEntry.trim();
|
|
12
|
-
if (entry.length === 0) {
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
try {
|
|
16
|
-
const cidr = parseCidr(entry);
|
|
17
|
-
if (!cidr) {
|
|
18
|
-
issues.push({ entry, error: 'Invalid CIDR notation' });
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
list.addSubnet(cidr.network, cidr.prefix, cidr.family);
|
|
22
|
-
}
|
|
23
|
-
catch (e) {
|
|
24
|
-
const error = (0, n8n_workflow_1.ensureError)(e);
|
|
25
|
-
issues.push({ entry, error: `Failed to add IP range: ${error.message}` });
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return { list, issues };
|
|
29
|
-
}
|
|
30
|
-
function parseCidr(entry) {
|
|
31
|
-
const result = cidrSchema.safeParse(entry);
|
|
32
|
-
if (!result.success) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
const [network, prefixStr] = result.data.split('/');
|
|
36
|
-
const family = validateIp(network);
|
|
37
|
-
if (family === null) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
const prefix = Number.parseInt(prefixStr, 10);
|
|
41
|
-
return { network, prefix, family };
|
|
42
|
-
}
|
|
43
|
-
const cidrSchema = zod_1.z.string().cidr();
|
|
44
|
-
function validateIp(ip) {
|
|
45
|
-
const version = (0, node_net_1.isIP)(ip);
|
|
46
|
-
if (version === 4)
|
|
47
|
-
return 'ipv4';
|
|
48
|
-
if (version === 6)
|
|
49
|
-
return 'ipv6';
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=ip-range-builder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ip-range-builder.js","sourceRoot":"","sources":["../../src/ssrf/ip-range-builder.ts"],"names":[],"mappings":";;AAmBA,4CAyBC;AA5CD,+CAA2C;AAC3C,uCAA2C;AAC3C,6BAAwB;AAiBxB,SAAgB,gBAAgB,CAAC,UAA6B;IAC7D,MAAM,IAAI,GAAG,IAAI,oBAAS,EAAE,CAAC;IAC7B,MAAM,MAAM,GAAmB,EAAE,CAAC;IAElC,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC9B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,SAAS;QACV,CAAC;QAED,IAAI,CAAC;YACJ,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;YAC9B,IAAI,CAAC,IAAI,EAAE,CAAC;gBACX,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,uBAAuB,EAAE,CAAC,CAAC;gBACvD,SAAS;YACV,CAAC;YAED,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI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-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SsrfBlockedIpError = void 0;
|
|
4
|
-
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
-
class SsrfBlockedIpError extends n8n_workflow_1.UserError {
|
|
6
|
-
constructor(ip, hostname) {
|
|
7
|
-
const target = hostname ? `'${hostname}' (${ip})` : ip;
|
|
8
|
-
super('The request was blocked because it resolves to a restricted IP address', {
|
|
9
|
-
description: `The target ${target} is not allowed. ` +
|
|
10
|
-
'This is a security measure to prevent Server-Side Request Forgery (SSRF). ' +
|
|
11
|
-
'If you need to access internal resources, ask your n8n administrator to allowlist ' +
|
|
12
|
-
'the hostname or IP range in the environment configuration.',
|
|
13
|
-
extra: { ip, hostname },
|
|
14
|
-
});
|
|
15
|
-
this.name = 'SsrfBlockedIpError';
|
|
16
|
-
this.ip = ip;
|
|
17
|
-
this.hostname = hostname;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.SsrfBlockedIpError = SsrfBlockedIpError;
|
|
21
|
-
//# sourceMappingURL=ssrf-blocked-ip.error.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ssrf-blocked-ip.error.js","sourceRoot":"","sources":["../../src/ssrf/ssrf-blocked-ip.error.ts"],"names":[],"mappings":";;;AAAA,+CAAyC;AAKzC,MAAa,kBAAmB,SAAQ,wBAAS;IAIhD,YAAY,EAAU,EAAE,QAAiB;QACxC,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,QAAQ,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACvD,KAAK,CAAC,wEAAwE,EAAE;YAC/E,WAAW,EACV,cAAc,MAAM,mBAAmB;gBACvC,4EAA4E;gBAC5E,oFAAoF;gBACpF,4DAA4D;YAC7D,KAAK,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE;SACvB,CAAC,CAAC;QAEH,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,CAAC;CACD;AAnBD,gDAmBC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@n8n/backend-common';
|
|
2
|
-
import { SsrfProtectionConfig } from '@n8n/config';
|
|
3
|
-
import { Result } from 'n8n-workflow';
|
|
4
|
-
import type { LookupFunction } from 'node:net';
|
|
5
|
-
import { DnsResolver } from './dns-resolver';
|
|
6
|
-
export type SsrfCheckResult = Result<void, Error>;
|
|
7
|
-
export interface SsrfBridge {
|
|
8
|
-
validateIp(ip: string): SsrfCheckResult;
|
|
9
|
-
validateUrl(url: string | URL): Promise<SsrfCheckResult>;
|
|
10
|
-
validateRedirectSync(url: string): void;
|
|
11
|
-
createSecureLookup(): LookupFunction;
|
|
12
|
-
}
|
|
13
|
-
export declare class SsrfProtectionService implements SsrfBridge {
|
|
14
|
-
private readonly ssrfConfig;
|
|
15
|
-
private readonly dnsResolver;
|
|
16
|
-
private readonly logger;
|
|
17
|
-
private readonly blockedIps;
|
|
18
|
-
private readonly allowedIps;
|
|
19
|
-
private readonly allowedHostnameMatcher;
|
|
20
|
-
constructor(ssrfConfig: SsrfProtectionConfig, dnsResolver: DnsResolver, logger: Logger);
|
|
21
|
-
validateUrl(url: string | URL): Promise<SsrfCheckResult>;
|
|
22
|
-
validateIp(ip: string): SsrfCheckResult;
|
|
23
|
-
createSecureLookup(): LookupFunction;
|
|
24
|
-
validateRedirectSync(url: string): void;
|
|
25
|
-
private normalizeIpInHostname;
|
|
26
|
-
private secureLookupAsync;
|
|
27
|
-
private lookupAndValidate;
|
|
28
|
-
private tryParseUrl;
|
|
29
|
-
private getIpFamily;
|
|
30
|
-
}
|