detect-pseudoRandomBytes.js 702 B

123456789101112131415161718192021222324
  1. /**
  2. * Tries to detect crypto.pseudoRandomBytes cause it's not cryptographical strong
  3. * @author Adam Baldwin
  4. */
  5. //------------------------------------------------------------------------------
  6. // Rule Definition
  7. //------------------------------------------------------------------------------
  8. module.exports = function(context) {
  9. "use strict";
  10. return {
  11. "MemberExpression": function (node) {
  12. if (node.property.name === 'pseudoRandomBytes') {
  13. var token = context.getTokens(node)[0];
  14. return context.report(node, 'Found crypto.pseudoRandomBytes which does not produce cryptographically strong numbers');
  15. }
  16. }
  17. };
  18. };