From 42fcdfdf43e794d1a1d764e337ae8706da5102b1 Mon Sep 17 00:00:00 2001 From: George Raduta Date: Thu, 5 Oct 2023 13:16:10 +0200 Subject: [PATCH] [OGUI-1426] && [OGUI-1427] Improve resilience of ILG (#2146) * Adds default value for instance name on both client and server sides. * removes the `port` and `host` information from `status` API request * removes open access to `frameworkInfo` --- InfoLogger/lib/StatusService.js | 4 ++-- InfoLogger/lib/api.js | 2 +- InfoLogger/public/index.js | 1 + InfoLogger/test/lib/mocha-status-service.js | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/InfoLogger/lib/StatusService.js b/InfoLogger/lib/StatusService.js index 65b106eba..740c7ddba 100644 --- a/InfoLogger/lib/StatusService.js +++ b/InfoLogger/lib/StatusService.js @@ -59,7 +59,7 @@ class StatusService { result.version = this.projPackage.version; } if (this.config.http) { - const ilg = {hostname: this.config.http.hostname, port: this.config.http.port, status: {ok: true}}; + const ilg = {status: {ok: true}}; result = Object.assign(result, ilg); } res.status(200).json(result); @@ -95,7 +95,7 @@ class StatusService { } if (this.config.http) { const {http} = this.config; - const ilg = {hostname: http.hostname, port: http.port, status: {ok: true}, name: http.name }; + const ilg = {hostname: http.hostname, port: http.port, status: {ok: true}, name: http.name ?? '' }; info = Object.assign(info, ilg); } return info; diff --git a/InfoLogger/lib/api.js b/InfoLogger/lib/api.js index 67d6341c0..c8ec3dd73 100644 --- a/InfoLogger/lib/api.js +++ b/InfoLogger/lib/api.js @@ -39,7 +39,7 @@ module.exports.attachTo = async (http, ws) => { http.get('/query/stats', queryController.getQueryStats.bind(queryController), {public: true}); http.get('/status/gui', statusService.getILGStatus.bind(statusService), {public: true}); - http.get('/getFrameworkInfo', statusService.frameworkInfo.bind(statusService), {public: true}); + http.get('/getFrameworkInfo', statusService.frameworkInfo.bind(statusService)); http.get('/getUserProfile', (req, res) => profileService.getUserProfile(req, res)); http.get('/getProfile', (req, res) => profileService.getProfile(req, res)); diff --git a/InfoLogger/public/index.js b/InfoLogger/public/index.js index 5bdedb7cd..726cd1b16 100644 --- a/InfoLogger/public/index.js +++ b/InfoLogger/public/index.js @@ -30,3 +30,4 @@ mount(document.body, view, model, debug); // Expose model to interact with it the browser's console window.model = model; +window.ILG = {name: 'ILG - '}; diff --git a/InfoLogger/test/lib/mocha-status-service.js b/InfoLogger/test/lib/mocha-status-service.js index 63acfa03a..6077d42ec 100644 --- a/InfoLogger/test/lib/mocha-status-service.js +++ b/InfoLogger/test/lib/mocha-status-service.js @@ -129,7 +129,7 @@ describe('Status Service test suite', () => { } await statusService.getILGStatus(undefined, res); - const info = {hostname: 'localhost', port: 8080, status: {ok: true}}; + const info = {status: {ok: true}}; assert.ok(res.status.calledWith(200)); assert.ok(res.json.calledWith(info));