-
-
Notifications
You must be signed in to change notification settings - Fork 106
/
Copy pathdetect-object-injection.js
47 lines (39 loc) · 1.12 KB
/
detect-object-injection.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
'use strict';
const RuleTester = require('eslint').RuleTester;
const tester = new RuleTester();
const ruleName = 'detect-object-injection';
const Rule = require(`../rules/${ruleName}`);
const valid = 'var a = {};';
// const invalidVariable = "TODO";
// const invalidFunction = "TODO";
const invalidGeneric = 'var a = {}; a[b] = 4';
// TODO
// tester.run(`${ruleName} (Variable Assigned to)`, Rule, {
// valid: [{ code: valid }],
// invalid: [
// {
// code: invalidVariable,
// errors: [{ message: `Variable Assigned to Object Injection Sink: <input>: 1\n\t${invalidVariable}\n\n` }]
// }
// ]
// });
//
//
// tester.run(`${ruleName} (Function)`, Rule, {
// valid: [{ code: valid }],
// invalid: [
// {
// code: invalidFunction,
// errors: [{ message: `Variable Assigned to Object Injection Sink: <input>: 1\n\t${invalidFunction}\n\n` }]
// }
// ]
// });
tester.run(`${ruleName} (Generic)`, Rule, {
valid: [{ code: valid }],
invalid: [
{
code: invalidGeneric,
errors: [{ message: `Generic Object Injection Sink: <input>: 1\n\t${invalidGeneric}\n\n` }]
}
]
});