mirror of
https://github.com/fosrl/pangolin.git
synced 2026-06-06 07:38:46 +00:00
Potential fix for pull request finding 'CodeQL / Insecure randomness'
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from "express";
|
||||||
|
import { randomInt } from "crypto";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import {
|
import {
|
||||||
actionAuditLog,
|
actionAuditLog,
|
||||||
@@ -392,7 +393,7 @@ export async function signSshKey(
|
|||||||
if (existingUserWithSameName) {
|
if (existingUserWithSameName) {
|
||||||
let foundUniqueUsername = false;
|
let foundUniqueUsername = false;
|
||||||
for (let attempt = 0; attempt < 20; attempt++) {
|
for (let attempt = 0; attempt < 20; attempt++) {
|
||||||
const randomNum = Math.floor(Math.random() * 101); // 0 to 100
|
const randomNum = randomInt(0, 101); // 0 to 100
|
||||||
const candidateUsername = `${usernameToUse}${randomNum}`;
|
const candidateUsername = `${usernameToUse}${randomNum}`;
|
||||||
|
|
||||||
const [existingUser] = await db
|
const [existingUser] = await db
|
||||||
|
|||||||
Reference in New Issue
Block a user