-
Notifications
You must be signed in to change notification settings - Fork 1.4k
UBERF-9747 #8867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
UBERF-9747 #8867
Conversation
Connected to Huly®: UBERF-10522 |
Signed-off-by: Andrey Sobolev <[email protected]>
const employee = await ensureEmployee( | ||
ctx, | ||
accountRef, | ||
newClient, | ||
workspaceLoginInfo.workspace, | ||
Array.from(accountRef.fullSocialIds.values()), | ||
getGlobalPerson | ||
) |
Check failure
Code scanning / CodeQL
Insecure randomness High
Math.random()
This uses a cryptographically insecure random number generated at
Math.random()
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 hour ago
To fix the issue, we need to replace the use of Math.random()
in the generateId
function with a cryptographically secure random number generator. The best approach is to use crypto.getRandomValues
to generate secure random values. Additionally, we can replace the random
variable in packages/core/src/utils.ts
with a secure implementation.
The changes will involve:
- Replacing the
Math.random()
calls inpackages/core/src/utils.ts
withcrypto.getRandomValues
. - Updating the
random
variable to use secure random values. - Ensuring that the
generateId
function continues to work as expected with the new secure randomness.
-
Copy modified lines R64-R65
@@ -63,4 +63,4 @@ | ||
|
||
let counter = (Math.random() * (1 << 24)) | 0 | ||
const random = toHex((Math.random() * (1 << 24)) | 0, 6) + toHex((Math.random() * (1 << 16)) | 0, 4) | ||
let counter = crypto.getRandomValues(new Uint32Array(1))[0] & 0xffffff | ||
const random = toHex(crypto.getRandomValues(new Uint32Array(1))[0] & 0xffffff, 6) + toHex(crypto.getRandomValues(new Uint32Array(1))[0] & 0xffff, 4) | ||
|
No description provided.