diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d1334a503..6b7eb5ec64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ All notable changes to the Wazuh app project will be documented in this file. - Added node name of agent list and detail [#3039](https://github.com/wazuh/wazuh-kibana-app/pull/3039) - Added loading view while the user is logging to prevent permissions prompts [#3041](https://github.com/wazuh/wazuh-kibana-app/pull/3041) - Added custom message for each possible run_as setup [#3048](https://github.com/wazuh/wazuh-kibana-app/pull/3048) +- Improve validation and prevention for caching bundles in client side [#3091](https://github.com/wazuh/wazuh-kibana-app/pull/3091) ### Fixed diff --git a/public/assets/meta.json b/public/assets/meta.json deleted file mode 100644 index e785e8483e..0000000000 --- a/public/assets/meta.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "version": "4.1.2", - "revision": "4201-2" -} \ No newline at end of file diff --git a/public/utils/check-plugin-version.ts b/public/utils/check-plugin-version.ts index fdcbddbb99..1b118aea51 100644 --- a/public/utils/check-plugin-version.ts +++ b/public/utils/check-plugin-version.ts @@ -12,8 +12,8 @@ import { GenericRequest } from '../react-services/generic-request'; import { AxiosResponse } from 'axios'; import _ from 'lodash'; -import meta from '../assets/meta.json'; -import { getCookies } from '../kibana-services'; +import { version as appVersion, revision as appRevision} from '../../package.json'; +import { getCookies, getToasts } from '../kibana-services'; type TAppInfo = { revision: string; @@ -39,9 +39,19 @@ export const checkPluginVersion = async () => { }; const checkClientAppVersion = (appInfo: TAppInfo) => { - if (appInfo['app-version'] !== meta.version || appInfo.revision !== meta.revision) { - clearBrowserInfo(appInfo); + if (appInfo['app-version'] !== appVersion || appInfo.revision !== appRevision) { + if( window.history.state !== 'refreshed') { + clearBrowserInfo(appInfo); + } else { + getToasts().addDanger({ + title: 'Conflict with the Wazuh app version', + text: 'The version of the Wazuh app in your browser does not correspond with the app version installed in Kibana.\nPlease clear your browser cache.\nIf the error persist please restart Kibana too.' + }); + } } else { + if(window.history.state == 'refreshed'){ + window.history.replaceState('', 'wazuh'); + }; const storeAppInfo = localStorage.getItem('appInfo'); !storeAppInfo && updateAppInfo(appInfo); } @@ -63,6 +73,9 @@ function clearBrowserInfo(appInfo: TAppInfo) { //update localStorage updateAppInfo(appInfo); + //replace status to avoid infinite refresh + window.history.replaceState('refreshed', 'wazuh'); + // delete browser cache and hard reload window.location.reload(true); } @@ -70,3 +83,4 @@ function clearBrowserInfo(appInfo: TAppInfo) { function updateAppInfo(appInfo: TAppInfo) { localStorage.setItem('appInfo', JSON.stringify(appInfo)); } + diff --git a/scripts/generate-build-version.js b/scripts/generate-build-version.js index c162f81f15..a03dd975fe 100644 --- a/scripts/generate-build-version.js +++ b/scripts/generate-build-version.js @@ -2,23 +2,6 @@ const fs = require('fs'); const packageJson = require('../package.json'); const { version, revision } = packageJson; -const jsonData = { - version, - revision, -}; - -const jsonContent = JSON.stringify(jsonData, null, 2); - -//write meta.json with last version -fs.writeFile('./public/assets/meta.json', jsonContent, 'utf8', function (err) { - if (err) { - console.log('An error occurred while writing JSON Object to meta.json'); - return console.log(err); - } - - console.log('meta.json file has been saved with latest version number'); -}); - //replaces kibana.json with last fs.readFile('kibana.json', 'utf-8', function (err, data) { if (err) {