From 262e8aab2dd94826e2fa5f5d0aebf5ee6f8c8a47 Mon Sep 17 00:00:00 2001 From: shamiluwais Date: Fri, 19 Jul 2024 11:23:36 +0100 Subject: [PATCH 01/12] Capture and add user ip address in submission --- apps/rotm/behaviours/caseworker-email.js | 13 +++++++++++-- apps/rotm/translations/src/en/email.json | 6 +++--- package.json | 3 +-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/apps/rotm/behaviours/caseworker-email.js b/apps/rotm/behaviours/caseworker-email.js index f91110e3..822164d2 100644 --- a/apps/rotm/behaviours/caseworker-email.js +++ b/apps/rotm/behaviours/caseworker-email.js @@ -7,6 +7,14 @@ const moment = require('moment'); const config = require('../../../config'); const { createLogger, format, transports } = require('winston'); const { combine, timestamp, json } = format; +const http = require('http'); + +let ipAddress = ""; +http.get({'host': 'api.ipify.org', 'port': 80, 'path': '/'}, function(resp) { + resp.on('data', function(ip) { + ipAddress = String.fromCharCode(...ip); + }); +}); const logger = createLogger({ format: combine(timestamp(), json()), @@ -26,7 +34,7 @@ const parse = (model, translate) => { logger.log({ level: 'info', - message: `Submission ID: ${model.submissionID}, Email Submitted: ${submissionDateTime}` + message: `Submission ID: ${model.submissionID}, Email Submitted: ${submissionDateTime}, IP Address: ${ipAddress}` }); return { @@ -37,6 +45,7 @@ const parse = (model, translate) => { table: [ {label: getLabel('uniqueId'), value: model.submissionID}, {label: getLabel('submitted'), value: submissionDateTime}, + {label: getLabel('ipaddress'), value: ipAddress}, ...fields.map(f => ({ label: getLabel(f), value: model[f] @@ -47,7 +56,7 @@ const parse = (model, translate) => { }; module.exports = settings => { - return Notify(Object.assign({}, settings, { +return Notify(Object.assign({}, settings, { recipient: settings.caseworker, subject: (model, translate) => translate('email.caseworker.subject'), template: path.resolve(__dirname, '../emails/caseworker.html'), diff --git a/apps/rotm/translations/src/en/email.json b/apps/rotm/translations/src/en/email.json index ec643b7f..e7a31649 100644 --- a/apps/rotm/translations/src/en/email.json +++ b/apps/rotm/translations/src/en/email.json @@ -8,15 +8,15 @@ "submitted": { "label": "Date and time of submission" }, + "ipaddress": { + "label": "User ip address" + }, "url": { "label": "Link" }, "evidence-written": { "label": "Additional details" }, - "url": { - "label": "Link" - }, "contact-details-name": { "label": "Full name" }, diff --git a/package.json b/package.json index f97c6ec3..8b73f392 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,7 @@ "bugs": "https://github.com/UKHomeOffice/rotm/issues", "scripts": { "start": "node server.js", - "start:dev": "hof-build watch", - "dev": "hof-build watch --env", + "start:dev": "hof-build watch --env", "test": "yarn run test:lint", "test:lint": "eslint . --config ./node_modules/eslint-config-hof/default.js", "test:unit": "mocha \"test/test.setup.js\" \"test/_unit/**/*.spec.js\"", From 8c361cbe415d49a4c6752c9c84cc260219f6a4af Mon Sep 17 00:00:00 2001 From: shamiluwais Date: Fri, 19 Jul 2024 16:22:43 +0100 Subject: [PATCH 02/12] fix lint errors --- apps/rotm/behaviours/caseworker-email.js | 8 +- package.json | 1 + yarn.lock | 195 ++++++++++++++++++++++- 3 files changed, 193 insertions(+), 11 deletions(-) diff --git a/apps/rotm/behaviours/caseworker-email.js b/apps/rotm/behaviours/caseworker-email.js index 822164d2..d0db3ebf 100644 --- a/apps/rotm/behaviours/caseworker-email.js +++ b/apps/rotm/behaviours/caseworker-email.js @@ -9,9 +9,9 @@ const { createLogger, format, transports } = require('winston'); const { combine, timestamp, json } = format; const http = require('http'); -let ipAddress = ""; -http.get({'host': 'api.ipify.org', 'port': 80, 'path': '/'}, function(resp) { - resp.on('data', function(ip) { +let ipAddress = ''; +http.get({host: 'api.ipify.org', port: 80, path: '/'}, function (resp) { + resp.on('data', function (ip) { ipAddress = String.fromCharCode(...ip); }); }); @@ -56,7 +56,7 @@ const parse = (model, translate) => { }; module.exports = settings => { -return Notify(Object.assign({}, settings, { + return Notify(Object.assign({}, settings, { recipient: settings.caseworker, subject: (model, translate) => translate('email.caseworker.subject'), template: path.resolve(__dirname, '../emails/caseworker.html'), diff --git a/package.json b/package.json index 8b73f392..228b3004 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "jimp": "^0.16.1", "jpeg-js": "^0.4.4", "lodash": "^4.17.21", + "mocha": "^10.6.0", "moment": "^2.29.4", "proxyquire": "^2.1.3", "tar": "^6.2.1", diff --git a/yarn.lock b/yarn.lock index fa4a1dde..8399153d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1042,7 +1042,7 @@ aliasify@^2.1.0: dependencies: browserify-transform-tools "~1.7.0" -ansi-colors@^4.1.1: +ansi-colors@^4.1.1, ansi-colors@^4.1.3: version "4.1.3" resolved "https://registry.npmmirror.com/ansi-colors/-/ansi-colors-4.1.3.tgz" integrity sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw== @@ -1383,6 +1383,13 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" +brace-expansion@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae" + integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA== + dependencies: + balanced-match "^1.0.0" + braces@^3.0.2, braces@~3.0.2: version "3.0.2" resolved "https://registry.npmmirror.com/braces/-/braces-3.0.2.tgz" @@ -1414,6 +1421,11 @@ browser-resolve@^2.0.0: dependencies: resolve "^1.17.0" +browser-stdout@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" + integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== + browserify-aes@^1.0.0, browserify-aes@^1.0.4: version "1.2.0" resolved "https://registry.npmmirror.com/browserify-aes/-/browserify-aes-1.2.0.tgz" @@ -1656,6 +1668,11 @@ callsites@^3.0.0: resolved "https://registry.npmmirror.com/callsites/-/callsites-3.1.0.tgz" integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== +camelcase@^6.0.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" + integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== + camelize@1.0.0: version "1.0.0" resolved "https://registry.npmmirror.com/camelize/-/camelize-1.0.0.tgz" @@ -1709,7 +1726,7 @@ chalk@^2.0.0, chalk@^2.4.2: escape-string-regexp "^1.0.5" supports-color "^5.3.0" -chalk@^4.0.0: +chalk@^4.0.0, chalk@^4.1.0: version "4.1.2" resolved "https://registry.npmmirror.com/chalk/-/chalk-4.1.2.tgz" integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== @@ -1724,7 +1741,7 @@ check-error@^1.0.2, check-error@^1.0.3: dependencies: get-func-name "^2.0.2" -"chokidar@>=3.0.0 <4.0.0", chokidar@^3.4.0: +"chokidar@>=3.0.0 <4.0.0", chokidar@^3.4.0, chokidar@^3.5.3: version "3.6.0" resolved "https://registry.npmmirror.com/chokidar/-/chokidar-3.6.0.tgz" integrity sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw== @@ -1775,6 +1792,15 @@ cli-table3@^0.6.0: optionalDependencies: "@colors/colors" "1.5.0" +cliui@^7.0.2: + version "7.0.4" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" + integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== + dependencies: + string-width "^4.2.0" + strip-ansi "^6.0.0" + wrap-ansi "^7.0.0" + color-convert@^1.9.0, color-convert@^1.9.3: version "1.9.3" resolved "https://registry.npmmirror.com/color-convert/-/color-convert-1.9.3.tgz" @@ -2082,6 +2108,18 @@ debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3 dependencies: ms "2.1.2" +debug@^4.3.5: + version "4.3.5" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.5.tgz#e83444eceb9fedd4a1da56d671ae2446a01a6e1e" + integrity sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg== + dependencies: + ms "2.1.2" + +decamelize@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-4.0.0.tgz#aa472d7bf660eb15f3494efd531cab7f2a709837" + integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ== + deep-eql@^4.1.3: version "4.1.3" resolved "https://registry.npmmirror.com/deep-eql/-/deep-eql-4.1.3.tgz" @@ -2199,7 +2237,7 @@ diff@^4.0.1: resolved "https://registry.npmmirror.com/diff/-/diff-4.0.2.tgz" integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== -diff@^5.0.0: +diff@^5.0.0, diff@^5.2.0: version "5.2.0" resolved "https://registry.npmmirror.com/diff/-/diff-5.2.0.tgz" integrity sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A== @@ -3096,6 +3134,11 @@ flat-cache@^3.0.4: keyv "^4.5.3" rimraf "^3.0.2" +flat@^5.0.2: + version "5.0.2" + resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" + integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== + flatted@^3.2.9: version "3.3.1" resolved "https://registry.npmmirror.com/flatted/-/flatted-3.3.1.tgz" @@ -3207,6 +3250,11 @@ get-assigned-identifiers@^1.2.0: resolved "https://registry.npmmirror.com/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz" integrity sha512-mBBwmeGTrxEMO4pMaaf/uUEFHnYtwr8FTe8Y/mer4rcV/bye0qGm6pw1bGZFGStxC5O76c5ZAVBGnqHmOaJpdQ== +get-caller-file@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" + integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== + get-func-name@^2.0.1, get-func-name@^2.0.2: version "2.0.2" resolved "https://registry.npmmirror.com/get-func-name/-/get-func-name-2.0.2.tgz" @@ -3284,6 +3332,17 @@ glob@^7.1.0, glob@^7.1.3, glob@^7.1.6, glob@^7.2.0: once "^1.3.0" path-is-absolute "^1.0.0" +glob@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/glob/-/glob-8.1.0.tgz#d388f656593ef708ee3e34640fdfb99a9fd1c33e" + integrity sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^5.0.1" + once "^1.3.0" + global-agent@^3.0.0: version "3.0.0" resolved "https://registry.npmmirror.com/global-agent/-/global-agent-3.0.0.tgz" @@ -3450,6 +3509,11 @@ hasown@^2.0.0, hasown@^2.0.1: dependencies: function-bind "^1.1.2" +he@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" + integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== + helmet-crossdomain@0.4.0: version "0.4.0" resolved "https://registry.npmmirror.com/helmet-crossdomain/-/helmet-crossdomain-0.4.0.tgz" @@ -3895,6 +3959,11 @@ is-pdf@^1.0.0: resolved "https://registry.npmmirror.com/is-pdf/-/is-pdf-1.0.0.tgz" integrity sha512-/I94Pa91D5IcM1yVL/znSi57Aj7OQbmhjEOqns/K8f8kRkp1JX5D9NPZMzOSLTYH/Ebhq89ERSdJk/H+x4WGCA== +is-plain-obj@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287" + integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA== + is-regex@^1.1.4: version "1.1.4" resolved "https://registry.npmmirror.com/is-regex/-/is-regex-1.1.4.tgz" @@ -3941,6 +4010,11 @@ is-typedarray@~1.0.0: resolved "https://registry.npmmirror.com/is-typedarray/-/is-typedarray-1.0.0.tgz" integrity sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA== +is-unicode-supported@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7" + integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw== + is-weakref@^1.0.2: version "1.0.2" resolved "https://registry.npmmirror.com/is-weakref/-/is-weakref-1.0.2.tgz" @@ -4252,6 +4326,14 @@ lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.21: resolved "https://registry.npmmirror.com/lodash/-/lodash-4.17.21.tgz" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== +log-symbols@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.1.0.tgz#3fbdbb95b4683ac9fc785111e792e558d4abd503" + integrity sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg== + dependencies: + chalk "^4.1.0" + is-unicode-supported "^0.1.0" + logform@^2.3.2, logform@^2.4.0: version "2.6.0" resolved "https://registry.npmmirror.com/logform/-/logform-2.6.0.tgz" @@ -4426,6 +4508,13 @@ minimalistic-crypto-utils@^1.0.1: dependencies: brace-expansion "^1.1.7" +minimatch@^5.0.1, minimatch@^5.1.6: + version "5.1.6" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.1.6.tgz#1cfcb8cf5522ea69952cd2af95ae09477f122a96" + integrity sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g== + dependencies: + brace-expansion "^2.0.1" + minimist@^1.1.0, minimist@^1.2.0, minimist@^1.2.6: version "1.2.8" resolved "https://registry.npmmirror.com/minimist/-/minimist-1.2.8.tgz" @@ -4478,6 +4567,32 @@ mkdirp@^1.0.3: resolved "https://registry.npmmirror.com/mkdirp/-/mkdirp-1.0.4.tgz" integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== +mocha@^10.6.0: + version "10.6.0" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.6.0.tgz#465fc66c52613088e10018989a3b98d5e11954b9" + integrity sha512-hxjt4+EEB0SA0ZDygSS015t65lJw/I2yRCS3Ae+SJ5FrbzrXgfYwJr96f0OvIXdj7h4lv/vLCrH3rkiuizFSvw== + dependencies: + ansi-colors "^4.1.3" + browser-stdout "^1.3.1" + chokidar "^3.5.3" + debug "^4.3.5" + diff "^5.2.0" + escape-string-regexp "^4.0.0" + find-up "^5.0.0" + glob "^8.1.0" + he "^1.2.0" + js-yaml "^4.1.0" + log-symbols "^4.1.0" + minimatch "^5.1.6" + ms "^2.1.3" + serialize-javascript "^6.0.2" + strip-json-comments "^3.1.1" + supports-color "^8.1.1" + workerpool "^6.5.1" + yargs "^16.2.0" + yargs-parser "^20.2.9" + yargs-unparser "^2.0.0" + mock-fs@^5.0.0: version "5.2.0" resolved "https://registry.npmmirror.com/mock-fs/-/mock-fs-5.2.0.tgz" @@ -4535,7 +4650,7 @@ ms@2.1.2: resolved "https://registry.npmmirror.com/ms/-/ms-2.1.2.tgz" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -ms@2.1.3, ms@^2.1.1: +ms@2.1.3, ms@^2.1.1, ms@^2.1.3: version "2.1.3" resolved "https://registry.npmmirror.com/ms/-/ms-2.1.3.tgz" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== @@ -5117,7 +5232,7 @@ random-bytes@~1.0.0: resolved "https://registry.npmmirror.com/random-bytes/-/random-bytes-1.0.0.tgz" integrity sha512-iv7LhNVO047HzYR3InF6pUcUsPQiHTM1Qal51DcGSuZFBil1aBBWG5eHPNek7bvILMaYJ/8RU1e8w1AMdHmLQQ== -randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5: +randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5, randombytes@^2.1.0: version "2.1.0" resolved "https://registry.npmmirror.com/randombytes/-/randombytes-2.1.0.tgz" integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== @@ -5313,6 +5428,11 @@ request@^2.79.0: tunnel-agent "^0.6.0" uuid "^3.3.2" +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== + require-from-string@^2.0.2: version "2.0.2" resolved "https://registry.npmmirror.com/require-from-string/-/require-from-string-2.0.2.tgz" @@ -5499,6 +5619,13 @@ serialize-error@^7.0.1: dependencies: type-fest "^0.13.1" +serialize-javascript@^6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.2.tgz#defa1e055c83bf6d59ea805d8da862254eb6a6c2" + integrity sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g== + dependencies: + randombytes "^2.1.0" + serve-static@1.15.0, serve-static@^1.14.1: version "1.15.0" resolved "https://registry.npmmirror.com/serve-static/-/serve-static-1.15.0.tgz" @@ -5796,7 +5923,7 @@ string-argv@^0.3.1: resolved "https://registry.npmmirror.com/string-argv/-/string-argv-0.3.2.tgz" integrity sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q== -string-width@^4.2.0, string-width@^4.2.3: +string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.npmmirror.com/string-width/-/string-width-4.2.3.tgz" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -5897,6 +6024,13 @@ supports-color@^7.1.0, supports-color@^7.2.0: dependencies: has-flag "^4.0.0" +supports-color@^8.1.1: + version "8.1.1" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" + integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== + dependencies: + has-flag "^4.0.0" + supports-preserve-symlinks-flag@^1.0.0: version "1.0.0" resolved "https://registry.npmmirror.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz" @@ -6421,6 +6555,20 @@ winston@^3.5.1, winston@^3.7.2: triple-beam "^1.3.0" winston-transport "^4.5.0" +workerpool@^6.5.1: + version "6.5.1" + resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.5.1.tgz#060f73b39d0caf97c6db64da004cd01b4c099544" + integrity sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA== + +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" + wrappy@1: version "1.0.2" resolved "https://registry.npmmirror.com/wrappy/-/wrappy-1.0.2.tgz" @@ -6472,6 +6620,11 @@ xtend@^4.0.0, xtend@^4.0.1, xtend@^4.0.2, xtend@~4.0.1: resolved "https://registry.npmmirror.com/xtend/-/xtend-4.0.2.tgz" integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== +y18n@^5.0.5: + version "5.0.8" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" + integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== + yallist@^2.1.2: version "2.1.2" resolved "https://registry.npmmirror.com/yallist/-/yallist-2.1.2.tgz" @@ -6487,6 +6640,34 @@ yallist@^4.0.0: resolved "https://registry.npmmirror.com/yallist/-/yallist-4.0.0.tgz" integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== +yargs-parser@^20.2.2, yargs-parser@^20.2.9: + version "20.2.9" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" + integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== + +yargs-unparser@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-2.0.0.tgz#f131f9226911ae5d9ad38c432fe809366c2325eb" + integrity sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA== + dependencies: + camelcase "^6.0.0" + decamelize "^4.0.0" + flat "^5.0.2" + is-plain-obj "^2.1.0" + +yargs@^16.2.0: + version "16.2.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" + integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== + dependencies: + cliui "^7.0.2" + escalade "^3.1.1" + get-caller-file "^2.0.5" + require-directory "^2.1.1" + string-width "^4.2.0" + y18n "^5.0.5" + yargs-parser "^20.2.2" + yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.npmmirror.com/yocto-queue/-/yocto-queue-0.1.0.tgz" From e1ad5cd2af36eea574daedf19d67f77bb2d2d8f9 Mon Sep 17 00:00:00 2001 From: shamiluwais Date: Mon, 22 Jul 2024 14:20:12 +0100 Subject: [PATCH 03/12] try different method to capture ip address --- apps/rotm/behaviours/caseworker-email.js | 4 ++-- apps/rotm/behaviours/url-repeater.js | 6 ++++++ server.js | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/rotm/behaviours/caseworker-email.js b/apps/rotm/behaviours/caseworker-email.js index d0db3ebf..6404ee07 100644 --- a/apps/rotm/behaviours/caseworker-email.js +++ b/apps/rotm/behaviours/caseworker-email.js @@ -34,7 +34,7 @@ const parse = (model, translate) => { logger.log({ level: 'info', - message: `Submission ID: ${model.submissionID}, Email Submitted: ${submissionDateTime}, IP Address: ${ipAddress}` + message: `Submission ID: ${model.submissionID}, Email Submitted: ${submissionDateTime}, IP Address: ${model.ip}` }); return { @@ -45,7 +45,7 @@ const parse = (model, translate) => { table: [ {label: getLabel('uniqueId'), value: model.submissionID}, {label: getLabel('submitted'), value: submissionDateTime}, - {label: getLabel('ipaddress'), value: ipAddress}, + {label: getLabel('ipaddress'), value: model.ip}, ...fields.map(f => ({ label: getLabel(f), value: model[f] diff --git a/apps/rotm/behaviours/url-repeater.js b/apps/rotm/behaviours/url-repeater.js index 429a24f8..d05b78d5 100644 --- a/apps/rotm/behaviours/url-repeater.js +++ b/apps/rotm/behaviours/url-repeater.js @@ -12,6 +12,8 @@ module.exports = superclass => class extends superclass { req.form.values['another-url-4'] ].filter(Boolean); const submissionID = req.sessionModel.get('submissionID'); + const ip = req.sessionModel.get('ip'); + req.log('info', `Submission ID: ${submissionID}, Saving Urls: ${req.form.values.urls}`); return super.saveValues(req, res, next); } @@ -19,6 +21,10 @@ module.exports = superclass => class extends superclass { getValues(req, res, next) { super.getValues(req, res, (err, values) => { const submissionID = req.sessionModel.get('submissionID') || uuid.v4(); + const ip = req.headers['x-forwarded-for'] || + req.connection.remoteAddress; + console.log("ipaddress : " + ip); + req.sessionModel.set('ip', ip); req.sessionModel.set('submissionID', submissionID); const urls = req.sessionModel.get('urls') || []; req.log('info', `Submission ID: ${submissionID}, Saved Urls: ${urls}`); diff --git a/server.js b/server.js index 5e585239..f993f561 100644 --- a/server.js +++ b/server.js @@ -57,6 +57,10 @@ if (config.useMocks) { } app.use((req, res, next) => { + var ip = req.headers['x-forwarded-for'] || + req.connection.remoteAddress; + console.log("ipaddress : " + ip); + // Set HTML Language res.locals.htmlLang = 'en'; From 84af1d58a7a7f30abc7eb2539be2021d6d28979e Mon Sep 17 00:00:00 2001 From: shamiluwais Date: Mon, 22 Jul 2024 15:45:36 +0100 Subject: [PATCH 04/12] set a proxy --- server.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server.js b/server.js index f993f561..0f183e4c 100644 --- a/server.js +++ b/server.js @@ -6,6 +6,12 @@ const config = require('./config'); const mockAPIs = require('./mock-apis'); const bodyParser = require('busboy-body-parser'); +var express = require('express'); +var exp = express(); + +exp.set('trust proxy', '127.0.0.1'); + + if (process.env.REDIS_URL) { config.redis = process.env.REDIS_URL; } @@ -35,6 +41,7 @@ settings = Object.assign({}, settings, { const app = hof(settings); + // Terms & Cookies added to have visibility on accessibility statement // in the footer. Once HOF has updated with that we can remove these // including the getTerms: false, getCookies: false config and common directory @@ -57,6 +64,7 @@ if (config.useMocks) { } app.use((req, res, next) => { + var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress; console.log("ipaddress : " + ip); From 2a35b77b14a9668ce9bb44e9d40640f97404158f Mon Sep 17 00:00:00 2001 From: shamiluwais Date: Tue, 23 Jul 2024 12:03:21 +0100 Subject: [PATCH 05/12] set a proxy --- apps/rotm/behaviours/url-repeater.js | 4 ++-- server.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/rotm/behaviours/url-repeater.js b/apps/rotm/behaviours/url-repeater.js index d05b78d5..0effd510 100644 --- a/apps/rotm/behaviours/url-repeater.js +++ b/apps/rotm/behaviours/url-repeater.js @@ -23,8 +23,8 @@ module.exports = superclass => class extends superclass { const submissionID = req.sessionModel.get('submissionID') || uuid.v4(); const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress; - console.log("ipaddress : " + ip); - req.sessionModel.set('ip', ip); + console.log("ipaddress : " + req.ip); + req.sessionModel.set('ip', req.ip); req.sessionModel.set('submissionID', submissionID); const urls = req.sessionModel.get('urls') || []; req.log('info', `Submission ID: ${submissionID}, Saved Urls: ${urls}`); diff --git a/server.js b/server.js index 0f183e4c..f59b6baa 100644 --- a/server.js +++ b/server.js @@ -9,7 +9,7 @@ const bodyParser = require('busboy-body-parser'); var express = require('express'); var exp = express(); -exp.set('trust proxy', '127.0.0.1'); +exp.set('trust proxy', true); if (process.env.REDIS_URL) { From 469f63dc0e873e4a8ec8e901c4771d2ff905b075 Mon Sep 17 00:00:00 2001 From: shamiluwais Date: Tue, 23 Jul 2024 12:34:25 +0100 Subject: [PATCH 06/12] set a proxy --- apps/rotm/behaviours/url-repeater.js | 4 ++-- docker-compose.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/rotm/behaviours/url-repeater.js b/apps/rotm/behaviours/url-repeater.js index 0effd510..d05b78d5 100644 --- a/apps/rotm/behaviours/url-repeater.js +++ b/apps/rotm/behaviours/url-repeater.js @@ -23,8 +23,8 @@ module.exports = superclass => class extends superclass { const submissionID = req.sessionModel.get('submissionID') || uuid.v4(); const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress; - console.log("ipaddress : " + req.ip); - req.sessionModel.set('ip', req.ip); + console.log("ipaddress : " + ip); + req.sessionModel.set('ip', ip); req.sessionModel.set('submissionID', submissionID); const urls = req.sessionModel.get('urls') || []; req.log('info', `Submission ID: ${submissionID}, Saved Urls: ${urls}`); diff --git a/docker-compose.yml b/docker-compose.yml index be38504d..280e49ef 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,7 +29,7 @@ services: - PROXY_SERVICE_HOST=app - PROXY_SERVICE_PORT=8080 - NAXSI_USE_DEFAULT_RULES=FALSE - - ADD_NGINX_SERVER_CFG=add_header Cache-Control private;add_header X-Frame-Options "SAMEORIGIN" always;add_header X-Content-Type-Options "nosniff" always;add_header X-XSS-Protection "1; mode=block" always;location /public {add_header Cache-Control max-age=86400;add_header X-Frame-Options "SAMEORIGIN" always;add_header X-Content-Type-Options "nosniff" always;add_header X-XSS-Protection "1; mode=block" always;alias /public;} + - ADD_NGINX_SERVER_CFG=add_header Cache-Control private;add_header X-Frame-Options "SAMEORIGIN" always;add_header X-Content-Type-Options "nosniff" always;add_header X-XSS-Protection "1; proxy_set_header X-Forwarded-For $remote_addr; mode=block" always;location /public {add_header Cache-Control max-age=86400;add_header X-Frame-Options "SAMEORIGIN" always;add_header X-Content-Type-Options "nosniff" always;add_header X-XSS-Protection "1; mode=block" always;alias /public;} - ERROR_REDIRECT_CODES=599 ports: - "443:443" From a4180a58eb396950f6abf82eb73fe83f74be2e85 Mon Sep 17 00:00:00 2001 From: shamiluwais Date: Wed, 24 Jul 2024 15:55:52 +0100 Subject: [PATCH 07/12] set a proxy --- apps/rotm/behaviours/caseworker-email.js | 14 +++++++------- apps/rotm/behaviours/url-repeater.js | 5 +++-- server.js | 10 +++++----- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/apps/rotm/behaviours/caseworker-email.js b/apps/rotm/behaviours/caseworker-email.js index 6404ee07..a2202a93 100644 --- a/apps/rotm/behaviours/caseworker-email.js +++ b/apps/rotm/behaviours/caseworker-email.js @@ -7,14 +7,14 @@ const moment = require('moment'); const config = require('../../../config'); const { createLogger, format, transports } = require('winston'); const { combine, timestamp, json } = format; -const http = require('http'); +// const http = require('http'); -let ipAddress = ''; -http.get({host: 'api.ipify.org', port: 80, path: '/'}, function (resp) { - resp.on('data', function (ip) { - ipAddress = String.fromCharCode(...ip); - }); -}); +// let ipAddress = ''; +// http.get({host: 'api.ipify.org', port: 80, path: '/'}, function (resp) { +// resp.on('data', function (ip) { +// ipAddress = String.fromCharCode(...ip); +// }); +// }); const logger = createLogger({ format: combine(timestamp(), json()), diff --git a/apps/rotm/behaviours/url-repeater.js b/apps/rotm/behaviours/url-repeater.js index d05b78d5..70395817 100644 --- a/apps/rotm/behaviours/url-repeater.js +++ b/apps/rotm/behaviours/url-repeater.js @@ -14,7 +14,7 @@ module.exports = superclass => class extends superclass { const submissionID = req.sessionModel.get('submissionID'); const ip = req.sessionModel.get('ip'); - req.log('info', `Submission ID: ${submissionID}, Saving Urls: ${req.form.values.urls}`); + req.log('info', `Submission ID: ${submissionID}, Saving Urls: ${req.form.values.urls}, IP Address: ${ip}`); return super.saveValues(req, res, next); } @@ -23,7 +23,8 @@ module.exports = superclass => class extends superclass { const submissionID = req.sessionModel.get('submissionID') || uuid.v4(); const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress; - console.log("ipaddress : " + ip); + // eslint-disable-next-line no-console + console.log('ipaddress : ' + ip); req.sessionModel.set('ip', ip); req.sessionModel.set('submissionID', submissionID); const urls = req.sessionModel.get('urls') || []; diff --git a/server.js b/server.js index f59b6baa..76e7be1c 100644 --- a/server.js +++ b/server.js @@ -6,8 +6,8 @@ const config = require('./config'); const mockAPIs = require('./mock-apis'); const bodyParser = require('busboy-body-parser'); -var express = require('express'); -var exp = express(); +const express = require('express'); +const exp = express(); exp.set('trust proxy', true); @@ -64,10 +64,10 @@ if (config.useMocks) { } app.use((req, res, next) => { - - var ip = req.headers['x-forwarded-for'] || + const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress; - console.log("ipaddress : " + ip); + // eslint-disable-next-line no-console + console.log('ipaddress : ' + ip); // Set HTML Language res.locals.htmlLang = 'en'; From 4d18f9c49d93dc365deb2a3e1d69433bd0cdd830 Mon Sep 17 00:00:00 2001 From: shamiluwais Date: Wed, 24 Jul 2024 16:49:52 +0100 Subject: [PATCH 08/12] try different methods to capture ip address --- apps/rotm/behaviours/url-repeater.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/rotm/behaviours/url-repeater.js b/apps/rotm/behaviours/url-repeater.js index 70395817..183a016e 100644 --- a/apps/rotm/behaviours/url-repeater.js +++ b/apps/rotm/behaviours/url-repeater.js @@ -21,8 +21,11 @@ module.exports = superclass => class extends superclass { getValues(req, res, next) { super.getValues(req, res, (err, values) => { const submissionID = req.sessionModel.get('submissionID') || uuid.v4(); - const ip = req.headers['x-forwarded-for'] || - req.connection.remoteAddress; + console.log('x-forwarded-for : ' + req.headers['x-forwarded-for']); + console.log('remoteAddress: ' + req.connection.remoteAddress); + console.log('x-Real-IP: ' + req.header('x-Real-IP')); + console.log('req.ip ' + req.ip); + const ip = req.header('x-Real-IP'); // eslint-disable-next-line no-console console.log('ipaddress : ' + ip); req.sessionModel.set('ip', ip); From 3a4a61609f1e8fe5b77797159f71daf2a00dd734 Mon Sep 17 00:00:00 2001 From: shamiluwais Date: Thu, 25 Jul 2024 11:54:19 +0100 Subject: [PATCH 09/12] try different methods to capture ip address --- apps/rotm/behaviours/url-repeater.js | 10 +++++----- docker-compose.yml | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/rotm/behaviours/url-repeater.js b/apps/rotm/behaviours/url-repeater.js index 183a016e..87f213d0 100644 --- a/apps/rotm/behaviours/url-repeater.js +++ b/apps/rotm/behaviours/url-repeater.js @@ -21,11 +21,11 @@ module.exports = superclass => class extends superclass { getValues(req, res, next) { super.getValues(req, res, (err, values) => { const submissionID = req.sessionModel.get('submissionID') || uuid.v4(); - console.log('x-forwarded-for : ' + req.headers['x-forwarded-for']); - console.log('remoteAddress: ' + req.connection.remoteAddress); - console.log('x-Real-IP: ' + req.header('x-Real-IP')); - console.log('req.ip ' + req.ip); - const ip = req.header('x-Real-IP'); + // console.log('x-forwarded-for : ' + req.headers['x-forwarded-for'].split(',')[0].trim()); + // console.log('remoteAddress: ' + req.connection.remoteAddress.split(',')[0].trim()); + // console.log('x-Real-IP: ' + req.header('x-Real-IP').split(',')[0].trim()); + // console.log('req.ip ' + req.ip.split(',')[0].trim()); + const ip = (req.headers['x-forwarded-for'] || req.connection.remoteAddress || '').split(',')[0].trim() // eslint-disable-next-line no-console console.log('ipaddress : ' + ip); req.sessionModel.set('ip', ip); diff --git a/docker-compose.yml b/docker-compose.yml index 280e49ef..2735edfa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,11 +29,11 @@ services: - PROXY_SERVICE_HOST=app - PROXY_SERVICE_PORT=8080 - NAXSI_USE_DEFAULT_RULES=FALSE - - ADD_NGINX_SERVER_CFG=add_header Cache-Control private;add_header X-Frame-Options "SAMEORIGIN" always;add_header X-Content-Type-Options "nosniff" always;add_header X-XSS-Protection "1; proxy_set_header X-Forwarded-For $remote_addr; mode=block" always;location /public {add_header Cache-Control max-age=86400;add_header X-Frame-Options "SAMEORIGIN" always;add_header X-Content-Type-Options "nosniff" always;add_header X-XSS-Protection "1; mode=block" always;alias /public;} + - ADD_NGINX_SERVER_CFG=add_header Cache-Control private;add_header X-Frame-Options "SAMEORIGIN" always;add_header X-Content-Type-Options "nosniff" always;add_header X-XSS-Protection "1; mode=block" always;location /public {add_header Cache-Control max-age=86400;add_header X-Frame-Options "SAMEORIGIN" always;add_header X-Content-Type-Options "nosniff" always;add_header X-XSS-Protection "1; mode=block" always;alias /public;} - ERROR_REDIRECT_CODES=599 ports: - - "443:443" - - "80:80" + - "444:444" + - "81:81" links: - app volumes_from: From ffc8294551c05c000194e68d7e642c7d0d779cf8 Mon Sep 17 00:00:00 2001 From: shamiluwais Date: Thu, 25 Jul 2024 14:51:10 +0100 Subject: [PATCH 10/12] try different methods to capture ip address --- apps/rotm/behaviours/caseworker-email.js | 15 ++++++++------- apps/rotm/behaviours/url-repeater.js | 8 ++++---- docker-compose.yml | 4 ++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/apps/rotm/behaviours/caseworker-email.js b/apps/rotm/behaviours/caseworker-email.js index a2202a93..c07c4227 100644 --- a/apps/rotm/behaviours/caseworker-email.js +++ b/apps/rotm/behaviours/caseworker-email.js @@ -7,14 +7,15 @@ const moment = require('moment'); const config = require('../../../config'); const { createLogger, format, transports } = require('winston'); const { combine, timestamp, json } = format; -// const http = require('http'); +const http = require('http'); -// let ipAddress = ''; -// http.get({host: 'api.ipify.org', port: 80, path: '/'}, function (resp) { -// resp.on('data', function (ip) { -// ipAddress = String.fromCharCode(...ip); -// }); -// }); +let ipAddress = ''; +http.get({host: 'api.ipify.org', port: 80, path: '/'}, function (resp) { + resp.on('data', function (ip) { + ipAddress = String.fromCharCode(...ip); + console.log('api.ipify.org ip address : ' + ip); console.log('ipaddress : ' + ipAddress); + }); +}); const logger = createLogger({ format: combine(timestamp(), json()), diff --git a/apps/rotm/behaviours/url-repeater.js b/apps/rotm/behaviours/url-repeater.js index 87f213d0..6ee539e7 100644 --- a/apps/rotm/behaviours/url-repeater.js +++ b/apps/rotm/behaviours/url-repeater.js @@ -21,10 +21,10 @@ module.exports = superclass => class extends superclass { getValues(req, res, next) { super.getValues(req, res, (err, values) => { const submissionID = req.sessionModel.get('submissionID') || uuid.v4(); - // console.log('x-forwarded-for : ' + req.headers['x-forwarded-for'].split(',')[0].trim()); - // console.log('remoteAddress: ' + req.connection.remoteAddress.split(',')[0].trim()); - // console.log('x-Real-IP: ' + req.header('x-Real-IP').split(',')[0].trim()); - // console.log('req.ip ' + req.ip.split(',')[0].trim()); + console.log('x-forwarded-for : ' + req.headers['x-forwarded-for']); + console.log('remoteAddress: ' + req.connection.remoteAddress); + console.log('x-Real-IP: ' + req.header('x-Real-IP')); + console.log('req.ip ' + req.ip); const ip = (req.headers['x-forwarded-for'] || req.connection.remoteAddress || '').split(',')[0].trim() // eslint-disable-next-line no-console console.log('ipaddress : ' + ip); diff --git a/docker-compose.yml b/docker-compose.yml index 2735edfa..be38504d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -32,8 +32,8 @@ services: - ADD_NGINX_SERVER_CFG=add_header Cache-Control private;add_header X-Frame-Options "SAMEORIGIN" always;add_header X-Content-Type-Options "nosniff" always;add_header X-XSS-Protection "1; mode=block" always;location /public {add_header Cache-Control max-age=86400;add_header X-Frame-Options "SAMEORIGIN" always;add_header X-Content-Type-Options "nosniff" always;add_header X-XSS-Protection "1; mode=block" always;alias /public;} - ERROR_REDIRECT_CODES=599 ports: - - "444:444" - - "81:81" + - "443:443" + - "80:80" links: - app volumes_from: From d593634d5073dbc2b3c59af8c62e5cf5005b0980 Mon Sep 17 00:00:00 2001 From: shamiluwais Date: Fri, 26 Jul 2024 11:49:21 +0100 Subject: [PATCH 11/12] fix lint errors --- apps/rotm/behaviours/caseworker-email.js | 1 + apps/rotm/behaviours/url-repeater.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/rotm/behaviours/caseworker-email.js b/apps/rotm/behaviours/caseworker-email.js index c07c4227..6d25db33 100644 --- a/apps/rotm/behaviours/caseworker-email.js +++ b/apps/rotm/behaviours/caseworker-email.js @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ 'use strict'; const hof = require('hof'); diff --git a/apps/rotm/behaviours/url-repeater.js b/apps/rotm/behaviours/url-repeater.js index 6ee539e7..2484ac6a 100644 --- a/apps/rotm/behaviours/url-repeater.js +++ b/apps/rotm/behaviours/url-repeater.js @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ 'use strict'; const uuid = require('uuid'); @@ -25,7 +26,7 @@ module.exports = superclass => class extends superclass { console.log('remoteAddress: ' + req.connection.remoteAddress); console.log('x-Real-IP: ' + req.header('x-Real-IP')); console.log('req.ip ' + req.ip); - const ip = (req.headers['x-forwarded-for'] || req.connection.remoteAddress || '').split(',')[0].trim() + const ip = (req.headers['x-forwarded-for'] || req.connection.remoteAddress || '').split(',')[0].trim(); // eslint-disable-next-line no-console console.log('ipaddress : ' + ip); req.sessionModel.set('ip', ip); From 63ed5cacbcbaec32016458e9c3a19a74ff90f8d3 Mon Sep 17 00:00:00 2001 From: shamiluwais Date: Fri, 26 Jul 2024 12:06:05 +0100 Subject: [PATCH 12/12] try setting nginx proxy settings in rotm --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index be38504d..08bd7fba 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,7 +29,7 @@ services: - PROXY_SERVICE_HOST=app - PROXY_SERVICE_PORT=8080 - NAXSI_USE_DEFAULT_RULES=FALSE - - ADD_NGINX_SERVER_CFG=add_header Cache-Control private;add_header X-Frame-Options "SAMEORIGIN" always;add_header X-Content-Type-Options "nosniff" always;add_header X-XSS-Protection "1; mode=block" always;location /public {add_header Cache-Control max-age=86400;add_header X-Frame-Options "SAMEORIGIN" always;add_header X-Content-Type-Options "nosniff" always;add_header X-XSS-Protection "1; mode=block" always;alias /public;} + - ADD_NGINX_SERVER_CFG=add_header Cache-Control private;add_header X-Frame-Options "SAMEORIGIN" always; location /public { proxy_pass http://127.0.0.1::8080; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto $scheme; }; add_header X-Content-Type-Options "nosniff" always;add_header X-XSS-Protection "1; mode=block" always;location /public {add_header Cache-Control max-age=86400;add_header X-Frame-Options "SAMEORIGIN" always;add_header X-Content-Type-Options "nosniff" always;add_header X-XSS-Protection "1; mode=block" always;alias /public;} - ERROR_REDIRECT_CODES=599 ports: - "443:443"