Fixes #848 - Use more secure PRNG

Math.random() is not cryptogaphically secure, but the crypto-random-string
package provides what is needed with a cryptographically secure pseudo-random
number generator.
This commit is contained in:
Brian Mearns
2019-10-01 21:29:42 -04:00
parent 4f29f7c3a7
commit 054901cb79
3 changed files with 18834 additions and 10 deletions

View File

@@ -1,4 +1,5 @@
import _ from 'lodash';
import randomString from 'crypto-random-string';
import { logger } from '../../logger';
@@ -9,17 +10,11 @@ let curBranch = 'master';
let direction = 'LR';
let seq = 0;
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
function getId() {
const pool = '0123456789abcdef';
let id = '';
for (let i = 0; i < 7; i++) {
id += pool[getRandomInt(0, 16)];
}
return id;
return randomString({
length: 7,
characters: '0123456789abcdef'
});
}
function isfastforwardable(currentCommit, otherCommit) {