diff --git a/Dockerfile b/Dockerfile index 3377bda7..22b7e69e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,23 @@ -FROM node:lts-slim +FROM --platform=linux/amd64 node:16.15.1-alpine as base + +RUN apk --update --no-cache add --virtual .builds-deps build-base python3 + WORKDIR /opt/app/ + +FROM base as build + COPY package.json package-lock.json ./ + RUN npm ci -RUN npm prune -COPY . /opt/app + +COPY . . + +FROM base + +COPY --from=build /opt/app /opt/app/ + ARG NODE_ENV + ENV NODE_ENV $NODE_ENV -CMD [ "npm", "start" ] +CMD [ "node", "app.js" ] diff --git a/lib/tasks/sip_request.js b/lib/tasks/sip_request.js index 5a500f4e..029a9670 100644 --- a/lib/tasks/sip_request.js +++ b/lib/tasks/sip_request.js @@ -12,6 +12,7 @@ class TaskSipRequest extends Task { this.method = this.data.method.toUpperCase(); this.headers = this.data.headers || {}; this.body = this.data.body; + if (this.body) this.body = `${this.body}\n`; } get name() { return TaskName.SipRequest; } diff --git a/lib/tasks/task.js b/lib/tasks/task.js index be2fddb3..f3fef4ef 100644 --- a/lib/tasks/task.js +++ b/lib/tasks/task.js @@ -145,7 +145,7 @@ class Task extends Emitter { async performAction(results, expectResponse = true) { if (this.actionHook) { - const params = results ? Object.assign(results, this.cs.callInfo.toJSON()) : this.cs.callInfo.toJSON(); + const params = results ? Object.assign(this.cs.callInfo.toJSON(), results) : this.cs.callInfo.toJSON(); const span = this.startSpan('verb:hook', {'hook.url': this.actionHook}); const b3 = this.getTracingPropagation('b3', span); const httpHeaders = b3 && {b3}; diff --git a/lib/utils/http-requestor.js b/lib/utils/http-requestor.js index 805c2093..e93e6851 100644 --- a/lib/utils/http-requestor.js +++ b/lib/utils/http-requestor.js @@ -23,9 +23,8 @@ class HttpRequestor extends BaseRequestor { this.authHeader = basicAuth(hook.username, hook.password); const u = parseUrl(this.url); - const myPort = u.port ? `:${u.port}` : ''; - const baseUrl = this._baseUrl = `${u.protocol}://${u.resource}${myPort}`; - + //const myPort = u.port ? `:${u.port}` : ''; + const baseUrl = this._baseUrl = `${u.protocol}://${u.resource}`; this.get = bent(baseUrl, 'GET', 'buffer', 200, 201); this.post = bent(baseUrl, 'POST', 'buffer', 200, 201); diff --git a/package-lock.json b/package-lock.json index f2cae731..7862eedd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,13 +33,13 @@ "helmet": "^5.1.0", "ip": "^1.1.8", "moment": "^2.29.3", - "parse-url": "^5.0.8", + "parse-url": "^7.0.2", "pino": "^6.14.0", "sdp-transform": "^2.14.1", "short-uuid": "^4.2.0", "to-snake-case": "^1.0.0", "uuid": "^8.3.2", - "verify-aws-sns-signature": "^0.0.6", + "verify-aws-sns-signature": "^0.0.7", "ws": "^8.8.0", "xml2js": "^0.4.23" }, @@ -1847,14 +1847,6 @@ "node": ">=0.10.0" } }, - "node_modules/decode-uri-component": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", - "integrity": "sha512-hjf+xovcEn31w/EUYdTXQh/8smFL/dzYjohQGEIgjyNavaJfBY2p5F527Bo1VPATxv0VYTUC2bOcXvqFwk78Og==", - "engines": { - "node": ">=0.10" - } - }, "node_modules/deep-equal": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.0.5.tgz", @@ -2695,14 +2687,6 @@ "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", "optional": true }, - "node_modules/filter-obj": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/filter-obj/-/filter-obj-1.1.0.tgz", - "integrity": "sha512-8rXg1ZnX7xzy2NGDVkBVaAy+lSlPNwad13BtgSlLuxfIslyt5Vg64U7tFcCt4WS1R0hvtnQybT/IyCkGZ3DpXQ==", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/finalhandler": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", @@ -3630,11 +3614,11 @@ } }, "node_modules/is-ssh": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/is-ssh/-/is-ssh-1.3.3.tgz", - "integrity": "sha512-NKzJmQzJfEEma3w5cJNcUMxoXfDjz0Zj0eyCalHn2E6VOwlzjZo0yuO2fcBSf8zhFuVCL/82/r5gRcoi6aEPVQ==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/is-ssh/-/is-ssh-1.4.0.tgz", + "integrity": "sha512-x7+VxdxOdlV3CYpjvRLBv5Lo9OJerlYanjwFrPR9fuGPjCiNiCzFgAWpiLAohSbsnH4ZAys3SBh+hq5rJosxUQ==", "dependencies": { - "protocols": "^1.1.0" + "protocols": "^2.0.1" } }, "node_modules/is-stream": { @@ -4687,25 +4671,22 @@ } }, "node_modules/parse-path": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/parse-path/-/parse-path-4.0.4.tgz", - "integrity": "sha512-Z2lWUis7jlmXC1jeOG9giRO2+FsuyNipeQ43HAjqAZjwSe3SEf+q/84FGPHoso3kyntbxa4c4i77t3m6fGf8cw==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/parse-path/-/parse-path-5.0.0.tgz", + "integrity": "sha512-qOpH55/+ZJ4jUu/oLO+ifUKjFPNZGfnPJtzvGzKN/4oLMil5m9OH4VpOj6++9/ytJcfks4kzH2hhi87GL/OU9A==", "dependencies": { - "is-ssh": "^1.3.0", - "protocols": "^1.4.0", - "qs": "^6.9.4", - "query-string": "^6.13.8" + "protocols": "^2.0.0" } }, "node_modules/parse-url": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/parse-url/-/parse-url-5.0.8.tgz", - "integrity": "sha512-KFg5QvyiOKJGQSwUT7c5A4ELs0TJ33gmx/NBjK0FvZUD6aonFuXHUVa3SIa2XpbYVkYU8VlDrD3oCbX1ufy0zg==", + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/parse-url/-/parse-url-7.0.2.tgz", + "integrity": "sha512-PqO4Z0eCiQ08Wj6QQmrmp5YTTxpYfONdOEamrtvK63AmzXpcavIVQubGHxOEwiIoDZFb8uDOoQFS0NCcjqIYQg==", "dependencies": { - "is-ssh": "^1.3.0", + "is-ssh": "^1.4.0", "normalize-url": "^6.1.0", - "parse-path": "^4.0.4", - "protocols": "^1.4.0" + "parse-path": "^5.0.0", + "protocols": "^2.0.1" } }, "node_modules/parseurl": { @@ -4872,9 +4853,9 @@ } }, "node_modules/protocols": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/protocols/-/protocols-1.4.8.tgz", - "integrity": "sha512-IgjKyaUSjsROSO8/D49Ab7hP8mJgTYcqApOqdPhLoPxAplXmkp+zRvsrSQjFn5by0rhm4VH0GAUELIPpx7B1yg==" + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/protocols/-/protocols-2.0.1.tgz", + "integrity": "sha512-/XJ368cyBJ7fzLMwLKv1e4vLxOju2MNAIokcr7meSaNcVbWz/CPcW22cP04mwxOErdA5mwjA8Q6w/cdAQxVn7Q==" }, "node_modules/proxy-addr": { "version": "2.0.7", @@ -4912,23 +4893,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/query-string": { - "version": "6.14.1", - "resolved": "https://registry.npmjs.org/query-string/-/query-string-6.14.1.tgz", - "integrity": "sha512-XDxAeVmpfu1/6IjyT/gXHOl+S0vQ9owggJ30hhWKdHAsNPOcasn5o9BW0eejZqL2e4vMjhAxoW3jVHcD6mbcYw==", - "dependencies": { - "decode-uri-component": "^0.2.0", - "filter-obj": "^1.1.0", - "split-on-first": "^1.0.0", - "strict-uri-encode": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/querystring": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", @@ -5439,14 +5403,6 @@ "node": ">=8" } }, - "node_modules/split-on-first": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-1.1.0.tgz", - "integrity": "sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==", - "engines": { - "node": ">=6" - } - }, "node_modules/sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -5474,14 +5430,6 @@ "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.1.tgz", "integrity": "sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==" }, - "node_modules/strict-uri-encode": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz", - "integrity": "sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ==", - "engines": { - "node": ">=4" - } - }, "node_modules/string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", @@ -6036,12 +5984,12 @@ } }, "node_modules/verify-aws-sns-signature": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/verify-aws-sns-signature/-/verify-aws-sns-signature-0.0.6.tgz", - "integrity": "sha512-Dz/H8ewScsdZ0BUKcdEyD5dNA0U5Btaa+6ei9dE/tFbQ57h7rjVnJm7D4GwgVUb+Mv8jUjUALduPT2iw0epLHA==", + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/verify-aws-sns-signature/-/verify-aws-sns-signature-0.0.7.tgz", + "integrity": "sha512-j/yePIQvLqRGshOwuEs9VT7jGh++1hBoOjjt+Rl4aAffJTu+22GwTPfAD9fLY9VqRrR4Cuiid3eNHOkmxE3TNg==", "dependencies": { - "bent": "^7.3.0", - "parse-url": "^5.0.1" + "bent": "^7.3.12", + "parse-url": "^7.0.2" } }, "node_modules/verror": { @@ -7716,11 +7664,6 @@ "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", "dev": true }, - "decode-uri-component": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", - "integrity": "sha512-hjf+xovcEn31w/EUYdTXQh/8smFL/dzYjohQGEIgjyNavaJfBY2p5F527Bo1VPATxv0VYTUC2bOcXvqFwk78Og==" - }, "deep-equal": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.0.5.tgz", @@ -8405,11 +8348,6 @@ "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", "optional": true }, - "filter-obj": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/filter-obj/-/filter-obj-1.1.0.tgz", - "integrity": "sha512-8rXg1ZnX7xzy2NGDVkBVaAy+lSlPNwad13BtgSlLuxfIslyt5Vg64U7tFcCt4WS1R0hvtnQybT/IyCkGZ3DpXQ==" - }, "finalhandler": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", @@ -9084,11 +9022,11 @@ } }, "is-ssh": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/is-ssh/-/is-ssh-1.3.3.tgz", - "integrity": "sha512-NKzJmQzJfEEma3w5cJNcUMxoXfDjz0Zj0eyCalHn2E6VOwlzjZo0yuO2fcBSf8zhFuVCL/82/r5gRcoi6aEPVQ==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/is-ssh/-/is-ssh-1.4.0.tgz", + "integrity": "sha512-x7+VxdxOdlV3CYpjvRLBv5Lo9OJerlYanjwFrPR9fuGPjCiNiCzFgAWpiLAohSbsnH4ZAys3SBh+hq5rJosxUQ==", "requires": { - "protocols": "^1.1.0" + "protocols": "^2.0.1" } }, "is-stream": { @@ -9891,25 +9829,22 @@ } }, "parse-path": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/parse-path/-/parse-path-4.0.4.tgz", - "integrity": "sha512-Z2lWUis7jlmXC1jeOG9giRO2+FsuyNipeQ43HAjqAZjwSe3SEf+q/84FGPHoso3kyntbxa4c4i77t3m6fGf8cw==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/parse-path/-/parse-path-5.0.0.tgz", + "integrity": "sha512-qOpH55/+ZJ4jUu/oLO+ifUKjFPNZGfnPJtzvGzKN/4oLMil5m9OH4VpOj6++9/ytJcfks4kzH2hhi87GL/OU9A==", "requires": { - "is-ssh": "^1.3.0", - "protocols": "^1.4.0", - "qs": "^6.9.4", - "query-string": "^6.13.8" + "protocols": "^2.0.0" } }, "parse-url": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/parse-url/-/parse-url-5.0.8.tgz", - "integrity": "sha512-KFg5QvyiOKJGQSwUT7c5A4ELs0TJ33gmx/NBjK0FvZUD6aonFuXHUVa3SIa2XpbYVkYU8VlDrD3oCbX1ufy0zg==", + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/parse-url/-/parse-url-7.0.2.tgz", + "integrity": "sha512-PqO4Z0eCiQ08Wj6QQmrmp5YTTxpYfONdOEamrtvK63AmzXpcavIVQubGHxOEwiIoDZFb8uDOoQFS0NCcjqIYQg==", "requires": { - "is-ssh": "^1.3.0", + "is-ssh": "^1.4.0", "normalize-url": "^6.1.0", - "parse-path": "^4.0.4", - "protocols": "^1.4.0" + "parse-path": "^5.0.0", + "protocols": "^2.0.1" } }, "parseurl": { @@ -10041,9 +9976,9 @@ } }, "protocols": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/protocols/-/protocols-1.4.8.tgz", - "integrity": "sha512-IgjKyaUSjsROSO8/D49Ab7hP8mJgTYcqApOqdPhLoPxAplXmkp+zRvsrSQjFn5by0rhm4VH0GAUELIPpx7B1yg==" + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/protocols/-/protocols-2.0.1.tgz", + "integrity": "sha512-/XJ368cyBJ7fzLMwLKv1e4vLxOju2MNAIokcr7meSaNcVbWz/CPcW22cP04mwxOErdA5mwjA8Q6w/cdAQxVn7Q==" }, "proxy-addr": { "version": "2.0.7", @@ -10072,17 +10007,6 @@ "side-channel": "^1.0.4" } }, - "query-string": { - "version": "6.14.1", - "resolved": "https://registry.npmjs.org/query-string/-/query-string-6.14.1.tgz", - "integrity": "sha512-XDxAeVmpfu1/6IjyT/gXHOl+S0vQ9owggJ30hhWKdHAsNPOcasn5o9BW0eejZqL2e4vMjhAxoW3jVHcD6mbcYw==", - "requires": { - "decode-uri-component": "^0.2.0", - "filter-obj": "^1.1.0", - "split-on-first": "^1.0.0", - "strict-uri-encode": "^2.0.0" - } - }, "querystring": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", @@ -10475,11 +10399,6 @@ "which": "^2.0.1" } }, - "split-on-first": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-1.1.0.tgz", - "integrity": "sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==" - }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -10501,11 +10420,6 @@ "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.1.tgz", "integrity": "sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==" }, - "strict-uri-encode": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz", - "integrity": "sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ==" - }, "string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", @@ -10941,12 +10855,12 @@ "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==" }, "verify-aws-sns-signature": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/verify-aws-sns-signature/-/verify-aws-sns-signature-0.0.6.tgz", - "integrity": "sha512-Dz/H8ewScsdZ0BUKcdEyD5dNA0U5Btaa+6ei9dE/tFbQ57h7rjVnJm7D4GwgVUb+Mv8jUjUALduPT2iw0epLHA==", + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/verify-aws-sns-signature/-/verify-aws-sns-signature-0.0.7.tgz", + "integrity": "sha512-j/yePIQvLqRGshOwuEs9VT7jGh++1hBoOjjt+Rl4aAffJTu+22GwTPfAD9fLY9VqRrR4Cuiid3eNHOkmxE3TNg==", "requires": { - "bent": "^7.3.0", - "parse-url": "^5.0.1" + "bent": "^7.3.12", + "parse-url": "^7.0.2" } }, "verror": { diff --git a/package.json b/package.json index 0fe982fa..c78dfac3 100644 --- a/package.json +++ b/package.json @@ -50,13 +50,13 @@ "helmet": "^5.1.0", "ip": "^1.1.8", "moment": "^2.29.3", - "parse-url": "^5.0.8", + "parse-url": "^7.0.2", "pino": "^6.14.0", "sdp-transform": "^2.14.1", "short-uuid": "^4.2.0", "to-snake-case": "^1.0.0", "uuid": "^8.3.2", - "verify-aws-sns-signature": "^0.0.6", + "verify-aws-sns-signature": "^0.0.7", "ws": "^8.8.0", "xml2js": "^0.4.23" },