Skip to content

Commit 48f7a58

Browse files
committed
JS: Update IncompleteHostnameRegExp test to match reality
1 parent a83508a commit 48f7a58

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

javascript/ql/test/query-tests/Security/CWE-020/IncompleteHostnameRegExp/IncompleteHostnameRegExp.expected

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
problems
21
| tst-IncompleteHostnameRegExp.js:3:3:3:28 | ^http:\\/\\/test.example.com | This regular expression has an unescaped '.' before 'example.com', so it might match more hosts than expected. | tst-IncompleteHostnameRegExp.js:3:2:3:29 | /^http: ... le.com/ | here |
32
| tst-IncompleteHostnameRegExp.js:5:3:5:28 | ^http:\\/\\/test.example.net | This regular expression has an unescaped '.' before 'example.net', so it might match more hosts than expected. | tst-IncompleteHostnameRegExp.js:5:2:5:29 | /^http: ... le.net/ | here |
43
| tst-IncompleteHostnameRegExp.js:6:3:6:42 | ^http:\\/\\/test.(example-a\|example-b).com | This regular expression has an unescaped '.' before '(example-a\|example-b).com', so it might match more hosts than expected. | tst-IncompleteHostnameRegExp.js:6:2:6:43 | /^http: ... b).com/ | here |
@@ -27,10 +26,3 @@ problems
2726
| tst-IncompleteHostnameRegExp.js:55:14:55:38 | ^http://test.example.com | This regular expression has an unescaped '.' before 'example.com', so it might match more hosts than expected. | tst-IncompleteHostnameRegExp.js:55:13:55:39 | '^http: ... le.com' | here |
2827
| tst-IncompleteHostnameRegExp.js:59:5:59:20 | foo.example\\.com | This regular expression has an unescaped '.' before 'example\\.com', so it might match more hosts than expected. | tst-IncompleteHostnameRegExp.js:59:2:59:32 | /^(foo. ... ever)$/ | here |
2928
| tst-IncompleteHostnameRegExp.js:61:18:61:41 | ^http://test.example.com | This regular expression has an unescaped '.' before 'example.com', so it might match more hosts than expected. | tst-IncompleteHostnameRegExp.js:61:17:61:42 | "^http: ... le.com" | here |
30-
testFailures
31-
| tst-IncompleteHostnameRegExp.js:9:45:9:54 | // $ Alert | Missing result: Alert |
32-
| tst-IncompleteHostnameRegExp.js:10:3:10:36 | This regular expression has an unescaped '.' before 'example.com', so it might match more hosts than expected. | Unexpected result: Alert |
33-
| tst-IncompleteHostnameRegExp.js:17:35:17:44 | // $ Alert | Missing result: Alert |
34-
| tst-IncompleteHostnameRegExp.js:36:43:36:52 | // $ Alert | Missing result: Alert |
35-
| tst-IncompleteHostnameRegExp.js:42:69:42:78 | // $ Alert | Missing result: Alert |
36-
| tst-IncompleteHostnameRegExp.js:59:5:59:20 | This regular expression has an unescaped '.' before 'example\\.com', so it might match more hosts than expected. | Unexpected result: Alert |

javascript/ql/test/query-tests/Security/CWE-020/IncompleteHostnameRegExp/tst-IncompleteHostnameRegExp.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
/^http:\/\/test.(example-a|example-b).com/; // $ Alert
77
/^http:\/\/(.+).example.com\//; // $ Alert
88
/^http:\/\/(\\.+)\\.example.com/;
9-
/^http:\/\/(?:.+)\\.test\\.example.com\//; // $ Alert
10-
/^http:\/\/test.example.com\/(?:.*)/;
9+
/^http:\/\/(?:.+)\\.test\\.example.com\//; // $ MISSING: Alert (TODO)
10+
/^http:\/\/test.example.com\/(?:.*)/; // $ SPURIOUS: Alert (TODO)
1111
new RegExp("^http://test.example.com"); // $ Alert
1212
if (s.match("^http://test.example.com")) {} // $ Alert
1313

1414
function id(e) { return e; }
1515
new RegExp(id(id(id("^http://test.example.com")))); // $ Alert
1616

17-
new RegExp(`test.example.com$`); // $ Alert
17+
new RegExp(`test.example.com$`); // $ MISSING: Alert (TODO)
1818

1919
let hostname = '^test.example.com'; // $ Alert
2020
new RegExp(`${hostname}$`);
@@ -33,13 +33,13 @@
3333
}
3434
domains.map(d => convert2(d));
3535

36-
/^(.+\.(?:example-a|example-b)\.com)\//; // $ Alert
36+
/^(.+\.(?:example-a|example-b)\.com)\//; // $ MISSING: Alert (TODO)
3737
/^(https?:)?\/\/((service|www).)?example.com(?=$|\/)/; // $ Alert
3838
/^(http|https):\/\/www.example.com\/p\/f\//; // $ Alert
3939
/^(http:\/\/sub.example.com\/)/g; // $ Alert
4040
/^https?:\/\/api.example.com/; // $ Alert
4141
new RegExp('^http://localhost:8000|' + '^https?://.+\\.example\\.com/'); // $ Alert
42-
new RegExp('^http[s]?:\/\/?sub1\\.sub2\\.example\\.com\/f\/(.+)'); // $ Alert
42+
new RegExp('^http[s]?:\/\/?sub1\\.sub2\\.example\\.com\/f\/(.+)'); // $ MISSING: Alert (TODO)
4343
/^https:\/\/[a-z]*.example.com$/; // $ Alert
4444
RegExp('^protos?://(localhost|.+.example.net|.+.example-a.com|.+.example-b.com|.+.example.internal)'); // $ Alert
4545

@@ -56,7 +56,7 @@
5656

5757
/^http:\/\/(..|...)\.example\.com\/index\.html/; // OK, wildcards are intentional
5858
/^http:\/\/.\.example\.com\/index\.html/; // OK, the wildcard is intentional
59-
/^(foo.example\.com|whatever)$/; // kinda OK - one disjunction doesn't even look like a hostname
59+
/^(foo.example\.com|whatever)$/; // $ SPURIOUS: Alert (TODO) (kinda OK - one disjunction doesn't even look like a hostname)
6060

6161
if (s.matchAll("^http://test.example.com")) {} // $ Alert
6262
});

0 commit comments

Comments
 (0)