mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-13 12:29:42 +02:00
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:
18828
package-lock.json
generated
Normal file
18828
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -47,6 +47,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@braintree/sanitize-url": "^3.1.0",
|
"@braintree/sanitize-url": "^3.1.0",
|
||||||
|
"crypto-random-string": "^3.0.1",
|
||||||
"d3": "^5.7.0",
|
"d3": "^5.7.0",
|
||||||
"dagre-d3-renderer": "^0.5.8",
|
"dagre-d3-renderer": "^0.5.8",
|
||||||
"dagre-layout": "^0.8.8",
|
"dagre-layout": "^0.8.8",
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import randomString from 'crypto-random-string';
|
||||||
|
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
|
|
||||||
@@ -9,17 +10,11 @@ let curBranch = 'master';
|
|||||||
let direction = 'LR';
|
let direction = 'LR';
|
||||||
let seq = 0;
|
let seq = 0;
|
||||||
|
|
||||||
function getRandomInt(min, max) {
|
|
||||||
return Math.floor(Math.random() * (max - min)) + min;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getId() {
|
function getId() {
|
||||||
const pool = '0123456789abcdef';
|
return randomString({
|
||||||
let id = '';
|
length: 7,
|
||||||
for (let i = 0; i < 7; i++) {
|
characters: '0123456789abcdef'
|
||||||
id += pool[getRandomInt(0, 16)];
|
});
|
||||||
}
|
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isfastforwardable(currentCommit, otherCommit) {
|
function isfastforwardable(currentCommit, otherCommit) {
|
||||||
|
Reference in New Issue
Block a user