Skip to content
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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

sasha-tlt
Copy link
Collaborator

@sasha-tlt sasha-tlt commented Mar 13, 2024

📦 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

Copy link

github-actions bot commented Mar 13, 2024

File name Prev size Next size Diff (abs) Diff (%)
📁 dist/
assistant-hash1.js 426.44 KB 426.14 KB -0.30 KB 0 %
createAssistantDevOrigin.js 119.19 KB 119.19 KB 0.00 KB 0 %
index.js 67.61 KB 67.82 KB 0.21 KB 0 %
worklet.js 0.00 KB 2.41 KB 2.41 KB 100 %
Total 613.25 KB 615.56 KB 2.32 KB 0 %
📁 esm/
assistant-hash1.js 139.09 KB 138.53 KB -0.56 KB 0 %
assistant.js 0.12 KB 0.12 KB 0.00 KB 0 %
common-hash1.js 6.14 KB 6.14 KB 0.00 KB 0 %
createAssistant.js 24.39 KB 24.39 KB 0.00 KB 0 %
createAssistantDev.js 0.37 KB 0.37 KB 0.00 KB 0 %
createAssistantDevOrigin.js 119.07 KB 119.07 KB 0.00 KB 0 %
index.js 0.99 KB 1.08 KB 0.09 KB 9 %
mock.js 5.29 KB 5.29 KB 0.00 KB 0 %
record-hash1.js 62.25 KB 62.25 KB 0.00 KB 0 %
sdk-hash1.js 255.70 KB 255.67 KB -0.03 KB 0 %
worklet.js 0.00 KB 2.40 KB 2.40 KB 100 %
Total 613.41 KB 615.31 KB 1.90 KB 0 %
📁 umd/
assistant.development.min.js 210.75 KB 210.65 KB -0.10 KB 0 %
assistant.production.min.js 12.59 KB 12.59 KB 0.00 KB 0 %
Total 223.34 KB 223.24 KB -0.10 KB 0 %

@sasha-tlt sasha-tlt force-pushed the infinite-listen branch 2 times, most recently from c25035c to d4e7aa8 Compare July 23, 2024 12:19
@sasha-tlt sasha-tlt force-pushed the infinite-listen branch 2 times, most recently from 47e83cd to bde6ae3 Compare August 5, 2024 07:23
@sasha-tlt sasha-tlt force-pushed the infinite-listen branch 2 times, most recently from 283b2af to b7e5a11 Compare September 3, 2024 09:37
Comment on lines +14 to +17
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

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 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.

Suggested changeset 1
test/index.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/test/index.ts b/test/index.ts
--- a/test/index.ts
+++ b/test/index.ts
@@ -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",
EOF
@@ -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",
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Comment on lines +75 to +78
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

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 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.

Suggested changeset 1
test/index.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/test/index.ts b/test/index.ts
--- a/test/index.ts
+++ b/test/index.ts
@@ -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)
           }`,
EOF
@@ -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)
}`,
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
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