Skip to content

Commit 95d8b2c

Browse files
Fix insecure randomness
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 90d0ca3 commit 95d8b2c

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • backend/src/server/routes

backend/src/server/routes/ide.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { q } from '../../database'
22
import { addHSGMemory, hsgQuery } from '../../hsg'
33
import { j, p } from '../../utils'
4-
4+
import * as crypto from 'crypto';
55
export function ide(app: any) {
66
app.post('/api/ide/events', async (req: any, res: any) => {
77
try {
@@ -101,7 +101,7 @@ export function ide(app: any) {
101101
const project_name = req.body.project_name || 'unknown'
102102
const ide_name = req.body.ide_name || 'unknown'
103103

104-
const session_id = `session_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`
104+
const session_id = `session_${Date.now()}_${crypto.randomBytes(7).toString('hex')}`
105105
const now_ts = Date.now()
106106

107107
const content = `Session started: ${user_id} in ${project_name} using ${ide_name}`

0 commit comments

Comments
 (0)