From 1e94c3bd81226f3447055898a4c9c9bcbad9a0a5 Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Sun, 14 Aug 2022 07:09:45 +0530 Subject: [PATCH] Fixed Security Hotspot reported by SonarQube. --- runtime/src/js/pgadmin.js | 12 +----------- web/pgadmin/dashboard/static/js/PgAdminLogo.jsx | 2 +- .../static/js/components/PreferencesComponent.jsx | 6 +++--- web/pgadmin/static/js/Explain/Graphical.jsx | 4 ++-- web/pgadmin/static/js/Explain/svg_download.js | 2 +- web/pgadmin/static/js/backform.pgadmin.js | 2 +- web/pgadmin/static/js/helpers/ModalProvider.jsx | 2 +- web/pgadmin/static/js/utils.js | 8 +++++--- .../js/components/DebuggerArgumentComponent.jsx | 4 ++-- 9 files changed, 17 insertions(+), 25 deletions(-) diff --git a/runtime/src/js/pgadmin.js b/runtime/src/js/pgadmin.js index 42583431a..14bbaeeb9 100644 --- a/runtime/src/js/pgadmin.js +++ b/runtime/src/js/pgadmin.js @@ -38,16 +38,6 @@ if (fs.existsSync('dev_config.json')) { } } -// This function is used to create UUID -function createUUID() { - let dt = new Date().getTime(); - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { - let r = (dt + Math.random()*16)%16 | 0; - dt = Math.floor(dt/16); - return (c==='x' ? r :(r&0x3|0x8)).toString(16); - }); -} - // This functions is used to start the pgAdmin4 server by spawning a // separate process. function startDesktopMode() { @@ -56,7 +46,7 @@ function startDesktopMode() { if (pgadminServerProcess != null) return; - let UUID = createUUID(); + let UUID = crypto.randomUUID(); // Set the environment variables so that pgAdmin 4 server // starts listening on the appropriate port. process.env.PGADMIN_INT_PORT = serverPort; diff --git a/web/pgadmin/dashboard/static/js/PgAdminLogo.jsx b/web/pgadmin/dashboard/static/js/PgAdminLogo.jsx index ecfe6e9e1..cea7b1fb4 100644 --- a/web/pgadmin/dashboard/static/js/PgAdminLogo.jsx +++ b/web/pgadmin/dashboard/static/js/PgAdminLogo.jsx @@ -12,7 +12,7 @@ export default function PgAdminLogo() { return (