mirror of
https://github.com/desktop/desktop
synced 2024-10-31 05:19:03 +00:00
39 lines
899 B
JavaScript
39 lines
899 B
JavaScript
// @ts-check
|
|
|
|
const RuleTester = require('eslint').RuleTester
|
|
const rule = require('../insecure-random')
|
|
|
|
const parserOptions = {
|
|
ecmaVersion: 2015,
|
|
sourceType: 'module',
|
|
}
|
|
|
|
const ruleTester = new RuleTester({ parserOptions })
|
|
ruleTester.run('react-no-unbound-dispatcher-props', rule, {
|
|
valid: [
|
|
'const b = crypto.randomBytes();',
|
|
'const b = window.crypto.getRandomValues();',
|
|
],
|
|
invalid: [
|
|
{
|
|
code: 'const b = Math.random();',
|
|
errors: [{ messageId: 'mathRandomInsecure' }],
|
|
},
|
|
{
|
|
code: `
|
|
const crypto = require('crypto');
|
|
|
|
const b = crypto.pseudoRandomBytes();`,
|
|
errors: [{ messageId: 'pseudoRandomBytesInsecure' }],
|
|
},
|
|
{
|
|
code: `
|
|
const { pseudoRandomBytes } = require('crypto');
|
|
|
|
const b = pseudoRandomBytes();
|
|
|
|
`,
|
|
errors: [{ messageId: 'pseudoRandomBytesInsecure' }],
|
|
},
|
|
],
|
|
})
|