|
1 | 1 | (function(x){
|
2 |
| - x.indexOf("internal") !== -1; // NOT OK, but not flagged |
3 |
| - x.indexOf("localhost") !== -1; // NOT OK, but not flagged |
4 |
| - x.indexOf("secure.com") !== -1; // NOT OK |
5 |
| - x.indexOf("secure.net") !== -1; // NOT OK |
6 |
| - x.indexOf(".secure.com") !== -1; // NOT OK |
7 |
| - x.indexOf("sub.secure.") !== -1; // NOT OK, but not flagged |
8 |
| - x.indexOf(".sub.secure.") !== -1; // NOT OK, but not flagged |
| 2 | + x.indexOf("internal") !== -1; // $ MISSING: Alert |
| 3 | + x.indexOf("localhost") !== -1; // $ MISSING: Alert |
| 4 | + x.indexOf("secure.com") !== -1; // $ Alert |
| 5 | + x.indexOf("secure.net") !== -1; // $ Alert |
| 6 | + x.indexOf(".secure.com") !== -1; // $ Alert |
| 7 | + x.indexOf("sub.secure.") !== -1; // $ MISSING: Alert |
| 8 | + x.indexOf(".sub.secure.") !== -1; // $ MISSING: Alert |
9 | 9 |
|
10 |
| - x.indexOf("secure.com") === -1; // NOT OK |
11 |
| - x.indexOf("secure.com") === 0; // NOT OK |
12 |
| - x.indexOf("secure.com") >= 0; // NOT OK |
| 10 | + x.indexOf("secure.com") === -1; // $ Alert |
| 11 | + x.indexOf("secure.com") === 0; // $ Alert |
| 12 | + x.indexOf("secure.com") >= 0; // $ Alert |
13 | 13 |
|
14 |
| - x.startsWith("https://secure.com"); // NOT OK |
15 |
| - x.endsWith("secure.com"); // NOT OK |
| 14 | + x.startsWith("https://secure.com"); // $ Alert |
| 15 | + x.endsWith("secure.com"); // $ Alert |
16 | 16 | x.endsWith(".secure.com"); // OK
|
17 | 17 | x.startsWith("secure.com/"); // OK
|
18 | 18 | x.indexOf("secure.com/") === 0; // OK
|
19 | 19 |
|
20 |
| - x.includes("secure.com"); // NOT OK |
| 20 | + x.includes("secure.com"); // $ Alert |
21 | 21 |
|
22 | 22 | x.indexOf("#") !== -1; // OK
|
23 | 23 | x.indexOf(":") !== -1; // OK
|
|
29 | 29 | x.indexOf("some/path") !== -1; // OK
|
30 | 30 | x.indexOf("/index.html") !== -1; // OK
|
31 | 31 | x.indexOf(":template:") !== -1; // OK
|
32 |
| - x.indexOf("https://secure.com") !== -1; // NOT OK |
33 |
| - x.indexOf("https://secure.com:443") !== -1; // NOT OK |
34 |
| - x.indexOf("https://secure.com/") !== -1; // NOT OK |
| 32 | + x.indexOf("https://secure.com") !== -1; // $ Alert |
| 33 | + x.indexOf("https://secure.com:443") !== -1; // $ Alert |
| 34 | + x.indexOf("https://secure.com/") !== -1; // $ Alert |
35 | 35 |
|
36 |
| - x.indexOf(".cn") !== -1; // NOT OK, but not flagged |
| 36 | + x.indexOf(".cn") !== -1; // $ MISSING: Alert |
37 | 37 | x.indexOf(".jpg") !== -1; // OK
|
38 | 38 | x.indexOf("index.html") !== -1; // OK
|
39 | 39 | x.indexOf("index.js") !== -1; // OK
|
|
43 | 43 | x.indexOf("secure=true") !== -1; // OK (query param)
|
44 | 44 | x.indexOf("&auth=") !== -1; // OK (query param)
|
45 | 45 |
|
46 |
| - x.indexOf(getCurrentDomain()) !== -1; // NOT OK, but not flagged |
47 |
| - x.indexOf(location.origin) !== -1; // NOT OK, but not flagged |
| 46 | + x.indexOf(getCurrentDomain()) !== -1; // $ MISSING: Alert |
| 47 | + x.indexOf(location.origin) !== -1; // $ MISSING: Alert |
48 | 48 |
|
49 | 49 | x.indexOf("tar.gz") + offset; // OK
|
50 | 50 | x.indexOf("tar.gz") - offset; // OK
|
51 | 51 |
|
52 |
| - x.indexOf("https://example.internal") !== -1; // NOT OK |
| 52 | + x.indexOf("https://example.internal") !== -1; // $ Alert |
53 | 53 | x.indexOf("https://") !== -1; // OK
|
54 | 54 |
|
55 |
| - x.startsWith("https://example.internal"); // NOT OK |
56 |
| - x.indexOf('https://example.internal.org') !== 0; // NOT OK |
57 |
| - x.indexOf('https://example.internal.org') === 0; // NOT OK |
58 |
| - x.endsWith("internal.com"); // NOT OK |
| 55 | + x.startsWith("https://example.internal"); // $ Alert |
| 56 | + x.indexOf('https://example.internal.org') !== 0; // $ Alert |
| 57 | + x.indexOf('https://example.internal.org') === 0; // $ Alert |
| 58 | + x.endsWith("internal.com"); // $ Alert |
59 | 59 | x.startsWith("https://example.internal:80"); // OK
|
60 | 60 |
|
61 |
| - x.indexOf("secure.com") !== -1; // NOT OK |
| 61 | + x.indexOf("secure.com") !== -1; // $ Alert |
62 | 62 | x.indexOf("secure.com") === -1; // OK
|
63 | 63 | !(x.indexOf("secure.com") !== -1); // OK
|
64 | 64 | !x.includes("secure.com"); // OK
|
65 | 65 |
|
66 |
| - if(!x.includes("secure.com")) { // NOT OK |
| 66 | + if(!x.includes("secure.com")) { // $ Alert |
67 | 67 |
|
68 | 68 | } else {
|
69 | 69 | doSomeThingWithTrustedURL(x);
|
70 | 70 | }
|
71 |
| - |
| 71 | + |
72 | 72 | x.startsWith("https://secure.com/foo/bar"); // OK - a forward slash after the domain makes prefix checks safe.
|
73 |
| - x.indexOf("https://secure.com/foo/bar") >= 0 // NOT OK - the url can be anywhere in the string. |
74 |
| - x.indexOf("https://secure.com") >= 0 // NOT OK |
75 |
| - x.indexOf("https://secure.com/foo/bar-baz") >= 0 // NOT OK - the url can be anywhere in the string. |
| 73 | + x.indexOf("https://secure.com/foo/bar") >= 0 // $ Alert - the url can be anywhere in the string. |
| 74 | + x.indexOf("https://secure.com") >= 0 // $ Alert |
| 75 | + x.indexOf("https://secure.com/foo/bar-baz") >= 0 // $ Alert - the url can be anywhere in the string. |
76 | 76 | });
|
0 commit comments