@nocobase/logger 2.2.23 → 2.2.24

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/config.d.ts CHANGED
@@ -7,6 +7,11 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  export declare const getLoggerLevel: () => string;
10
+ /**
11
+ * Resolve a directory inside the log root. Callers pass app names, plugin names and record ids, so the result is
12
+ * checked to stay under the root: `path.resolve` silently adopts an absolute segment and happily walks out of the
13
+ * root on `..`, which would turn any caller that forwards untrusted input into an arbitrary-directory write.
14
+ */
10
15
  export declare const getLoggerFilePath: (...paths: string[]) => string;
11
16
  export declare const getLoggerTransport: () => ('console' | 'file' | 'dailyRotateFile')[];
12
17
  export declare const getLoggerFormat: () => 'logfmt' | 'json' | 'delimiter' | 'console';
package/lib/config.js CHANGED
@@ -47,7 +47,12 @@ var import_path = __toESM(require("path"));
47
47
  var import_utils = require("@nocobase/utils");
48
48
  const getLoggerLevel = /* @__PURE__ */ __name(() => process.env.LOGGER_LEVEL || (process.env.APP_ENV === "development" ? "debug" : "info"), "getLoggerLevel");
49
49
  const getLoggerFilePath = /* @__PURE__ */ __name((...paths) => {
50
- return import_path.default.resolve((0, import_utils.storagePathJoin)("logs"), ...paths);
50
+ const root = import_path.default.resolve((0, import_utils.storagePathJoin)("logs"));
51
+ const resolved = import_path.default.resolve(root, ...paths);
52
+ if (resolved !== root && !resolved.startsWith(root + import_path.default.sep)) {
53
+ throw new Error(`log path ${paths.join("/")} escapes the log directory`);
54
+ }
55
+ return resolved;
51
56
  }, "getLoggerFilePath");
52
57
  const getLoggerTransport = /* @__PURE__ */ __name(() => (process.env.LOGGER_TRANSPORT || "console,dailyRotateFile").split(","), "getLoggerTransport");
53
58
  const getLoggerFormat = /* @__PURE__ */ __name(() => process.env.LOGGER_FORMAT || (process.env.APP_ENV === "development" ? "console" : "json"), "getLoggerFormat");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/logger",
3
- "version": "2.2.23",
3
+ "version": "2.2.24",
4
4
  "description": "nocobase logging library",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./lib/index.js",
@@ -11,7 +11,7 @@
11
11
  "directory": "packages/logger"
12
12
  },
13
13
  "dependencies": {
14
- "@nocobase/utils": "2.2.23",
14
+ "@nocobase/utils": "2.2.24",
15
15
  "chalk": "^4",
16
16
  "lodash": "^4.17.21",
17
17
  "triple-beam": "^1.4.1",
@@ -19,5 +19,5 @@
19
19
  "winston-daily-rotate-file": "^5.0.0",
20
20
  "winston-transport": "^4.7.0"
21
21
  },
22
- "gitHead": "71852bf1353c21818600ffe7b2a38aa68b5e47e6"
22
+ "gitHead": "b067d4c18834112e59bb72b2084e872c59d64f9c"
23
23
  }