-
Notifications
You must be signed in to change notification settings - Fork 7
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
DO NOT MERGE fix: Отключена автоостановка слушания #202
base: master
Are you sure you want to change the base?
Conversation
|
05e417f
to
c7f8799
Compare
c7f8799
to
eb9e01c
Compare
c183aef
to
36e72da
Compare
c25035c
to
d4e7aa8
Compare
913b423
to
2c5ba40
Compare
47e83cd
to
bde6ae3
Compare
bde6ae3
to
e4994e1
Compare
283b2af
to
b7e5a11
Compare
b7e5a11
to
cdf16a4
Compare
8db8a42
to
8ce9dab
Compare
8ce9dab
to
6c3de01
Compare
userId: `webdbg_userid_${ | ||
Math.random().toString(36).substring(2, 13) + | ||
Math.random().toString(36).substring(2, 13) | ||
}`, |
Check failure
Code scanning / CodeQL
Insecure randomness High test
Math.random()
This uses a cryptographically insecure random number generated at
Math.random()
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 21 days ago
To fix the problem, we need to replace the use of Math.random()
with a cryptographically secure random number generator. In a browser environment, we can use window.crypto.getRandomValues
to generate secure random values. This method provides a cryptographically secure way to generate random numbers.
We will replace the Math.random().toString(36).substring(2, 13)
calls with a function that generates a secure random string of the same length using window.crypto.getRandomValues
.
-
Copy modified lines R4-R9 -
Copy modified line R20 -
Copy modified line R78
@@ -3,2 +3,8 @@ | ||
|
||
function generateSecureRandomString(length) { | ||
const array = new Uint8Array(length); | ||
window.crypto.getRandomValues(array); | ||
return Array.from(array, byte => ('0' + (byte & 0xFF).toString(36)).slice(-2)).join('').substring(0, length); | ||
} | ||
|
||
const token = ''; | ||
@@ -13,6 +19,3 @@ | ||
url: "wss://nlp2vps.online.sberbank.ru:443/vps/", | ||
userId: `webdbg_userid_${ | ||
Math.random().toString(36).substring(2, 13) + | ||
Math.random().toString(36).substring(2, 13) | ||
}`, | ||
userId: `webdbg_userid_${generateSecureRandomString(22)}`, | ||
userChannel: "B2C", | ||
@@ -74,6 +77,3 @@ | ||
url: "wss://nlp2vps.online.sberbank.ru:443/vps/", | ||
userId: `webdbg_userid_${ | ||
Math.random().toString(36).substring(2, 13) + | ||
Math.random().toString(36).substring(2, 13) | ||
}`, | ||
userId: `webdbg_userid_${generateSecureRandomString(22)}`, | ||
userChannel: "B2C", |
userId: `webdbg_userid_${ | ||
Math.random().toString(36).substring(2, 13) + | ||
Math.random().toString(36).substring(2, 13) | ||
}`, |
Check failure
Code scanning / CodeQL
Insecure randomness High test
Math.random()
This uses a cryptographically insecure random number generated at
Math.random()
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 21 days ago
To fix the problem, we need to replace the use of Math.random()
with a cryptographically secure random number generator. In a browser environment, we can use window.crypto.getRandomValues
to generate secure random values. We will generate a random string using Uint32Array
and convert it to a base-36 string to maintain the existing functionality.
-
Copy modified line R15 -
Copy modified line R75
@@ -14,4 +14,3 @@ | ||
userId: `webdbg_userid_${ | ||
Math.random().toString(36).substring(2, 13) + | ||
Math.random().toString(36).substring(2, 13) | ||
Array.from(window.crypto.getRandomValues(new Uint32Array(2)), num => num.toString(36)).join('').substring(0, 22) | ||
}`, | ||
@@ -75,4 +74,3 @@ | ||
userId: `webdbg_userid_${ | ||
Math.random().toString(36).substring(2, 13) + | ||
Math.random().toString(36).substring(2, 13) | ||
Array.from(window.crypto.getRandomValues(new Uint32Array(2)), num => num.toString(36)).join('').substring(0, 22) | ||
}`, |
📦 Published PR as canary version:
1.36.0--canary.202.c0eaf10ca7c551907dbb4684a81c19f8a59085ac.0
✨ Test out this PR locally via:
npm install @salutejs/client@1.36.0--canary.202.c0eaf10ca7c551907dbb4684a81c19f8a59085ac.0 # or yarn add @salutejs/client@1.36.0--canary.202.c0eaf10ca7c551907dbb4684a81c19f8a59085ac.0