Skip to content

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

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft

UBERF-9747 #8867

wants to merge 1 commit into from

Conversation

haiodo
Copy link
Member

@haiodo haiodo commented May 7, 2025

No description provided.

Copy link

Connected to Huly®: UBERF-10522

Signed-off-by: Andrey Sobolev <[email protected]>
Comment on lines +303 to +310
const employee = await ensureEmployee(
ctx,
accountRef,
newClient,
workspaceLoginInfo.workspace,
Array.from(accountRef.fullSocialIds.values()),
getGlobalPerson
)

Check failure

Code scanning / CodeQL

Insecure randomness High

This uses a cryptographically insecure random number generated at
Math.random()
in a security context.
This uses a cryptographically insecure random number generated at
Math.random()
in a security context.

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:

  1. Replacing the Math.random() calls in packages/core/src/utils.ts with crypto.getRandomValues.
  2. Updating the random variable to use secure random values.
  3. Ensuring that the generateId function continues to work as expected with the new secure randomness.

Suggested changeset 1
packages/core/src/utils.ts
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/core/src/utils.ts b/packages/core/src/utils.ts
--- a/packages/core/src/utils.ts
+++ b/packages/core/src/utils.ts
@@ -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)
 
EOF
@@ -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)

Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant