fix(ui): code scanning alert no. 1681: Insecure randomness #23886 (#23886)

This commit is contained in:
Ushran Gouhar 2025-10-15 00:17:18 +05:30 committed by GitHub
parent b39c08256c
commit 63a8862e28
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -258,7 +258,7 @@ export const formatJsonString = (jsonString: string, indent = '') => {
export const replaceCallback = (character: string) => {
// Generate a random number between 0 and 15
const randomNumber = (Math.random() * 16) | 0;
const randomNumber = crypto.getRandomValues(new Uint8Array(1))[0] & 0xf;
// If the character in the UUID template is 'x', use the random number.
// Otherwise, use the random number ANDed with 0x3 (which gives a number between 0 and 3) ORed with 0x8