From d51984abc99216ec0c0776320f52c8323bcc000b Mon Sep 17 00:00:00 2001 From: Prabhu Murthy Date: Wed, 17 Jan 2024 12:09:39 +0530 Subject: [PATCH] fix sonar security issue (#458) replacing Math.random with custom getUniqueId function --- sonar-project.properties | 2 +- src/components/index.tsx | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/sonar-project.properties b/sonar-project.properties index d736e51d..3ad7a882 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -6,7 +6,7 @@ sonar.organization=prabhuignoto #sonar.projectVersion=1.0 sonar.sources=src -sonar.exclusions=**/node_modules/**,**/*.test.js,**/*.spec.js,**/*.test.jsx,**/*.spec.jsx,**/*.test.ts,**/*.spec.ts,**/*.test.tsx,**/*.spec.tsx,coverage/**,build/**,dist/**,public/**,src/setupTests.js,src/setupTests.ts,src/setupTests.tsx,src/setupTests.jsx,src/setupTests.test.js,src/setupTests.test.ts,src/setupTests.test.tsx,src/setupTests.test.jsx,src/setupTests.spec.js,src/setupTests.spec.ts,src/setupTests.spec.tsx,src/setupTests.spec.jsx,src/serviceWorker.js,src/serviceWorker.ts,src/serviceWorker.tsx,src/serviceWorker.jsx,src/serviceWorker.test.js,src/serviceWorker.test.ts,src/serviceWorker.test.tsx,src/serviceWorker.test.jsx,src/serviceWorker.spec.js,src/serviceWorker.spec.ts,src/serviceWorker.spec.tsx,src/serviceWorker.spec.jsx,demo/** +sonar.exclusions=**/node_modules/**,**/*.test.js,**/*.spec.js,**/*.test.jsx,**/*.spec.jsx,**/*.test.ts,**/*.spec.ts,**/*.test.tsx,**/*.spec.tsx,coverage/**,build/**,dist/**,public/**,src/setupTests.js,src/setupTests.ts,src/setupTests.tsx,src/setupTests.jsx,src/setupTests.test.js,src/setupTests.test.ts,src/setupTests.test.tsx,src/setupTests.test.jsx,src/setupTests.spec.js,src/setupTests.spec.ts,src/setupTests.spec.tsx,src/setupTests.spec.jsx,src/serviceWorker.js,src/serviceWorker.ts,src/serviceWorker.tsx,src/serviceWorker.jsx,src/serviceWorker.test.js,src/serviceWorker.test.ts,src/serviceWorker.test.tsx,src/serviceWorker.test.jsx,src/serviceWorker.spec.js,src/serviceWorker.spec.ts,src/serviceWorker.spec.tsx,src/serviceWorker.spec.jsx,src/demo/** # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. diff --git a/src/components/index.tsx b/src/components/index.tsx index cdd5e98a..1a5a3cb1 100644 --- a/src/components/index.tsx +++ b/src/components/index.tsx @@ -61,7 +61,7 @@ const Chrono: React.FunctionComponent> = ( return Array.from({ length: itemLength }).map((_, index) => ({ active: index === activeItemIndex, - id: Math.random().toString(16).slice(2), + id: getUniqueID(), visible: true, })); }; @@ -73,7 +73,6 @@ const Chrono: React.FunctionComponent> = ( return lineItems.map((item, index) => ({ ...item, active: index === pos, - // id: Math.random().toString(16).slice(2), visible: true, })); } else {