From a94fd10b7e3ab0c893578f253f6edfdef5b30741 Mon Sep 17 00:00:00 2001 From: Chang-Hung Liang Date: Wed, 8 May 2024 12:44:10 +0800 Subject: [PATCH] Upgrade secret-scrubber-js to 1.1.1 --- packages/core/package.json | 2 +- packages/core/test/logger.js | 45 ++++++++++++++++++++++++++++++++++++ yarn.lock | 40 +++++++------------------------- 3 files changed, 54 insertions(+), 33 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index 75ab3160f..dc7be5a02 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -41,7 +41,7 @@ }, "engineStrict": true, "dependencies": { - "@zapier/secret-scrubber": "^1.0.8", + "@zapier/secret-scrubber": "^1.1.1", "bluebird": "3.7.2", "content-disposition": "0.5.4", "dotenv": "12.0.4 ", diff --git a/packages/core/test/logger.js b/packages/core/test/logger.js index a49907ae9..843d632fb 100644 --- a/packages/core/test/logger.js +++ b/packages/core/test/logger.js @@ -20,6 +20,7 @@ const prepareTestRequest = ({ reqBody = {}, resBody = {}, reqQueryParams = '', + resHeaders = {}, } = {}) => prepareRequestLog( { @@ -37,6 +38,7 @@ const prepareTestRequest = ({ status: 200, headers: { 'content-type': 'application/json', + ...resHeaders, }, content: resBody, @@ -335,6 +337,49 @@ describe('logger', () => { ]); }); + it('should replace set-cookie header', async () => { + const event = { + method: 'authentication.sessionConfig.perform', + }; + const logger = createlogger(event, options); + + const { message, data } = prepareTestRequest({ + reqBody: { + username: 'user1234', + password: 'password1234', + }, + resBody: '"new_access_token_is_secret"', + resHeaders: { + 'set-cookie': + '_sid=1234567890; domain=password1234.com; HttpOnly; Secure', + }, + }); + + logger(message, data); + const response = await logger.end(1000); + response.status.should.eql(200); + + response.content.logs.should.deepEqual([ + { + message: '200 POST http://example.com', + data: { + log_type: 'http', + request_type: 'devplatform-outbound', + request_url: 'http://example.com', + request_method: 'POST', + request_headers: 'accept: application/json', + request_data: + '{"username":"user1234","password":":censored:12:60562c5b6c:"}', + request_via_client: true, + response_status_code: 200, + response_headers: + 'content-type: application/json\nset-cookie: :censored:58:a5f1e7f860:', + response_content: '":censored:26:fea118210f:"', + }, + }, + ]); + }); + it('should leave response content of null uncensored', async () => { const event = { method: 'authentication.sessionConfig.perform', diff --git a/yarn.lock b/yarn.lock index 70aebbbb6..d07998ede 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2300,11 +2300,12 @@ js-yaml "^3.10.0" tslib "^2.4.0" -"@zapier/secret-scrubber@^1.0.8": - version "1.0.8" - resolved "https://registry.yarnpkg.com/@zapier/secret-scrubber/-/secret-scrubber-1.0.8.tgz#f757ea475243c408789803b99f6c5fc0a5465187" - integrity sha512-6vVhOwlwfbETEhLCS+eY/OzXLANzf71O1XnfPpKAx29JMxZV4S1Sefp9F5jBQGTmL0BVYu34rNS7Uej1x/rcsQ== +"@zapier/secret-scrubber@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@zapier/secret-scrubber/-/secret-scrubber-1.1.1.tgz#ccb7b75e320d5662efd2ff23eb66cf7fea764a39" + integrity sha512-4w0lsz8lpsl/+c1u8h5LDNioCdLloPobryH7voawgO6hoPkwJxYhXB1xZYLAxycFSZmCXajRmzZyzma26pdIOQ== dependencies: + create-hash "^1.2.0" lodash.isplainobject "^4.0.6" "@zkochan/js-yaml@0.0.6": @@ -10790,7 +10791,7 @@ string-length@4.0.2: char-regex "^1.0.2" strip-ansi "^6.0.0" -"string-width-cjs@npm:string-width@^4.2.0": +"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.2.2, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -10808,15 +10809,6 @@ string-width@^1.0.1: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" -"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.2.2, string-width@^4.2.3: - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - string-width@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" @@ -10918,7 +10910,7 @@ stringify-object@3.3.0: is-obj "^1.0.1" is-regexp "^1.0.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1": +"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -10953,13 +10945,6 @@ strip-ansi@^6.0.0: dependencies: ansi-regex "^5.0.0" -strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - strip-ansi@^7.0.1: version "7.1.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" @@ -11963,7 +11948,7 @@ workerpool@6.2.1: resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343" integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -11990,15 +11975,6 @@ wrap-ansi@^6.2.0: string-width "^4.1.0" strip-ansi "^6.0.0" -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"