Skip to content

Commit 47ee224

Browse files
fix for code scanning alert no. 4: Insecure randomness (#396)
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent c16c8d5 commit 47ee224

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/app/_components/VersionDisplay.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,11 +416,20 @@ export function VersionDisplay({ onOpenReleaseNotes }: VersionDisplayProps = {})
416416
setShowUpdateConfirmation(true);
417417
};
418418

419+
// Helper to generate secure random string
420+
function getSecureRandomString(length: number): string {
421+
const array = new Uint8Array(length);
422+
window.crypto.getRandomValues(array);
423+
// Convert to base36 string (alphanumeric)
424+
return Array.from(array, b => b.toString(36)).join('').substr(0, length);
425+
}
426+
419427
const handleConfirmUpdate = () => {
420428
// Close the confirmation modal
421429
setShowUpdateConfirmation(false);
422430
// Start the actual update process
423-
const sessionId = `update_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
431+
const randomSuffix = getSecureRandomString(9);
432+
const sessionId = `update_${Date.now()}_${randomSuffix}`;
424433
const startTime = Date.now();
425434

426435
setIsUpdating(true);

0 commit comments

Comments
 (0)