Skip to content

Commit b156ef5

Browse files
Potential fix for code scanning alert no. 209: Insecure randomness
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent c83ed6e commit b156ef5

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

samples/grids/grid-lite/styling-config-themes/src/GridLiteDataService.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ export class GridLiteDataService {
3838
private priorities: ('Low' | 'Standard' | 'High')[] = ['Low', 'Standard', 'High'];
3939

4040
private randomInt(min: number, max: number): number {
41-
return Math.floor(Math.random() * (max - min + 1)) + min;
41+
const array = new Uint32Array(1);
42+
window.crypto.getRandomValues(array);
43+
const random01 = array[0] / 2 ** 32;
44+
return Math.floor(random01 * (max - min + 1)) + min;
4245
}
4346

4447
private randomFloat(min: number, max: number, precision = 2): number {

0 commit comments

Comments
 (0)