File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,15 @@ interface ShellTerminalProps {
1111 cwd ?: string ;
1212}
1313
14+ // Generate a cryptographically secure random string
15+ function secureRandomString ( length : number ) : string {
16+ const array = new Uint8Array ( length ) ;
17+ window . crypto . getRandomValues ( array ) ;
18+ return Array . from ( array , ( byte ) => byte . toString ( 36 ) . padStart ( 2 , "0" ) )
19+ . join ( "" )
20+ . substring ( 0 , length ) ;
21+ }
22+
1423export function ShellTerminal ( { cwd } : ShellTerminalProps ) {
1524 const terminalRef = useRef < HTMLDivElement > ( null ) ;
1625 const terminal = useRef < Terminal | null > ( null ) ;
@@ -38,8 +47,8 @@ export function ShellTerminal({ cwd }: ShellTerminalProps) {
3847 useEffect ( ( ) => {
3948 if ( ! terminalRef . current ) return ;
4049
41- // Generate unique session ID for this effect run
42- const sessionId = `shell-${ Date . now ( ) } -${ Math . random ( ) . toString ( 36 ) . substring ( 7 ) } ` ;
50+ // Generate unique session ID for this effect run using cryptographically secure random
51+ const sessionId = `shell-${ Date . now ( ) } -${ secureRandomString ( 7 ) } ` ;
4352 sessionIdRef . current = sessionId ;
4453
4554 // Initialize terminal with same styling as task mode
You can’t perform that action at this time.
0 commit comments