-
-
Notifications
You must be signed in to change notification settings - Fork 106
/
Copy pathdetect-pseudoRandomBytes.js
31 lines (28 loc) · 1 KB
/
detect-pseudoRandomBytes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* Tries to detect crypto.pseudoRandomBytes cause it's not cryptographical strong
* @author Adam Baldwin
*/
'use strict';
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
module.exports = {
meta: {
type: 'error',
docs: {
description: 'Detects if "pseudoRandomBytes()" is in use, which might not give you the randomness you need and expect.',
category: 'Possible Security Vulnerability',
recommended: true,
url: 'https://github.com/eslint-community/eslint-plugin-security/blob/main/docs/rules/detect-pseudoRandomBytes.md',
},
},
create(context) {
return {
MemberExpression: function (node) {
if (node.property.name === 'pseudoRandomBytes') {
return context.report({ node: node, message: 'Found crypto.pseudoRandomBytes which does not produce cryptographically strong numbers' });
}
},
};
},
};