-
Notifications
You must be signed in to change notification settings - Fork 79
Lee at zoo corp/ttc ux 1 #7542
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: main
Are you sure you want to change the base?
Lee at zoo corp/ttc ux 1 #7542
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
status: 'completed', | ||
updated_at: Math.random(), | ||
// declare type ApiTokenUuid_type = string; | ||
user_id: Math.random().toString(), |
Check failure
Code scanning / CodeQL
Insecure randomness High
Math.random()
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 13 days ago
To fix the issue, replace all instances of Math.random()
with a cryptographically secure random number generator. In Node.js, the crypto
module provides a secure method for generating random values. Specifically, crypto.randomUUID()
can be used to generate secure UUIDs, and crypto.randomBytes()
can be used to generate random bytes for other purposes.
For this fix:
- Import the
crypto
module from Node.js. - Replace
Math.random().toString()
withcrypto.randomUUID()
where a unique identifier is needed. - Replace other uses of
Math.random()
with appropriate secure alternatives, such as generating random bytes and converting them to the desired format.
-
Copy modified line R2 -
Copy modified lines R99-R102 -
Copy modified lines R105-R107 -
Copy modified line R113 -
Copy modified lines R115-R116 -
Copy modified line R119 -
Copy modified line R121
@@ -1,2 +1,3 @@ | ||
import type { Models } from '@kittycad/lib' | ||
import * as crypto from 'crypto'; | ||
|
||
@@ -97,11 +98,11 @@ | ||
export const generateFakeSubmittedPrompt = () => ({ | ||
code: Math.random().toString(), | ||
completed_at: Math.random().toString(), | ||
created_at: new Date(Math.random() * 100000000).toISOString(), | ||
error: Math.random().toString(), | ||
code: crypto.randomUUID(), | ||
completed_at: crypto.randomUUID(), | ||
created_at: new Date(crypto.randomBytes(4).readUInt32BE(0) % 100000000).toISOString(), | ||
error: crypto.randomUUID(), | ||
// declare type MlFeedback_type = 'thumbs_up' | 'thumbs_down' | 'accepted' | 'rejected'; | ||
feedback: 'thumbs_up' as Prompt['feedback'], | ||
id: Math.random().toString(), | ||
kcl_version: Math.random().toString(), | ||
model_version: Math.random().toString(), | ||
id: crypto.randomUUID(), | ||
kcl_version: crypto.randomUUID(), | ||
model_version: crypto.randomUUID(), | ||
// export declare type TextToCadModel_type = 'cad' | 'kcl' | 'kcl_iteration'; model : 'kcl', | ||
@@ -111,11 +112,11 @@ | ||
outputs: { | ||
[Math.random().toString()]: Math.random().toString(), | ||
[crypto.randomUUID()]: crypto.randomUUID(), | ||
}, | ||
prompt: PROMPTS[parseInt((Math.random() * 10).toString()[0])], | ||
started_at: new Date(Math.random()).toISOString(), | ||
prompt: PROMPTS[crypto.randomBytes(1)[0] % PROMPTS.length], | ||
started_at: new Date(crypto.randomBytes(4).readUInt32BE(0)).toISOString(), | ||
// declare type ApiCallStatus_type = 'queued' | 'uploaded' | 'in_progress' | 'completed' | 'failed'; | ||
status: 'completed' as Prompt['status'], | ||
updated_at: Math.random().toString(), | ||
updated_at: crypto.randomUUID(), | ||
// declare type ApiTokenUuid_type = string; | ||
user_id: Math.random().toString(), | ||
user_id: crypto.randomUUID(), | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How the fuck do I delete you
c0c5e7b
to
4a46a24
Compare
No description provided.