Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test - please do not merge #237

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ trigger:

linting: &linting
pull: if-not-exists
image: node:14
image: node:18
environment:
NOTIFY_KEY: USE_MOCK
commands:
- yarn run test:lint

unit_tests: &unit_tests
pull: if-not-exists
image: node:14
image: node:18
environment:
NOTIFY_KEY: USE_MOCK
commands:
Expand Down Expand Up @@ -70,7 +70,7 @@ steps:

- name: setup_deploy
pull: if-not-exists
image: node:14
image: node:18
environment:
NOTIFY_KEY: USE_MOCK
commands:
Expand Down Expand Up @@ -165,7 +165,7 @@ steps:

- name: setup_branch
pull: if-not-exists
image: node:14
image: node:18
environment:
NOTIFY_KEY: USE_MOCK
commands:
Expand Down Expand Up @@ -220,7 +220,7 @@ steps:
# Snyk & Anchore security scans which run after branch deployment to prevent blocking of PR UAT tests
- name: snyk_scan
pull: if-not-exists
image: node:14
image: node:18
environment:
SNYK_TOKEN:
from_secret: snyk_token
Expand Down Expand Up @@ -425,7 +425,7 @@ steps:

- name: cron_snyk_scan
pull: if-not-exists
image: node:14
image: node:18
environment:
SNYK_TOKEN:
from_secret: snyk_token
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM node:14-alpine@sha256:5c33bc6f021453ae2e393e6e20650a4df0a4737b1882d389f17069dc1933fdc5
FROM node:lts-alpine@sha256:b78c9500958805b52214e8bd588defe55ec32116dfdc094e3ca652a3502d67df

USER root

# Update packages as a result of Anchore security vulnerability checks
RUN apk update && \
apk add --upgrade gnutls binutils nodejs nodejs-npm apk-tools libjpeg-turbo libcurl libx11 libxml2
apk add --upgrade gnutls binutils nodejs npm apk-tools libjpeg-turbo libcurl libx11 libxml2

# Setup nodejs group & nodejs user
RUN addgroup --system nodejs --gid 998 && \
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "A Home Office application for reporting online terrorist material.",
"license": "GPL-2.0",
"engines": {
"node": "^14.15.0"
"node": ">=18.0.0"
},
"repository": {
"type": "git",
Expand All @@ -14,7 +14,7 @@
"bugs": "https://github.com/UKHomeOffice/rotm/issues",
"scripts": {
"start": "node server.js",
"start:dev": "hof-build watch --env",
"start:dev": "hof-build watch",
"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\"",
Expand All @@ -32,11 +32,15 @@
"express": "^4.17.1",
"govuk-frontend": "^3.13.0",
"hof": "^19.14.13",
"ipify": "^6.0.0",
"ipware": "^2.0.0",
"jimp": "^0.16.1",
"jpeg-js": "^0.4.4",
"lodash": "^4.17.21",
"moment": "^2.29.4",
"node": "^18.13.0",
"proxyquire": "^2.1.3",
"request-ip": "^3.3.0",
"tar": "^6.1.11",
"uuid": "^8.3.2",
"winston": "^3.5.1"
Expand Down
31 changes: 31 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ const hof = require('hof');
const config = require('./config');
const mockAPIs = require('./mock-apis');
const bodyParser = require('busboy-body-parser');
const requestIp = require('request-ip');
var http = require('http');

http.get({'host': 'api.ipify.org', 'port': 80, 'path': '/'}, function(resp) {
resp.on('data', function(ip) {
console.log("My public IP address is: " + ip);
});
});

if (process.env.REDIS_URL) {
config.redis = process.env.REDIS_URL;
Expand Down Expand Up @@ -44,7 +52,30 @@ if (config.useMocks) {
app.use(mockAPIs);
}

var getIP = require('ipware')().get_ip;
app.use(function(req, res, next) {
var ipInfo = getIP(req);
console.log("ipInfo " + ipInfo.clientIp);
// { clientIp: '127.0.0.1', clientIpRoutable: false }
next();
});

/* app.use(requestIp.mw())

app.use((req, res) => {
const ip = req.clientIp;
console.log("ip1 : " + ip);
}); */

app.use((req, res, next) => {



var ip = req.headers['x-forwarded-for'] ||
req.connection.remoteAddress;

console.log("ip2 : " + ip);

// Set HTML Language
res.locals.htmlLang = 'en';

Expand Down
Loading