Skip to content

Commit a43543f

Browse files
committed
codeql
1 parent 0d8d5e8 commit a43543f

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

apps/array/src/shared/utils/id.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { randomBytes } from "node:crypto";
2+
13
export function randomSuffix(length = 8): string {
2-
return Math.random()
3-
.toString(36)
4-
.substring(2, 2 + length);
4+
return randomBytes(length).toString("hex").substring(0, length);
55
}
66

77
export function generateId(prefix: string, length = 8): string {

packages/agent/src/adapters/claude/mcp-server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { randomBytes } from "node:crypto";
12
import type {
23
ClientCapabilities,
34
TerminalOutputResponse,
@@ -719,7 +720,7 @@ export function replaceAndCalculateLocation(
719720
let currentContent = fileContent;
720721

721722
// Use unique markers to track where replacements happen
722-
const markerPrefix = `__REPLACE_MARKER_${Math.random().toString(36).substr(2, 9)}_`;
723+
const markerPrefix = `__REPLACE_MARKER_${randomBytes(5).toString("hex")}_`;
723724
let markerCounter = 0;
724725
const markers: string[] = [];
725726

packages/agent/src/worktree-manager.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { exec, execFile } from "node:child_process";
2+
import * as crypto from "node:crypto";
23
import * as fs from "node:fs/promises";
34
import * as path from "node:path";
45
import { promisify } from "node:util";
@@ -523,7 +524,7 @@ export class WorktreeManager {
523524
}
524525

525526
private randomElement<T>(array: T[]): T {
526-
return array[Math.floor(Math.random() * array.length)];
527+
return array[crypto.randomInt(array.length)];
527528
}
528529

529530
generateWorktreeName(): string {

0 commit comments

Comments
 (0)