@ezs/basics 1.23.0 → 1.23.1
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/CHANGELOG.md +17 -0
- package/lib/file-load.js +12 -7
- package/lib/file-save.js +9 -1
- package/lib/obj-standardize.js +1 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,23 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.23.1](https://github.com/Inist-CNRS/ezs/compare/@ezs/basics@1.23.0...@ezs/basics@1.23.1) (2023-01-28)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* 🐛 improve security in file access ([6942a8e](https://github.com/Inist-CNRS/ezs/commit/6942a8e039a05d820d8643fa0908287a0a6aefda))
|
|
12
|
+
* 🐛 objstandarize lost boolean values ([dca4714](https://github.com/Inist-CNRS/ezs/commit/dca4714c984214f422f9ed8951575de66af0f0ce))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Reverts
|
|
16
|
+
|
|
17
|
+
* Revert "chore: 🤖 use lerna exec instead bootstrap" ([56375ee](https://github.com/Inist-CNRS/ezs/commit/56375ee2bd7e9f69f61da3993ab569ca1c16c547))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
6
23
|
# [1.23.0](https://github.com/Inist-CNRS/ezs/compare/@ezs/basics@1.22.7...@ezs/basics@1.23.0) (2023-01-20)
|
|
7
24
|
|
|
8
25
|
|
package/lib/file-load.js
CHANGED
|
@@ -13,6 +13,10 @@ var _path = require("path");
|
|
|
13
13
|
|
|
14
14
|
var _os = require("os");
|
|
15
15
|
|
|
16
|
+
var _higherPath = _interopRequireDefault(require("higher-path"));
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
16
20
|
/**
|
|
17
21
|
* Take `Object` containing filename et throw content by chunk
|
|
18
22
|
*
|
|
@@ -52,18 +56,19 @@ async function FILELoad(data, feed) {
|
|
|
52
56
|
return;
|
|
53
57
|
}
|
|
54
58
|
|
|
55
|
-
const cwd = process.cwd();
|
|
56
|
-
const tpd = (0, _os.tmpdir)();
|
|
57
59
|
const compress = this.getParam('compress', false);
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
+
const location = (0, _path.normalize)(this.getParam('location', '/'));
|
|
61
|
+
const locations = [(0, _higherPath.default)((0, _os.tmpdir)(), location), (0, _higherPath.default)(process.cwd(), location)];
|
|
62
|
+
const filename = locations.filter(Boolean).map(dir => (0, _path.resolve)(dir, String(data).trim())).filter(fil => (0, _fs.existsSync)(fil)).shift();
|
|
60
63
|
|
|
61
|
-
if (!
|
|
62
|
-
feed.
|
|
64
|
+
if (!filename) {
|
|
65
|
+
feed.stop(new Error('File location check failed.'));
|
|
63
66
|
return;
|
|
64
67
|
}
|
|
65
68
|
|
|
66
|
-
|
|
69
|
+
(0, _fs.accessSync)((0, _path.dirname)(filename), _fs.constants.R_OK | _fs.constants.W_OK);
|
|
70
|
+
(0, _fs.accessSync)(filename, _fs.constants.R_OK | _fs.constants.W_OK);
|
|
71
|
+
const stream = compress ? (0, _fs.createReadStream)(filename).pipe((0, _zlib.createGunzip)()) : (0, _fs.createReadStream)(filename);
|
|
67
72
|
await feed.flow(stream);
|
|
68
73
|
return;
|
|
69
74
|
}
|
package/lib/file-save.js
CHANGED
|
@@ -68,13 +68,21 @@ const toJSONL = line => JSON.stringify(line).concat(eol);
|
|
|
68
68
|
function FILESave(data, feed) {
|
|
69
69
|
if (this.isFirst()) {
|
|
70
70
|
const identifier = String(this.getParam('identifier'));
|
|
71
|
-
|
|
71
|
+
|
|
72
|
+
const location = _path.default.normalize(this.getParam('location', (0, _os.tmpdir)()));
|
|
73
|
+
|
|
72
74
|
const compress = this.getParam('compress', false);
|
|
73
75
|
|
|
76
|
+
if (location.indexOf((0, _os.tmpdir)()) !== 0 && location.indexOf(process.cwd()) !== 0) {
|
|
77
|
+
feed.stop(new Error('File location check failed.'));
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
74
81
|
if (!_pathExists.default.sync(location)) {
|
|
75
82
|
_makeDir.default.sync(location);
|
|
76
83
|
}
|
|
77
84
|
|
|
85
|
+
(0, _fs.accessSync)(location, _fs.constants.R_OK | _fs.constants.W_OK);
|
|
78
86
|
const name = compress ? `${identifier}.gz` : identifier;
|
|
79
87
|
|
|
80
88
|
const filename = _path.default.resolve(location, name);
|
package/lib/obj-standardize.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ezs/basics",
|
|
3
3
|
"description": "Basics statements for EZS",
|
|
4
|
-
"version": "1.23.
|
|
4
|
+
"version": "1.23.1",
|
|
5
5
|
"author": "Nicolas Thouvenin <nthouvenin@gmail.com>",
|
|
6
6
|
"bugs": "https://github.com/Inist-CNRS/ezs/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"fetch-with-proxy": "3.0.1",
|
|
14
14
|
"flat": "5.0.2",
|
|
15
15
|
"get-stream": "6.0.1",
|
|
16
|
+
"higher-path": "1.0.0",
|
|
16
17
|
"lodash.escaperegexp": "4.1.2",
|
|
17
18
|
"lodash.get": "4.4.2",
|
|
18
19
|
"lodash.mapkeys": "4.6.0",
|
|
@@ -37,7 +38,7 @@
|
|
|
37
38
|
"directories": {
|
|
38
39
|
"test": "test"
|
|
39
40
|
},
|
|
40
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "c244731593d7181d55b1d0c20373e5a263f18f02",
|
|
41
42
|
"homepage": "https://github.com/Inist-CNRS/ezs/tree/master/packages/basics#readme",
|
|
42
43
|
"keywords": [
|
|
43
44
|
"ezs"
|