@vtex/api 6.45.6 → 6.45.7

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 CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [6.45.7] - 2022-02-23
11
+
12
+ ### Fixed
13
+
14
+ - Remove sensitive data from logs.
15
+
10
16
  ## [6.45.6] - 2021-10-26
11
17
 
12
18
  ### Fixed
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const constants_1 = require("../../constants");
4
4
  const error_1 = require("../../utils/error");
5
+ const log_1 = require("../../utils/log");
5
6
  const console_1 = require("./console");
6
7
  const linked = !!process.env.VTEX_APP_LINK;
7
8
  const app = constants_1.APP.ID;
@@ -22,6 +23,7 @@ class Logger {
22
23
  this.log = (message, level) => {
23
24
  var _a;
24
25
  const data = message ? error_1.cleanError(message) : EMPTY_MESSAGE;
26
+ log_1.cleanLog(data);
25
27
  /* tslint:disable:object-literal-sort-keys */
26
28
  const inflatedLog = {
27
29
  __VTEX_IO_LOG: true,
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const ramda_1 = require("ramda");
4
4
  const error_1 = require("../../../../../utils/error");
5
+ const log_1 = require("../../../../../utils/log");
5
6
  const ERROR_FIELD_WHITELIST = ['message', 'path', 'stack', 'extensions', 'statusCode', 'name', 'headers', 'originalError', 'code'];
6
7
  const QUERY_FIELDS = ['query', 'operationName', 'variables'];
7
8
  const trimVariables = (variables) => {
@@ -48,8 +49,8 @@ const formatError = (error, details) => {
48
49
  formattedError.extensions.exception = {
49
50
  message: formattedError.originalError.message,
50
51
  name: formattedError.originalError.name,
51
- ...ramda_1.omit(error_1.SENSITIVE_EXCEPTION_FIELDS, formattedError.originalError),
52
- sensitive: ramda_1.pick(error_1.SENSITIVE_EXCEPTION_FIELDS, formattedError.originalError),
52
+ ...ramda_1.omit(log_1.FIRST_LEVEL_SENSITIVE_FIELDS, formattedError.originalError),
53
+ sensitive: ramda_1.pick(log_1.FIRST_LEVEL_SENSITIVE_FIELDS, formattedError.originalError),
53
54
  };
54
55
  }
55
56
  else {
@@ -59,8 +60,8 @@ const formatError = (error, details) => {
59
60
  const extendedException = {
60
61
  message: formattedError.originalError.message,
61
62
  name: formattedError.originalError.name,
62
- ...ramda_1.omit(error_1.SENSITIVE_EXCEPTION_FIELDS, mergedException),
63
- sensitive: ramda_1.pick(error_1.SENSITIVE_EXCEPTION_FIELDS, mergedException),
63
+ ...ramda_1.omit(log_1.FIRST_LEVEL_SENSITIVE_FIELDS, mergedException),
64
+ sensitive: ramda_1.pick(log_1.FIRST_LEVEL_SENSITIVE_FIELDS, mergedException),
64
65
  };
65
66
  formattedError.extensions.exception = error_1.cleanError(extendedException);
66
67
  }
@@ -4,6 +4,7 @@ const constants_1 = require("../../../../../constants");
4
4
  const RequestCancelledError_1 = require("../../../../../errors/RequestCancelledError");
5
5
  const TooManyRequestsError_1 = require("../../../../../errors/TooManyRequestsError");
6
6
  const error_1 = require("../../../../../utils/error");
7
+ const log_1 = require("../../../../../utils/log");
7
8
  const logger_1 = require("../../../../logger");
8
9
  const CACHE_CONTROL_HEADER = 'cache-control';
9
10
  const META_HEADER = 'x-vtex-meta';
@@ -39,7 +40,7 @@ const logAndRemoveSensitiveData = (ctx, err) => {
39
40
  // Use sendLog directly to avoid cleaning error twice.
40
41
  ctx.vtex.logger.log(log, level);
41
42
  if (!constants_1.LINKED) {
42
- error_1.SENSITIVE_EXCEPTION_FIELDS.forEach(field => {
43
+ log_1.FIRST_LEVEL_SENSITIVE_FIELDS.forEach(field => {
43
44
  delete err[field];
44
45
  });
45
46
  }
@@ -1,5 +1,4 @@
1
1
  export declare const PICKED_AXIOS_PROPS: string[];
2
- export declare const SENSITIVE_EXCEPTION_FIELDS: string[];
3
2
  /**
4
3
  * Cleans errors by removing circular properties, truncating large strings and picking axios properties
5
4
  *
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // Inspired by https://github.com/sindresorhus/serialize-error
4
4
  const ramda_1 = require("ramda");
5
5
  exports.PICKED_AXIOS_PROPS = ['baseURL', 'cacheable', 'data', 'finished', 'headers', 'method', 'timeout', 'status', 'path', 'url', 'metric', 'inflightKey', 'forceMaxAge', 'params', 'responseType'];
6
- exports.SENSITIVE_EXCEPTION_FIELDS = ['config', 'request', 'stack'];
7
6
  const MAX_ERROR_STRING_LENGTH = process.env.MAX_ERROR_STRING_LENGTH ? parseInt(process.env.MAX_ERROR_STRING_LENGTH, 10) : 8 * 1024;
8
7
  const findCaseInsensitive = (target, set) => ramda_1.find(t => t.toLocaleLowerCase() === target, set);
9
8
  const destroyCircular = (from, seen) => {
@@ -0,0 +1,3 @@
1
+ export declare const FIRST_LEVEL_SENSITIVE_FIELDS: string[];
2
+ export declare const SECOND_LEVEL_SENSITIVE_FIELDS: string[][];
3
+ export declare const cleanLog: (log: any) => void;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FIRST_LEVEL_SENSITIVE_FIELDS = ['config', 'request', 'stack', 'error'];
4
+ exports.SECOND_LEVEL_SENSITIVE_FIELDS = [['parsedInfo', 'requestConfig'], ['headers', 'cookie']];
5
+ exports.cleanLog = (log) => {
6
+ exports.FIRST_LEVEL_SENSITIVE_FIELDS.forEach(field => {
7
+ delete log[field];
8
+ });
9
+ exports.SECOND_LEVEL_SENSITIVE_FIELDS.forEach(field => {
10
+ if (field[0] in log) {
11
+ delete log[field[0]][field[1]];
12
+ }
13
+ });
14
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/api",
3
- "version": "6.45.6",
3
+ "version": "6.45.7",
4
4
  "description": "VTEX I/O API client",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",