n8n-core 1.122.2 → 1.122.4
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/build.tsbuildinfo +1 -1
- package/dist/execution-engine/node-execution-context/utils/file-system-helper-functions.d.ts +0 -1
- package/dist/execution-engine/node-execution-context/utils/file-system-helper-functions.js +55 -18
- package/dist/execution-engine/node-execution-context/utils/file-system-helper-functions.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getFileSystemHelperFunctions = void 0;
|
|
4
|
-
exports.isFilePathBlocked = isFilePathBlocked;
|
|
5
4
|
const backend_common_1 = require("@n8n/backend-common");
|
|
5
|
+
const config_1 = require("@n8n/config");
|
|
6
6
|
const di_1 = require("@n8n/di");
|
|
7
7
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
8
8
|
const node_fs_1 = require("node:fs");
|
|
@@ -21,33 +21,50 @@ const getAllowedPaths = () => {
|
|
|
21
21
|
.filter((path) => path);
|
|
22
22
|
return allowedPaths;
|
|
23
23
|
};
|
|
24
|
-
async function
|
|
25
|
-
const allowedPaths = getAllowedPaths();
|
|
26
|
-
let resolvedFilePath = '';
|
|
24
|
+
async function resolvePath(path) {
|
|
27
25
|
try {
|
|
28
|
-
|
|
26
|
+
return (await (0, promises_1.realpath)(path));
|
|
29
27
|
}
|
|
30
28
|
catch (error) {
|
|
31
29
|
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
throw error;
|
|
30
|
+
return (0, node_path_1.resolve)(path.toString());
|
|
36
31
|
}
|
|
32
|
+
throw error;
|
|
37
33
|
}
|
|
34
|
+
}
|
|
35
|
+
function isFilePatternBlocked(resolvedFilePath) {
|
|
36
|
+
const { blockFilePatterns } = di_1.Container.get(config_1.SecurityConfig);
|
|
37
|
+
return blockFilePatterns
|
|
38
|
+
.split(';')
|
|
39
|
+
.map((pattern) => pattern.trim())
|
|
40
|
+
.filter((pattern) => pattern)
|
|
41
|
+
.some((pattern) => {
|
|
42
|
+
try {
|
|
43
|
+
return new RegExp(pattern, 'mi').test(resolvedFilePath);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function isFilePathBlocked(resolvedFilePath) {
|
|
51
|
+
const allowedPaths = getAllowedPaths();
|
|
38
52
|
const blockFileAccessToN8nFiles = process.env[constants_1.BLOCK_FILE_ACCESS_TO_N8N_FILES] !== 'false';
|
|
39
53
|
const restrictedPaths = blockFileAccessToN8nFiles ? getN8nRestrictedPaths() : [];
|
|
40
54
|
if (restrictedPaths.some((restrictedPath) => (0, backend_common_1.isContainedWithin)(restrictedPath, resolvedFilePath))) {
|
|
41
55
|
return true;
|
|
42
56
|
}
|
|
57
|
+
if (isFilePatternBlocked(resolvedFilePath)) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
43
60
|
if (allowedPaths.length) {
|
|
44
61
|
return !allowedPaths.some((allowedPath) => (0, backend_common_1.isContainedWithin)(allowedPath, resolvedFilePath));
|
|
45
62
|
}
|
|
46
63
|
return false;
|
|
47
64
|
}
|
|
48
65
|
const getFileSystemHelperFunctions = (node) => ({
|
|
49
|
-
async createReadStream(
|
|
50
|
-
if (
|
|
66
|
+
async createReadStream(resolvedFilePath) {
|
|
67
|
+
if (isFilePathBlocked(resolvedFilePath)) {
|
|
51
68
|
const allowedPaths = getAllowedPaths();
|
|
52
69
|
const message = allowedPaths.length ? ` Allowed paths: ${allowedPaths.join(', ')}` : '';
|
|
53
70
|
throw new n8n_workflow_1.NodeOperationError(node, `Access to the file is not allowed.${message}`, {
|
|
@@ -55,30 +72,50 @@ const getFileSystemHelperFunctions = (node) => ({
|
|
|
55
72
|
});
|
|
56
73
|
}
|
|
57
74
|
try {
|
|
58
|
-
await (0, promises_1.access)(
|
|
75
|
+
await (0, promises_1.access)(resolvedFilePath);
|
|
59
76
|
}
|
|
60
77
|
catch (error) {
|
|
61
78
|
throw error.code === 'ENOENT'
|
|
62
79
|
?
|
|
63
80
|
new n8n_workflow_1.NodeOperationError(node, error, {
|
|
64
|
-
message: `The file "${String(
|
|
81
|
+
message: `The file "${String(resolvedFilePath)}" could not be accessed.`,
|
|
65
82
|
level: 'warning',
|
|
66
83
|
})
|
|
67
84
|
: error;
|
|
68
85
|
}
|
|
69
|
-
|
|
86
|
+
const stream = (0, node_fs_1.createReadStream)(resolvedFilePath, {
|
|
87
|
+
flags: (node_fs_1.constants.O_RDONLY | node_fs_1.constants.O_NOFOLLOW),
|
|
88
|
+
});
|
|
89
|
+
return await new Promise((resolve, reject) => {
|
|
90
|
+
stream.once('error', (error) => {
|
|
91
|
+
if (error.code === 'ELOOP') {
|
|
92
|
+
reject(new n8n_workflow_1.NodeOperationError(node, error, {
|
|
93
|
+
level: 'warning',
|
|
94
|
+
description: 'Symlinks are not allowed.',
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
reject(error);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
stream.once('open', () => resolve(stream));
|
|
102
|
+
});
|
|
70
103
|
},
|
|
71
104
|
getStoragePath() {
|
|
72
105
|
return (0, backend_common_1.safeJoinPath)(di_1.Container.get(instance_settings_1.InstanceSettings).n8nFolder, `storage/${node.type}`);
|
|
73
106
|
},
|
|
74
|
-
async writeContentToFile(
|
|
75
|
-
if (
|
|
76
|
-
throw new n8n_workflow_1.NodeOperationError(node, `The file "${String(
|
|
107
|
+
async writeContentToFile(resolvedFilePath, content, flag) {
|
|
108
|
+
if (isFilePathBlocked(resolvedFilePath)) {
|
|
109
|
+
throw new n8n_workflow_1.NodeOperationError(node, `The file "${String(resolvedFilePath)}" is not writable.`, {
|
|
77
110
|
level: 'warning',
|
|
78
111
|
});
|
|
79
112
|
}
|
|
80
|
-
return await (0, promises_1.writeFile)(
|
|
113
|
+
return await (0, promises_1.writeFile)(resolvedFilePath, content, {
|
|
114
|
+
encoding: 'binary',
|
|
115
|
+
flag: (flag ?? 0) | node_fs_1.constants.O_NOFOLLOW,
|
|
116
|
+
});
|
|
81
117
|
},
|
|
118
|
+
resolvePath,
|
|
82
119
|
isFilePathBlocked,
|
|
83
120
|
});
|
|
84
121
|
exports.getFileSystemHelperFunctions = getFileSystemHelperFunctions;
|
package/dist/execution-engine/node-execution-context/utils/file-system-helper-functions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-system-helper-functions.js","sourceRoot":"","sources":["../../../../src/execution-engine/node-execution-context/utils/file-system-helper-functions.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"file-system-helper-functions.js","sourceRoot":"","sources":["../../../../src/execution-engine/node-execution-context/utils/file-system-helper-functions.ts"],"names":[],"mappings":";;;AAAA,wDAAsE;AACtE,wCAA6C;AAC7C,gCAAoC;AACpC,+CAAkD;AAGlD,qCAAsD;AACtD,+CAI0B;AAC1B,yCAAoC;AAEpC,2CAQqB;AACrB,2DAAuD;AAEvD,MAAM,eAAe,GAAG,GAAG,EAAE;IAC5B,MAAM,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC,mCAAuB,CAAC,CAAC;IAClE,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC3B,OAAO,EAAE,CAAC;IACX,CAAC;IACD,MAAM,YAAY,GAAG,oBAAoB;SACvC,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IACzB,OAAO,YAAY,CAAC;AACrB,CAAC,CAAC;AAEF,KAAK,UAAU,WAAW,CAAC,IAAc;IACxC,IAAI,CA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OAAO,eAAe,CAAC;AACxB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-core",
|
|
3
|
-
"version": "1.122.
|
|
3
|
+
"version": "1.122.4",
|
|
4
4
|
"description": "Core functionality of n8n",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -58,13 +58,13 @@
|
|
|
58
58
|
"winston": "3.14.2",
|
|
59
59
|
"xml2js": "0.6.2",
|
|
60
60
|
"zod": "3.25.67",
|
|
61
|
-
"@n8n/backend-common": "0.33.
|
|
61
|
+
"@n8n/backend-common": "0.33.3",
|
|
62
|
+
"@n8n/config": "1.65.2",
|
|
62
63
|
"@n8n/client-oauth2": "0.33.0",
|
|
63
64
|
"@n8n/constants": "0.14.0",
|
|
64
|
-
"@n8n/decorators": "0.33.
|
|
65
|
-
"@n8n/config": "1.65.0",
|
|
65
|
+
"@n8n/decorators": "0.33.2",
|
|
66
66
|
"@n8n/di": "0.10.0",
|
|
67
|
-
"n8n-workflow": "1.120.
|
|
67
|
+
"n8n-workflow": "1.120.2"
|
|
68
68
|
},
|
|
69
69
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
70
70
|
"homepage": "https://n8n.io",
|