From 60e84c7fcd109a553f855da6af1d98f0aef667c3 Mon Sep 17 00:00:00 2001 From: Kevin Greene Date: Fri, 9 Aug 2019 16:34:28 -0700 Subject: [PATCH] Add support for stripping header structs --- package-lock.json | 6 ++-- .../package-lock.json | 26 +++++++------- .../package-lock.json | 26 +++++++------- .../package-lock.json | 2 +- .../src/main/ThriftClientTTwitterFilter.ts | 19 +++-------- .../package-lock.json | 8 ++--- packages/thrift-client/package-lock.json | 14 ++++---- packages/thrift-integration/package-lock.json | 26 +++++++------- packages/thrift-server-core/package-lock.json | 26 +++++++------- .../src/main/utils/readThriftObject.ts | 34 +++++++++++++++++++ .../src/tests/unit/utils.spec.ts | 26 ++++++++++++++ .../thrift-server-ecosystem/package-lock.json | 2 +- .../thrift-server-express/package-lock.json | 2 +- packages/thrift-server-hapi/package-lock.json | 2 +- .../src/main/ThriftServerHapi.ts | 5 ++- packages/zipkin-core/package-lock.json | 32 ++++++++--------- .../zipkin-tracing-express/package-lock.json | 2 +- .../zipkin-tracing-hapi/package-lock.json | 2 +- 18 files changed, 157 insertions(+), 103 deletions(-) diff --git a/package-lock.json b/package-lock.json index a81de022..87b586c5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1053,9 +1053,9 @@ "dev": true }, "@types/node": { - "version": "12.7.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.0.tgz", - "integrity": "sha512-vqcj1MVm2Sla4PpMfYKh1MyDN4D2f/mPIZD7RdAGqEsbE+JxfeqQHHVbRDQ0Nqn8i73gJa1HQ1Pu3+nH4Q0Yiw==", + "version": "12.7.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.1.tgz", + "integrity": "sha512-aK9jxMypeSrhiYofWWBf/T7O+KwaiAHzM4sveCdWPn71lzUSMimRnKzhXDKfKwV1kWoBo2P1aGgaIYGLf9/ljw==", "dev": true }, "@zkochan/cmd-shim": { diff --git a/packages/thrift-client-context-filter/package-lock.json b/packages/thrift-client-context-filter/package-lock.json index 0f691709..9e91f4cc 100644 --- a/packages/thrift-client-context-filter/package-lock.json +++ b/packages/thrift-client-context-filter/package-lock.json @@ -1,6 +1,6 @@ { "name": "@creditkarma/thrift-client-context-filter", - "version": "0.13.7", + "version": "0.13.8", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -51,9 +51,9 @@ }, "dependencies": { "@hapi/hoek": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.1.0.tgz", - "integrity": "sha512-b1J4jxYnW+n6lC91V6Pqg9imP9BZq0HNCeM+3sbXg05rQsE9cGYrKFpZjyztVesGmNRE6R+QaEoWGATeIiUVjA==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.2.0.tgz", + "integrity": "sha512-pR2ZgiP562aiaQvQ98WgfqfTrm+xG+7hwHRPEiYZ+7U1OHAAb4OVZJIalCP03bMqYSioQzflzVTVrybSwDBn1Q==", "dev": true } } @@ -68,9 +68,9 @@ } }, "@hapi/eslint-config-hapi": { - "version": "12.1.1", - "resolved": "https://registry.npmjs.org/@hapi/eslint-config-hapi/-/eslint-config-hapi-12.1.1.tgz", - "integrity": "sha512-+N6skVzPKrcZVY+BPf4kcIMTOCjKk321r7T6v6aET9kqR1/Zyzgnc9wVzyyXF1htQzQVL9PS9oG/tzty/CWbnA==", + "version": "12.2.0", + "resolved": "https://registry.npmjs.org/@hapi/eslint-config-hapi/-/eslint-config-hapi-12.2.0.tgz", + "integrity": "sha512-tByj7aMwzpG1bTxiVkDlNWbEcdm7AYNp8HSFys8COO5Vxg7FwTqyU44Ke/Jdm3M13vGSD+OEyF0LB3aw4khjlQ==", "dev": true }, "@hapi/eslint-plugin-hapi": { @@ -166,18 +166,18 @@ "dev": true }, "@hapi/topo": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-3.1.2.tgz", - "integrity": "sha512-r+aumOqJ5QbD6aLPJWqVjMAPsx5pZKz+F5yPqXZ/WWG9JTtHbQqlzrJoknJ0iJxLj9vlXtmpSdjlkszseeG8OA==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-3.1.3.tgz", + "integrity": "sha512-JmS9/vQK6dcUYn7wc2YZTqzIKubAQcJKu2KCKAru6es482U5RT5fP1EXCPtlXpiK7PR0On/kpQKI4fRKkzpZBQ==", "dev": true, "requires": { "@hapi/hoek": "8.x.x" }, "dependencies": { "@hapi/hoek": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.1.0.tgz", - "integrity": "sha512-b1J4jxYnW+n6lC91V6Pqg9imP9BZq0HNCeM+3sbXg05rQsE9cGYrKFpZjyztVesGmNRE6R+QaEoWGATeIiUVjA==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.2.0.tgz", + "integrity": "sha512-pR2ZgiP562aiaQvQ98WgfqfTrm+xG+7hwHRPEiYZ+7U1OHAAb4OVZJIalCP03bMqYSioQzflzVTVrybSwDBn1Q==", "dev": true } } diff --git a/packages/thrift-client-timing-filter/package-lock.json b/packages/thrift-client-timing-filter/package-lock.json index 14274eb3..8a0389b7 100644 --- a/packages/thrift-client-timing-filter/package-lock.json +++ b/packages/thrift-client-timing-filter/package-lock.json @@ -1,6 +1,6 @@ { "name": "@creditkarma/thrift-client-timing-filter", - "version": "0.13.7", + "version": "0.13.8", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -51,9 +51,9 @@ }, "dependencies": { "@hapi/hoek": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.1.0.tgz", - "integrity": "sha512-b1J4jxYnW+n6lC91V6Pqg9imP9BZq0HNCeM+3sbXg05rQsE9cGYrKFpZjyztVesGmNRE6R+QaEoWGATeIiUVjA==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.2.0.tgz", + "integrity": "sha512-pR2ZgiP562aiaQvQ98WgfqfTrm+xG+7hwHRPEiYZ+7U1OHAAb4OVZJIalCP03bMqYSioQzflzVTVrybSwDBn1Q==", "dev": true } } @@ -68,9 +68,9 @@ } }, "@hapi/eslint-config-hapi": { - "version": "12.1.1", - "resolved": "https://registry.npmjs.org/@hapi/eslint-config-hapi/-/eslint-config-hapi-12.1.1.tgz", - "integrity": "sha512-+N6skVzPKrcZVY+BPf4kcIMTOCjKk321r7T6v6aET9kqR1/Zyzgnc9wVzyyXF1htQzQVL9PS9oG/tzty/CWbnA==", + "version": "12.2.0", + "resolved": "https://registry.npmjs.org/@hapi/eslint-config-hapi/-/eslint-config-hapi-12.2.0.tgz", + "integrity": "sha512-tByj7aMwzpG1bTxiVkDlNWbEcdm7AYNp8HSFys8COO5Vxg7FwTqyU44Ke/Jdm3M13vGSD+OEyF0LB3aw4khjlQ==", "dev": true }, "@hapi/eslint-plugin-hapi": { @@ -166,18 +166,18 @@ "dev": true }, "@hapi/topo": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-3.1.2.tgz", - "integrity": "sha512-r+aumOqJ5QbD6aLPJWqVjMAPsx5pZKz+F5yPqXZ/WWG9JTtHbQqlzrJoknJ0iJxLj9vlXtmpSdjlkszseeG8OA==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-3.1.3.tgz", + "integrity": "sha512-JmS9/vQK6dcUYn7wc2YZTqzIKubAQcJKu2KCKAru6es482U5RT5fP1EXCPtlXpiK7PR0On/kpQKI4fRKkzpZBQ==", "dev": true, "requires": { "@hapi/hoek": "8.x.x" }, "dependencies": { "@hapi/hoek": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.1.0.tgz", - "integrity": "sha512-b1J4jxYnW+n6lC91V6Pqg9imP9BZq0HNCeM+3sbXg05rQsE9cGYrKFpZjyztVesGmNRE6R+QaEoWGATeIiUVjA==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.2.0.tgz", + "integrity": "sha512-pR2ZgiP562aiaQvQ98WgfqfTrm+xG+7hwHRPEiYZ+7U1OHAAb4OVZJIalCP03bMqYSioQzflzVTVrybSwDBn1Q==", "dev": true } } diff --git a/packages/thrift-client-ttwitter-filter/package-lock.json b/packages/thrift-client-ttwitter-filter/package-lock.json index ab737182..dbf2d3fc 100644 --- a/packages/thrift-client-ttwitter-filter/package-lock.json +++ b/packages/thrift-client-ttwitter-filter/package-lock.json @@ -1,6 +1,6 @@ { "name": "@creditkarma/thrift-client-ttwitter-filter", - "version": "0.13.7", + "version": "0.13.8", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/packages/thrift-client-ttwitter-filter/src/main/ThriftClientTTwitterFilter.ts b/packages/thrift-client-ttwitter-filter/src/main/ThriftClientTTwitterFilter.ts index 9a127285..5ef6cd39 100644 --- a/packages/thrift-client-ttwitter-filter/src/main/ThriftClientTTwitterFilter.ts +++ b/packages/thrift-client-ttwitter-filter/src/main/ThriftClientTTwitterFilter.ts @@ -161,34 +161,25 @@ export function ThriftClientTTwitterFilter({ const requestHeader: TTwitter.IRequestHeader = { trace_id: new Int64( - `0x${ - (normalHeaders as any)[ - ZipkinHeaders.TraceId - ] - }`, + `0x${normalHeaders[ZipkinHeaders.TraceId]}`, ), span_id: new Int64( - `0x${ - (normalHeaders as any)[ - ZipkinHeaders.SpanId - ] - }`, + `0x${normalHeaders[ZipkinHeaders.SpanId]}`, ), parent_span_id: normalHeaders[ZipkinHeaders.ParentId] !== undefined ? new Int64( `0x${ - (normalHeaders as any)[ + normalHeaders[ ZipkinHeaders.ParentId ] }`, ) : undefined, sampled: - (normalHeaders as any)[ - ZipkinHeaders.Sampled - ] === '1', + normalHeaders[ZipkinHeaders.Sampled] === + '1', client_id: clientId !== undefined ? new TTwitter.ClientId(clientId) diff --git a/packages/thrift-client-zipkin-filter/package-lock.json b/packages/thrift-client-zipkin-filter/package-lock.json index 31b19010..49110230 100644 --- a/packages/thrift-client-zipkin-filter/package-lock.json +++ b/packages/thrift-client-zipkin-filter/package-lock.json @@ -1,6 +1,6 @@ { "name": "@creditkarma/thrift-client-zipkin-filter", - "version": "0.13.7", + "version": "0.13.8", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -47,9 +47,9 @@ }, "dependencies": { "@types/node": { - "version": "12.7.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.0.tgz", - "integrity": "sha512-vqcj1MVm2Sla4PpMfYKh1MyDN4D2f/mPIZD7RdAGqEsbE+JxfeqQHHVbRDQ0Nqn8i73gJa1HQ1Pu3+nH4Q0Yiw==" + "version": "12.7.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.1.tgz", + "integrity": "sha512-aK9jxMypeSrhiYofWWBf/T7O+KwaiAHzM4sveCdWPn71lzUSMimRnKzhXDKfKwV1kWoBo2P1aGgaIYGLf9/ljw==" } } }, diff --git a/packages/thrift-client/package-lock.json b/packages/thrift-client/package-lock.json index afd5157a..2273c0eb 100644 --- a/packages/thrift-client/package-lock.json +++ b/packages/thrift-client/package-lock.json @@ -1,6 +1,6 @@ { "name": "@creditkarma/thrift-client", - "version": "0.13.7", + "version": "0.13.8", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -38,9 +38,9 @@ }, "dependencies": { "@types/node": { - "version": "12.7.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.0.tgz", - "integrity": "sha512-vqcj1MVm2Sla4PpMfYKh1MyDN4D2f/mPIZD7RdAGqEsbE+JxfeqQHHVbRDQ0Nqn8i73gJa1HQ1Pu3+nH4Q0Yiw==" + "version": "12.7.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.1.tgz", + "integrity": "sha512-aK9jxMypeSrhiYofWWBf/T7O+KwaiAHzM4sveCdWPn71lzUSMimRnKzhXDKfKwV1kWoBo2P1aGgaIYGLf9/ljw==" } } }, @@ -62,9 +62,9 @@ }, "dependencies": { "@types/node": { - "version": "12.7.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.0.tgz", - "integrity": "sha512-vqcj1MVm2Sla4PpMfYKh1MyDN4D2f/mPIZD7RdAGqEsbE+JxfeqQHHVbRDQ0Nqn8i73gJa1HQ1Pu3+nH4Q0Yiw==" + "version": "12.7.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.1.tgz", + "integrity": "sha512-aK9jxMypeSrhiYofWWBf/T7O+KwaiAHzM4sveCdWPn71lzUSMimRnKzhXDKfKwV1kWoBo2P1aGgaIYGLf9/ljw==" } } }, diff --git a/packages/thrift-integration/package-lock.json b/packages/thrift-integration/package-lock.json index b3e0e0fa..850dc3d0 100644 --- a/packages/thrift-integration/package-lock.json +++ b/packages/thrift-integration/package-lock.json @@ -1,6 +1,6 @@ { "name": "@creditkarma/thrift-integration", - "version": "0.13.7", + "version": "0.13.8", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -120,9 +120,9 @@ }, "dependencies": { "@hapi/hoek": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.1.0.tgz", - "integrity": "sha512-b1J4jxYnW+n6lC91V6Pqg9imP9BZq0HNCeM+3sbXg05rQsE9cGYrKFpZjyztVesGmNRE6R+QaEoWGATeIiUVjA==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.2.0.tgz", + "integrity": "sha512-pR2ZgiP562aiaQvQ98WgfqfTrm+xG+7hwHRPEiYZ+7U1OHAAb4OVZJIalCP03bMqYSioQzflzVTVrybSwDBn1Q==", "dev": true } } @@ -137,9 +137,9 @@ } }, "@hapi/eslint-config-hapi": { - "version": "12.1.1", - "resolved": "https://registry.npmjs.org/@hapi/eslint-config-hapi/-/eslint-config-hapi-12.1.1.tgz", - "integrity": "sha512-+N6skVzPKrcZVY+BPf4kcIMTOCjKk321r7T6v6aET9kqR1/Zyzgnc9wVzyyXF1htQzQVL9PS9oG/tzty/CWbnA==", + "version": "12.2.0", + "resolved": "https://registry.npmjs.org/@hapi/eslint-config-hapi/-/eslint-config-hapi-12.2.0.tgz", + "integrity": "sha512-tByj7aMwzpG1bTxiVkDlNWbEcdm7AYNp8HSFys8COO5Vxg7FwTqyU44Ke/Jdm3M13vGSD+OEyF0LB3aw4khjlQ==", "dev": true }, "@hapi/eslint-plugin-hapi": { @@ -235,18 +235,18 @@ "dev": true }, "@hapi/topo": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-3.1.2.tgz", - "integrity": "sha512-r+aumOqJ5QbD6aLPJWqVjMAPsx5pZKz+F5yPqXZ/WWG9JTtHbQqlzrJoknJ0iJxLj9vlXtmpSdjlkszseeG8OA==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-3.1.3.tgz", + "integrity": "sha512-JmS9/vQK6dcUYn7wc2YZTqzIKubAQcJKu2KCKAru6es482U5RT5fP1EXCPtlXpiK7PR0On/kpQKI4fRKkzpZBQ==", "dev": true, "requires": { "@hapi/hoek": "8.x.x" }, "dependencies": { "@hapi/hoek": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.1.0.tgz", - "integrity": "sha512-b1J4jxYnW+n6lC91V6Pqg9imP9BZq0HNCeM+3sbXg05rQsE9cGYrKFpZjyztVesGmNRE6R+QaEoWGATeIiUVjA==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.2.0.tgz", + "integrity": "sha512-pR2ZgiP562aiaQvQ98WgfqfTrm+xG+7hwHRPEiYZ+7U1OHAAb4OVZJIalCP03bMqYSioQzflzVTVrybSwDBn1Q==", "dev": true } } diff --git a/packages/thrift-server-core/package-lock.json b/packages/thrift-server-core/package-lock.json index a404fd31..69cbbe3b 100644 --- a/packages/thrift-server-core/package-lock.json +++ b/packages/thrift-server-core/package-lock.json @@ -1,6 +1,6 @@ { "name": "@creditkarma/thrift-server-core", - "version": "0.13.7", + "version": "0.13.8", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -78,9 +78,9 @@ }, "dependencies": { "@hapi/hoek": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.1.0.tgz", - "integrity": "sha512-b1J4jxYnW+n6lC91V6Pqg9imP9BZq0HNCeM+3sbXg05rQsE9cGYrKFpZjyztVesGmNRE6R+QaEoWGATeIiUVjA==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.2.0.tgz", + "integrity": "sha512-pR2ZgiP562aiaQvQ98WgfqfTrm+xG+7hwHRPEiYZ+7U1OHAAb4OVZJIalCP03bMqYSioQzflzVTVrybSwDBn1Q==", "dev": true } } @@ -95,9 +95,9 @@ } }, "@hapi/eslint-config-hapi": { - "version": "12.1.1", - "resolved": "https://registry.npmjs.org/@hapi/eslint-config-hapi/-/eslint-config-hapi-12.1.1.tgz", - "integrity": "sha512-+N6skVzPKrcZVY+BPf4kcIMTOCjKk321r7T6v6aET9kqR1/Zyzgnc9wVzyyXF1htQzQVL9PS9oG/tzty/CWbnA==", + "version": "12.2.0", + "resolved": "https://registry.npmjs.org/@hapi/eslint-config-hapi/-/eslint-config-hapi-12.2.0.tgz", + "integrity": "sha512-tByj7aMwzpG1bTxiVkDlNWbEcdm7AYNp8HSFys8COO5Vxg7FwTqyU44Ke/Jdm3M13vGSD+OEyF0LB3aw4khjlQ==", "dev": true }, "@hapi/eslint-plugin-hapi": { @@ -193,18 +193,18 @@ "dev": true }, "@hapi/topo": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-3.1.2.tgz", - "integrity": "sha512-r+aumOqJ5QbD6aLPJWqVjMAPsx5pZKz+F5yPqXZ/WWG9JTtHbQqlzrJoknJ0iJxLj9vlXtmpSdjlkszseeG8OA==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-3.1.3.tgz", + "integrity": "sha512-JmS9/vQK6dcUYn7wc2YZTqzIKubAQcJKu2KCKAru6es482U5RT5fP1EXCPtlXpiK7PR0On/kpQKI4fRKkzpZBQ==", "dev": true, "requires": { "@hapi/hoek": "8.x.x" }, "dependencies": { "@hapi/hoek": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.1.0.tgz", - "integrity": "sha512-b1J4jxYnW+n6lC91V6Pqg9imP9BZq0HNCeM+3sbXg05rQsE9cGYrKFpZjyztVesGmNRE6R+QaEoWGATeIiUVjA==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.2.0.tgz", + "integrity": "sha512-pR2ZgiP562aiaQvQ98WgfqfTrm+xG+7hwHRPEiYZ+7U1OHAAb4OVZJIalCP03bMqYSioQzflzVTVrybSwDBn1Q==", "dev": true } } diff --git a/packages/thrift-server-core/src/main/utils/readThriftObject.ts b/packages/thrift-server-core/src/main/utils/readThriftObject.ts index b34392df..890c9196 100644 --- a/packages/thrift-server-core/src/main/utils/readThriftObject.ts +++ b/packages/thrift-server-core/src/main/utils/readThriftObject.ts @@ -1,9 +1,11 @@ import { IProtocolConstructor, IStructCodec, + IThriftField, ITransportConstructor, ProtocolType, TransportType, + TType, } from '../types' import { getProtocol, TProtocol } from '../protocols' @@ -26,3 +28,35 @@ export function readThriftObject( resolve([decoded, receiver.remaining()]) }) } + +export function stripStruct( + data: Buffer, + transportType: TransportType = 'buffered', + protocolType: ProtocolType = 'binary', +): Buffer { + try { + const Transport: ITransportConstructor = getTransport(transportType) + const Protocol: IProtocolConstructor = getProtocol(protocolType) + const receiver: TTransport = new Transport(data) + const input: TProtocol = new Protocol(receiver) + + input.readStructBegin() + + while (true) { + const ret: IThriftField = input.readFieldBegin() + const fieldType: TType = ret.fieldType + if (fieldType === TType.STOP) { + break + } else { + input.skip(fieldType) + } + input.readFieldEnd() + } + + input.readStructEnd() + + return receiver.remaining() + } catch (err) { + return data + } +} diff --git a/packages/thrift-server-core/src/tests/unit/utils.spec.ts b/packages/thrift-server-core/src/tests/unit/utils.spec.ts index 01e4dc27..520d1a64 100644 --- a/packages/thrift-server-core/src/tests/unit/utils.spec.ts +++ b/packages/thrift-server-core/src/tests/unit/utils.spec.ts @@ -8,6 +8,7 @@ import { encode, MessageType, readThriftObject, + stripStruct, TProtocol, TTransport, } from '../../main' @@ -84,6 +85,31 @@ describe('Utils', () => { }) }) + describe('stripStruct', () => { + it('should strip struct from message', async () => { + const meta: IMetadata = { traceId: 7 } + const data: Buffer = Buffer.from([1, 2, 3, 4, 5]) + const totalLength: number = + (await encode(meta, MetadataCodec)).length + data.length + + return appendThriftObject(meta, data, MetadataCodec).then( + (val: Buffer) => { + expect(val.length).to.equal(totalLength) + const result: Buffer = stripStruct(val) + expect(result.toString()).to.equal(data.toString()) + expect(result.length).to.equal(data.length) + }, + ) + }) + + it('should leave message without struct unaltered', async () => { + const data: Buffer = Buffer.from([1, 2, 3, 4, 5]) + const result: Buffer = stripStruct(data) + expect(result.toString()).to.equal(data.toString()) + expect(result.length).to.equal(data.length) + }) + }) + describe('deepMerge', () => { it('should merge two objects into new object', async () => { const obj1: any = { diff --git a/packages/thrift-server-ecosystem/package-lock.json b/packages/thrift-server-ecosystem/package-lock.json index ec531b83..cc1edad0 100644 --- a/packages/thrift-server-ecosystem/package-lock.json +++ b/packages/thrift-server-ecosystem/package-lock.json @@ -1,6 +1,6 @@ { "name": "@creditkarma/thrift-server-ecosystem", - "version": "0.13.7", + "version": "0.13.8", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/packages/thrift-server-express/package-lock.json b/packages/thrift-server-express/package-lock.json index a9a23f4a..9faf653e 100644 --- a/packages/thrift-server-express/package-lock.json +++ b/packages/thrift-server-express/package-lock.json @@ -1,6 +1,6 @@ { "name": "@creditkarma/thrift-server-express", - "version": "0.13.7", + "version": "0.13.8", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/packages/thrift-server-hapi/package-lock.json b/packages/thrift-server-hapi/package-lock.json index 086d8676..7c03b342 100644 --- a/packages/thrift-server-hapi/package-lock.json +++ b/packages/thrift-server-hapi/package-lock.json @@ -1,6 +1,6 @@ { "name": "@creditkarma/thrift-server-hapi", - "version": "0.13.7", + "version": "0.13.8", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/packages/thrift-server-hapi/src/main/ThriftServerHapi.ts b/packages/thrift-server-hapi/src/main/ThriftServerHapi.ts index 4956bdbf..4fcee7e7 100644 --- a/packages/thrift-server-hapi/src/main/ThriftServerHapi.ts +++ b/packages/thrift-server-hapi/src/main/ThriftServerHapi.ts @@ -157,7 +157,10 @@ export function ThriftServerHapi< request: Hapi.Request, reply: Hapi.ResponseToolkit, ) => { - const buffer: Buffer = request.payload as Buffer + const buffer: Buffer = Core.stripStruct( + request.payload as Buffer, + ) + const method: string = Core.readThriftMethod( buffer, Transport, diff --git a/packages/zipkin-core/package-lock.json b/packages/zipkin-core/package-lock.json index 4c8508d4..20cf3cb9 100644 --- a/packages/zipkin-core/package-lock.json +++ b/packages/zipkin-core/package-lock.json @@ -1,6 +1,6 @@ { "name": "@creditkarma/zipkin-core", - "version": "0.13.7", + "version": "0.13.8", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -51,9 +51,9 @@ }, "dependencies": { "@hapi/hoek": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.1.0.tgz", - "integrity": "sha512-b1J4jxYnW+n6lC91V6Pqg9imP9BZq0HNCeM+3sbXg05rQsE9cGYrKFpZjyztVesGmNRE6R+QaEoWGATeIiUVjA==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.2.0.tgz", + "integrity": "sha512-pR2ZgiP562aiaQvQ98WgfqfTrm+xG+7hwHRPEiYZ+7U1OHAAb4OVZJIalCP03bMqYSioQzflzVTVrybSwDBn1Q==", "dev": true } } @@ -68,9 +68,9 @@ } }, "@hapi/eslint-config-hapi": { - "version": "12.1.1", - "resolved": "https://registry.npmjs.org/@hapi/eslint-config-hapi/-/eslint-config-hapi-12.1.1.tgz", - "integrity": "sha512-+N6skVzPKrcZVY+BPf4kcIMTOCjKk321r7T6v6aET9kqR1/Zyzgnc9wVzyyXF1htQzQVL9PS9oG/tzty/CWbnA==", + "version": "12.2.0", + "resolved": "https://registry.npmjs.org/@hapi/eslint-config-hapi/-/eslint-config-hapi-12.2.0.tgz", + "integrity": "sha512-tByj7aMwzpG1bTxiVkDlNWbEcdm7AYNp8HSFys8COO5Vxg7FwTqyU44Ke/Jdm3M13vGSD+OEyF0LB3aw4khjlQ==", "dev": true }, "@hapi/eslint-plugin-hapi": { @@ -166,18 +166,18 @@ "dev": true }, "@hapi/topo": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-3.1.2.tgz", - "integrity": "sha512-r+aumOqJ5QbD6aLPJWqVjMAPsx5pZKz+F5yPqXZ/WWG9JTtHbQqlzrJoknJ0iJxLj9vlXtmpSdjlkszseeG8OA==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-3.1.3.tgz", + "integrity": "sha512-JmS9/vQK6dcUYn7wc2YZTqzIKubAQcJKu2KCKAru6es482U5RT5fP1EXCPtlXpiK7PR0On/kpQKI4fRKkzpZBQ==", "dev": true, "requires": { "@hapi/hoek": "8.x.x" }, "dependencies": { "@hapi/hoek": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.1.0.tgz", - "integrity": "sha512-b1J4jxYnW+n6lC91V6Pqg9imP9BZq0HNCeM+3sbXg05rQsE9cGYrKFpZjyztVesGmNRE6R+QaEoWGATeIiUVjA==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.2.0.tgz", + "integrity": "sha512-pR2ZgiP562aiaQvQ98WgfqfTrm+xG+7hwHRPEiYZ+7U1OHAAb4OVZJIalCP03bMqYSioQzflzVTVrybSwDBn1Q==", "dev": true } } @@ -208,9 +208,9 @@ }, "dependencies": { "@types/node": { - "version": "12.7.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.0.tgz", - "integrity": "sha512-vqcj1MVm2Sla4PpMfYKh1MyDN4D2f/mPIZD7RdAGqEsbE+JxfeqQHHVbRDQ0Nqn8i73gJa1HQ1Pu3+nH4Q0Yiw==" + "version": "12.7.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.1.tgz", + "integrity": "sha512-aK9jxMypeSrhiYofWWBf/T7O+KwaiAHzM4sveCdWPn71lzUSMimRnKzhXDKfKwV1kWoBo2P1aGgaIYGLf9/ljw==" } } }, diff --git a/packages/zipkin-tracing-express/package-lock.json b/packages/zipkin-tracing-express/package-lock.json index d7318336..233df4d4 100644 --- a/packages/zipkin-tracing-express/package-lock.json +++ b/packages/zipkin-tracing-express/package-lock.json @@ -1,6 +1,6 @@ { "name": "@creditkarma/zipkin-tracing-express", - "version": "0.13.7", + "version": "0.13.8", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/packages/zipkin-tracing-hapi/package-lock.json b/packages/zipkin-tracing-hapi/package-lock.json index 0b2eca34..d664bac0 100644 --- a/packages/zipkin-tracing-hapi/package-lock.json +++ b/packages/zipkin-tracing-hapi/package-lock.json @@ -1,6 +1,6 @@ { "name": "@creditkarma/zipkin-tracing-hapi", - "version": "0.13.7", + "version": "0.13.8", "lockfileVersion": 1, "requires": true, "dependencies": {