From 19614b7804fece3a022b9986c0301207aa04d31b Mon Sep 17 00:00:00 2001 From: otdoges Date: Mon, 21 Jul 2025 20:19:51 -0500 Subject: [PATCH] Potential fix for code scanning alert no. 51: Insecure randomness Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- src/lib/e2b-service.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/e2b-service.ts b/src/lib/e2b-service.ts index 4861e2f9..4746bec1 100644 --- a/src/lib/e2b-service.ts +++ b/src/lib/e2b-service.ts @@ -1,3 +1,4 @@ +import * as crypto from 'crypto'; import { Sandbox } from '@e2b/code-interpreter'; export interface ExecutionResult { @@ -151,7 +152,7 @@ class E2BService { const now = new Date(); const session: SandboxSession = { - id: `session_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`, + id: `session_${Date.now()}_${crypto.randomBytes(9).toString('hex')}`, sandbox, createdAt: now, lastUsed: now,