eslint-plugin-security 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/.eslintrc +11 -1
  2. package/.github/workflows/ci.yml +47 -0
  3. package/.github/workflows/pr.yml +15 -0
  4. package/.prettierrc.json +7 -0
  5. package/CHANGELOG.md +65 -34
  6. package/README.md +26 -24
  7. package/docs/avoid-command-injection-node.md +85 -0
  8. package/docs/bypass-connect-csrf-protection-by-abusing.md +42 -0
  9. package/docs/regular-expression-dos-and-node.md +83 -0
  10. package/docs/the-dangers-of-square-bracket-notation.md +107 -0
  11. package/index.js +1 -3
  12. package/package.json +26 -7
  13. package/rules/data/fsFunctionData.json +49 -49
  14. package/rules/detect-buffer-noassert.js +66 -55
  15. package/rules/detect-child-process.js +36 -27
  16. package/rules/detect-disable-mustache-escape.js +24 -14
  17. package/rules/detect-eval-with-expression.js +19 -9
  18. package/rules/detect-new-buffer.js +18 -15
  19. package/rules/detect-no-csrf-before-method-override.js +32 -25
  20. package/rules/detect-non-literal-fs-filename.js +38 -33
  21. package/rules/detect-non-literal-regexp.js +24 -18
  22. package/rules/detect-non-literal-require.js +25 -17
  23. package/rules/detect-object-injection.js +61 -59
  24. package/rules/detect-possible-timing-attacks.js +40 -42
  25. package/rules/detect-pseudoRandomBytes.js +18 -11
  26. package/rules/detect-unsafe-regex.js +36 -23
  27. package/test/detect-buffer-noassert.js +18 -18
  28. package/test/detect-child-process.js +14 -24
  29. package/test/detect-disable-mustache-escape.js +0 -1
  30. package/test/detect-eval-with-expression.js +0 -1
  31. package/test/detect-new-buffer.js +0 -1
  32. package/test/detect-no-csrf-before-method-override.js +0 -1
  33. package/test/detect-non-literal-fs-filename.js +0 -1
  34. package/test/detect-non-literal-regexp.js +0 -1
  35. package/test/detect-non-literal-require.js +8 -5
  36. package/test/detect-object-injection.js +0 -2
  37. package/test/detect-possible-timing-attacks.js +0 -2
  38. package/test/detect-pseudoRandomBytes.js +0 -1
  39. package/test/detect-unsafe-regexp.js +2 -4
  40. package/.npmignore +0 -1
@@ -3,26 +3,32 @@
3
3
  * @author Jon Lamendola
4
4
  */
5
5
 
6
+ 'use strict';
7
+
6
8
  //------------------------------------------------------------------------------
7
9
  // Rule Definition
8
10
  //------------------------------------------------------------------------------
9
11
 
10
-
11
- module.exports = function(context) {
12
-
13
- "use strict";
14
-
15
- return {
16
- "NewExpression": function(node) {
17
- if (node.callee.name === 'RegExp') {
18
- var args = node.arguments;
19
- if (args && args.length > 0 && args[0].type !== 'Literal') {
20
- var token = context.getTokens(node)[0];
21
- return context.report(node, 'Found non-literal argument to RegExp Constructor');
22
- }
23
- }
24
-
25
- }
26
-
12
+ module.exports = {
13
+ meta: {
14
+ type: 'error',
15
+ docs: {
16
+ description: 'Detects "RegExp(variable)", which might allow an attacker to DOS your server with a long-running regular expression.',
17
+ category: 'Possible Security Vulnerability',
18
+ recommended: true,
19
+ url: 'https://github.com/nodesecurity/eslint-plugin-security/blob/main/docs/regular-expression-dos-and-node.md',
20
+ },
21
+ },
22
+ create: function (context) {
23
+ return {
24
+ NewExpression: function (node) {
25
+ if (node.callee.name === 'RegExp') {
26
+ const args = node.arguments;
27
+ if (args && args.length > 0 && args[0].type !== 'Literal') {
28
+ return context.report(node, 'Found non-literal argument to RegExp Constructor');
29
+ }
27
30
  }
28
- }
31
+ },
32
+ };
33
+ },
34
+ };
@@ -1,29 +1,37 @@
1
1
  /**
2
2
  * Tries to detect calls to require with non-literal argument
3
- * @author Adam Baldwin
3
+ * @author Adam Baldwin
4
4
  */
5
5
 
6
+ 'use strict';
7
+
6
8
  //------------------------------------------------------------------------------
7
9
  // Rule Definition
8
10
  //------------------------------------------------------------------------------
9
11
 
10
- module.exports = function(context) {
11
-
12
- "use strict";
13
-
12
+ module.exports = {
13
+ meta: {
14
+ type: 'error',
15
+ docs: {
16
+ description: 'Detects "require(variable)", which might allow an attacker to load and run arbitrary code, or access arbitrary files on disk. ',
17
+ category: 'Possible Security Vulnerability',
18
+ recommended: true,
19
+ url: 'https://github.com/nodesecurity/eslint-plugin-security#detect-non-literal-require',
20
+ },
21
+ },
22
+ create: function (context) {
14
23
  return {
15
- "CallExpression": function (node) {
16
- if (node.callee.name === 'require') {
17
- var args = node.arguments;
18
- if (args && args.length > 0 && args[0].type !== 'Literal') {
19
- var token = context.getTokens(node)[0];
20
- return context.report(node, 'Found non-literal argument in require');
21
- }
22
- }
23
-
24
+ CallExpression: function (node) {
25
+ if (node.callee.name === 'require') {
26
+ const args = node.arguments;
27
+ if (
28
+ (args && args.length > 0 && args[0].type === 'TemplateLiteral' && args[0].expressions.length > 0) ||
29
+ (args[0].type !== 'TemplateLiteral' && args[0].type !== 'Literal')
30
+ ) {
31
+ return context.report(node, 'Found non-literal argument in require');
32
+ }
24
33
  }
25
-
34
+ },
26
35
  };
27
-
36
+ },
28
37
  };
29
-
@@ -3,77 +3,79 @@
3
3
  * @author Jon Lamendola
4
4
  */
5
5
 
6
+ 'use strict';
7
+
6
8
  //------------------------------------------------------------------------------
7
9
  // Rule Definition
8
10
  //------------------------------------------------------------------------------
9
11
 
10
- var Sinks = [];
11
- function getSerialize (fn, decycle) {
12
- var seen = [], keys = [];
13
- decycle = decycle || function(key, value) {
14
- return '[Circular ' + getPath(value, seen, keys) + ']'
15
- };
16
- return function(key, value) {
17
- var ret = value;
12
+ const getPath = (value, seen, keys) => {
13
+ let index = seen.indexOf(value);
14
+ const path = [keys[index]];
15
+ for (index--; index >= 0; index--) {
16
+ if (seen[index][path[0]] === value) {
17
+ value = seen[index];
18
+ path.unshift(keys[index]);
19
+ }
20
+ }
21
+ return `~${path.join('.')}`;
22
+ };
23
+
24
+ const getSerialize = (fn, decycle) => {
25
+ const seen = [];
26
+ const keys = [];
27
+ decycle =
28
+ decycle ||
29
+ function (key, value) {
30
+ return `[Circular ${getPath(value, seen, keys)}]`;
31
+ };
32
+ return function (key, value) {
33
+ let ret = value;
18
34
  if (typeof value === 'object' && value) {
19
- if (seen.indexOf(value) !== -1)
35
+ if (seen.indexOf(value) !== -1) {
20
36
  ret = decycle(key, value);
21
- else {
37
+ } else {
22
38
  seen.push(value);
23
39
  keys.push(key);
24
40
  }
25
41
  }
26
- if (fn) ret = fn(key, ret);
27
- return ret;
28
- }
29
- }
30
-
31
- function getPath (value, seen, keys) {
32
- var index = seen.indexOf(value);
33
- var path = [ keys[index] ];
34
- for (index--; index >= 0; index--) {
35
- if (seen[index][ path[0] ] === value) {
36
- value = seen[index];
37
- path.unshift(keys[index]);
42
+ if (fn) {
43
+ ret = fn(key, ret);
38
44
  }
39
- }
40
- return '~' + path.join('.');
41
- }
45
+ return ret;
46
+ };
47
+ };
42
48
 
43
- function stringify(obj, fn, spaces, decycle) {
49
+ const stringify = (obj, fn, spaces, decycle) => {
44
50
  return JSON.stringify(obj, getSerialize(fn, decycle), spaces);
45
- }
46
-
47
- stringify.getSerialize = getSerialize;module.exports = function(context) {
48
-
49
- "use strict";
50
-
51
- var isChanged = false;
52
-
53
-
54
-
55
- return {
56
- "MemberExpression": function(node) {
57
-
58
- if (node.computed === true) {
59
- var token = context.getTokens(node)[0];
60
- if (node.property.type === 'Identifier') {
61
- if (node.parent.type === 'VariableDeclarator') {
62
- context.report(node, 'Variable Assigned to Object Injection Sink');
63
-
64
- } else if (node.parent.type === 'CallExpression') {
65
- // console.log(node.parent)
66
- context.report(node, 'Function Call Object Injection Sink');
67
- } else {
68
- context.report(node, 'Generic Object Injection Sink');
69
-
70
- }
71
-
72
- }
73
- }
51
+ };
74
52
 
53
+ stringify.getSerialize = getSerialize;
54
+ module.exports = {
55
+ meta: {
56
+ type: 'error',
57
+ docs: {
58
+ description: 'Detects "variable[key]" as a left- or right-hand assignment operand.',
59
+ category: 'Possible Security Vulnerability',
60
+ recommended: true,
61
+ url: 'https://github.com/nodesecurity/eslint-plugin-security/blob/main/docs/the-dangers-of-square-bracket-notation.md',
62
+ },
63
+ },
64
+ create: function (context) {
65
+ return {
66
+ MemberExpression: function (node) {
67
+ if (node.computed === true) {
68
+ if (node.property.type === 'Identifier') {
69
+ if (node.parent.type === 'VariableDeclarator') {
70
+ context.report(node, 'Variable Assigned to Object Injection Sink');
71
+ } else if (node.parent.type === 'CallExpression') {
72
+ context.report(node, 'Function Call Object Injection Sink');
73
+ } else {
74
+ context.report(node, 'Generic Object Injection Sink');
75
75
  }
76
-
77
- };
78
- }
79
-
76
+ }
77
+ }
78
+ },
79
+ };
80
+ },
81
+ };
@@ -3,58 +3,56 @@
3
3
  * @author Adam Baldwin / Jon Lamendola
4
4
  */
5
5
 
6
+ 'use strict';
7
+
6
8
  //------------------------------------------------------------------------------
7
9
  // Rule Definition
8
10
  //------------------------------------------------------------------------------
9
11
 
10
- var keywords = '((' + [
11
- 'password',
12
- 'secret',
13
- 'api',
14
- 'apiKey',
15
- 'token',
16
- 'auth',
17
- 'pass',
18
- 'hash'
19
- ].join(')|(') + '))';
20
-
21
- var re = new RegExp('^' + keywords + '$', 'im');
12
+ const keywords = `((${['password', 'secret', 'api', 'apiKey', 'token', 'auth', 'pass', 'hash'].join(')|(')}))`;
22
13
 
23
- function containsKeyword (node) {
24
- if (node.type === 'Identifier') {
25
- if (re.test(node.name))
26
- return true;
27
- }
28
- return
29
- }
14
+ const re = new RegExp(`^${keywords}$`, 'im');
30
15
 
31
- module.exports = function(context) {
32
-
33
- "use strict";
16
+ const containsKeyword = (node) => {
17
+ if (node.type === 'Identifier') {
18
+ if (re.test(node.name)) {
19
+ return true;
20
+ }
21
+ }
22
+ return;
23
+ };
34
24
 
25
+ module.exports = {
26
+ meta: {
27
+ type: 'error',
28
+ docs: {
29
+ description: 'Detects insecure comparisons (`==`, `!=`, `!==` and `===`), which check input sequentially.',
30
+ category: 'Possible Security Vulnerability',
31
+ recommended: true,
32
+ url: 'https://github.com/nodesecurity/eslint-plugin-security#detect-possible-timing-attacks'
33
+ }
34
+ },
35
+ create: function (context) {
35
36
  return {
36
- "IfStatement": function(node) {
37
- if (node.test && node.test.type === 'BinaryExpression') {
38
- if (node.test.operator === '==' || node.test.operator === '===' || node.test.operator === '!=' || node.test.operator === '!==') {
39
-
40
- var token = context.getTokens(node)[0];
41
-
42
- if (node.test.left) {
43
- var left = containsKeyword(node.test.left);
44
- if (left) {
45
- return context.report(node, "Potential timing attack, left side: " + left);
46
- }
47
- }
37
+ IfStatement: function (node) {
38
+ if (node.test && node.test.type === 'BinaryExpression') {
39
+ if (node.test.operator === '==' || node.test.operator === '===' || node.test.operator === '!=' || node.test.operator === '!==') {
40
+ if (node.test.left) {
41
+ const left = containsKeyword(node.test.left);
42
+ if (left) {
43
+ return context.report(node, `Potential timing attack, left side: ${left}`);
44
+ }
45
+ }
48
46
 
49
- if (node.test.right) {
50
- var right = containsKeyword(node.test.right);
51
- if (right) {
52
- return context.report(node, "Potential timing attack, right side: " + right);
53
- }
54
- }
55
- }
47
+ if (node.test.right) {
48
+ const right = containsKeyword(node.test.right);
49
+ if (right) {
50
+ return context.report(node, `Potential timing attack, right side: ${right}`);
51
+ }
56
52
  }
53
+ }
57
54
  }
55
+ }
58
56
  };
59
-
57
+ }
60
58
  };
@@ -3,22 +3,29 @@
3
3
  * @author Adam Baldwin
4
4
  */
5
5
 
6
+ 'use strict';
7
+
6
8
  //------------------------------------------------------------------------------
7
9
  // Rule Definition
8
10
  //------------------------------------------------------------------------------
9
11
 
10
- module.exports = function(context) {
11
-
12
- "use strict";
13
-
12
+ module.exports = {
13
+ meta: {
14
+ type: 'error',
15
+ docs: {
16
+ description: 'Detects if "pseudoRandomBytes()" is in use, which might not give you the randomness you need and expect.',
17
+ category: 'Possible Security Vulnerability',
18
+ recommended: true,
19
+ url: 'https://github.com/nodesecurity/eslint-plugin-security#detect-pseudorandombytes',
20
+ },
21
+ },
22
+ create: function (context) {
14
23
  return {
15
- "MemberExpression": function (node) {
16
- if (node.property.name === 'pseudoRandomBytes') {
17
- var token = context.getTokens(node)[0];
18
- return context.report(node, 'Found crypto.pseudoRandomBytes which does not produce cryptographically strong numbers');
19
- }
24
+ MemberExpression: function (node) {
25
+ if (node.property.name === 'pseudoRandomBytes') {
26
+ return context.report(node, 'Found crypto.pseudoRandomBytes which does not produce cryptographically strong numbers');
20
27
  }
21
-
28
+ },
22
29
  };
23
-
30
+ },
24
31
  };
@@ -1,37 +1,50 @@
1
- var safe = require('safe-regex');
2
1
  /**
3
2
  * Check if the regex is evil or not using the safe-regex module
4
3
  * @author Adam Baldwin
5
4
  */
6
5
 
6
+ 'use strict';
7
+
8
+ //-----------------------------------------------------------------------------
9
+ // Requirements
10
+ //-----------------------------------------------------------------------------
11
+
12
+ const safe = require('safe-regex');
13
+
7
14
  //------------------------------------------------------------------------------
8
15
  // Rule Definition
9
16
  //------------------------------------------------------------------------------
10
17
 
11
- module.exports = function(context) {
12
-
13
- "use strict";
14
-
18
+ module.exports = {
19
+ meta: {
20
+ type: 'error',
21
+ docs: {
22
+ description: 'Locates potentially unsafe regular expressions, which may take a very long time to run, blocking the event loop.',
23
+ category: 'Possible Security Vulnerability',
24
+ recommended: true,
25
+ url: 'https://github.com/nodesecurity/eslint-plugin-security/blob/main/docs/regular-expression-dos-and-node.md'
26
+ }
27
+ },
28
+ create: function (context) {
15
29
  return {
16
- "Literal": function(node) {
17
- var token = context.getTokens(node)[0],
18
- nodeType = token.type,
19
- nodeValue = token.value;
30
+ Literal: function (node) {
31
+ const token = context.getTokens(node)[0];
32
+ const nodeType = token.type;
33
+ const nodeValue = token.value;
20
34
 
21
- if (nodeType === "RegularExpression") {
22
- if (!safe(nodeValue)) {
23
- context.report(node, "Unsafe Regular Expression");
24
- }
25
- }
26
- },
27
- "NewExpression": function(node) {
28
- if (node.callee.name == "RegExp" && node.arguments && node.arguments.length > 0 && node.arguments[0].type == "Literal") {
29
- if (!safe(node.arguments[0].value)) {
30
- context.report(node, "Unsafe Regular Expression (new RegExp)");
31
- }
32
- }
35
+ if (nodeType === 'RegularExpression') {
36
+ if (!safe(nodeValue)) {
37
+ context.report(node, 'Unsafe Regular Expression');
38
+ }
39
+ }
40
+ },
41
+ NewExpression: function (node) {
42
+ if (node.callee.name === 'RegExp' && node.arguments && node.arguments.length > 0 && node.arguments[0].type === 'Literal') {
43
+ if (!safe(node.arguments[0].value)) {
44
+ context.report(node, 'Unsafe Regular Expression (new RegExp)');
45
+ }
33
46
  }
47
+ }
34
48
  };
35
-
49
+ }
36
50
  };
37
-
@@ -4,27 +4,27 @@ const RuleTester = require('eslint').RuleTester;
4
4
  const tester = new RuleTester();
5
5
 
6
6
  const ruleName = 'detect-buffer-noassert';
7
- const Rule = require(`../rules/${ruleName}`);
7
+ const rule = require(`../rules/${ruleName}`);
8
8
 
9
- const invalid = 'a.readUInt8(0, true);';
9
+ const allMethodNames = [...rule.meta.__methodsToCheck.read, ...rule.meta.__methodsToCheck.write];
10
10
 
11
-
12
- tester.run(ruleName, Rule, {
13
- valid: [{ code: 'a.readUInt8(0);' }],
11
+ tester.run(ruleName, rule, {
12
+ valid: [...allMethodNames.map((methodName) => `a.${methodName}(0)`), ...allMethodNames.map((methodName) => `a.${methodName}(0, false)`)],
14
13
  invalid: [
15
- {
16
- code: invalid,
17
- errors: [{ message: 'Found Buffer.readUInt8 with noAssert flag set true' }]
18
- }
19
- ]
20
- });
14
+ ...rule.meta.__methodsToCheck.read.map((methodName) => ({
15
+ code: `a.${methodName}(0, true)`,
16
+ errors: [{ message: `Found Buffer.${methodName} with noAssert flag set true` }],
17
+ })),
21
18
 
22
- tester.run(`${ruleName} (false)`, Rule, {
23
- valid: [{ code: 'a.readUInt8(0, false);' }],
24
- invalid: [
19
+ ...rule.meta.__methodsToCheck.write.map((methodName) => ({
20
+ code: `a.${methodName}(0, 0, true)`,
21
+ errors: [{ message: `Found Buffer.${methodName} with noAssert flag set true` }],
22
+ })),
23
+
24
+ // hard-coded test to ensure #63 is fixed
25
25
  {
26
- code: invalid,
27
- errors: [{ message: 'Found Buffer.readUInt8 with noAssert flag set true' }]
28
- }
29
- ]
26
+ code: 'a.readDoubleLE(0, true);',
27
+ errors: [{ message: 'Found Buffer.readDoubleLE with noAssert flag set true' }],
28
+ },
29
+ ],
30
30
  });
@@ -4,32 +4,22 @@ const RuleTester = require('eslint').RuleTester;
4
4
  const tester = new RuleTester();
5
5
 
6
6
  const ruleName = 'detect-child-process';
7
- const Rule = require(`../rules/${ruleName}`);
7
+ const rule = require(`../rules/${ruleName}`);
8
8
 
9
- const valid = 'child_process.exec(\'ls\')';
10
- const invalidRequire = 'require(\'child_process\')';
11
- const invalidExec = 'var child = require(\'child_process\'); child.exec(com)';
12
-
13
-
14
- tester.run(`${ruleName} (require("child_process"))`, Rule, {
15
- valid: [{ code: valid }],
9
+ tester.run(ruleName, rule, {
10
+ valid: ["child_process.exec('ls')"],
16
11
  invalid: [
17
12
  {
18
- code: invalidRequire,
19
- errors: [{ message: 'Found require("child_process")' }]
20
- }
21
- ]
22
- });
23
-
24
-
25
- tester.run(`${ruleName} (child_process.exec() wih non literal 1st arg.)`, Rule, {
26
- valid: [{ code: valid }],
27
- invalid: [
13
+ code: "require('child_process')",
14
+ errors: [{ message: 'Found require("child_process")' }],
15
+ },
16
+ {
17
+ code: "var child = require('child_process'); child.exec(com)",
18
+ errors: [{ message: 'Found require("child_process")' }, { message: 'Found child_process.exec() with non Literal first argument' }],
19
+ },
28
20
  {
29
- code: invalidExec,
30
- errors: [
31
- { message: 'Found require("child_process")' },
32
- { message: 'Found child_process.exec() with non Literal first argument' }]
33
- }
34
- ]
21
+ code: "var child = require('child_process'); child.exec()",
22
+ errors: [{ message: 'Found require("child_process")' }],
23
+ },
24
+ ],
35
25
  });
@@ -5,7 +5,6 @@ const tester = new RuleTester();
5
5
 
6
6
  const ruleName = 'detect-disable-mustache-escape';
7
7
 
8
-
9
8
  tester.run(ruleName, require(`../rules/${ruleName}`), {
10
9
  valid: [{ code: 'escapeMarkup = false' }],
11
10
  invalid: [
@@ -5,7 +5,6 @@ const tester = new RuleTester();
5
5
 
6
6
  const ruleName = 'detect-eval-with-expression';
7
7
 
8
-
9
8
  tester.run(ruleName, require(`../rules/${ruleName}`), {
10
9
  valid: [{ code: 'eval(\'alert()\')' }],
11
10
  invalid: [
@@ -6,7 +6,6 @@ const tester = new RuleTester();
6
6
  const ruleName = 'detect-new-buffer';
7
7
  const invalid = 'var a = new Buffer(c)';
8
8
 
9
-
10
9
  tester.run(ruleName, require(`../rules/${ruleName}`), {
11
10
  valid: [{ code: 'var a = new Buffer(\'test\')' }],
12
11
  invalid: [
@@ -5,7 +5,6 @@ const tester = new RuleTester();
5
5
 
6
6
  const ruleName = 'detect-no-csrf-before-method-override';
7
7
 
8
-
9
8
  tester.run(ruleName, require(`../rules/${ruleName}`), {
10
9
  valid: [{ code: 'express.methodOverride();express.csrf()' }],
11
10
  invalid: [
@@ -7,7 +7,6 @@ const invalid = 'var a = fs.open(c)';
7
7
 
8
8
  const ruleName = 'detect-non-literal-fs-filename';
9
9
 
10
-
11
10
  tester.run(ruleName, require(`../rules/${ruleName}`), {
12
11
  valid: [{ code: 'var a = fs.open(\'test\')' }],
13
12
  invalid: [
@@ -6,7 +6,6 @@ const tester = new RuleTester();
6
6
  const ruleName = 'detect-non-literal-regexp';
7
7
  const invalid = 'var a = new RegExp(c, \'i\')';
8
8
 
9
-
10
9
  tester.run(ruleName, require(`../rules/${ruleName}`), {
11
10
  valid: [{ code: 'var a = new RegExp(\'ab+c\', \'i\')' }],
12
11
  invalid: [
@@ -1,17 +1,20 @@
1
1
  'use strict';
2
2
 
3
3
  const RuleTester = require('eslint').RuleTester;
4
- const tester = new RuleTester();
5
4
 
6
- const ruleName = 'detect-non-literal-require';
7
- const invalid = 'var a = require(c)';
5
+ const tester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
8
6
 
7
+ const ruleName = 'detect-non-literal-require';
9
8
 
10
9
  tester.run(ruleName, require(`../rules/${ruleName}`), {
11
- valid: [{ code: 'var a = require(\'b\')' }],
10
+ valid: [{ code: 'var a = require(\'b\')' }, { code: 'var a = require(`b`)' }],
12
11
  invalid: [
13
12
  {
14
- code: invalid,
13
+ code: 'var a = require(c)',
14
+ errors: [{ message: 'Found non-literal argument in require' }]
15
+ },
16
+ {
17
+ code: 'var a = require(`${c}`)',
15
18
  errors: [{ message: 'Found non-literal argument in require' }]
16
19
  }
17
20
  ]
@@ -12,7 +12,6 @@ const valid = 'var a = {};';
12
12
  // const invalidFunction = "TODO";
13
13
  const invalidGeneric = 'var a = {}; a[b] = 4';
14
14
 
15
-
16
15
  // TODO
17
16
  // tester.run(`${ruleName} (Variable Assigned to)`, Rule, {
18
17
  // valid: [{ code: valid }],
@@ -35,7 +34,6 @@ const invalidGeneric = 'var a = {}; a[b] = 4';
35
34
  // ]
36
35
  // });
37
36
 
38
-
39
37
  tester.run(`${ruleName} (Generic)`, Rule, {
40
38
  valid: [{ code: valid }],
41
39
  invalid: [