Skip to content

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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft

Conversation

lee-at-zoo-corp
Copy link
Contributor

No description provided.

Copy link

vercel bot commented Jun 19, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
modeling-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 20, 2025 8:50pm

status: 'completed',
updated_at: Math.random(),
// declare type ApiTokenUuid_type = string;
user_id: Math.random().toString(),

Check failure

Code scanning / CodeQL

Insecure randomness High

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

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:

  1. Import the crypto module from Node.js.
  2. Replace Math.random().toString() with crypto.randomUUID() where a unique identifier is needed.
  3. Replace other uses of Math.random() with appropriate secure alternatives, such as generating random bytes and converting them to the desired format.

Suggested changeset 1
src/lib/prompt.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/src/lib/prompt.ts b/src/lib/prompt.ts
--- a/src/lib/prompt.ts
+++ b/src/lib/prompt.ts
@@ -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(),
 })
EOF
@@ -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(),
})
Copilot is powered by AI and may make mistakes. Always verify output.
Copy link
Contributor Author

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

@lee-at-zoo-corp lee-at-zoo-corp force-pushed the lee-at-zoo-corp/ttc-ux-1 branch 2 times, most recently from c0c5e7b to 4a46a24 Compare June 19, 2025 19:46
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