Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e01a984

Browse files
committed
JS: Update test annotations
1 parent 153d346 commit e01a984

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
"http://evil.com/?http://good.com".match("https?://good.com"); // NOT OK
44
"http://evil.com/?http://good.com".match(new RegExp("https?://good.com")); // NOT OK
5-
"http://evil.com/?http://good.com".match("^https?://good.com"); // OK
6-
"http://evil.com/?http://good.com".match(/^https?:\/\/good.com/); // OK
7-
"http://evil.com/?http://good.com".match("(^https?://good1.com)|(^https?://good2.com)"); // OK
8-
"http://evil.com/?http://good.com".match("(https?://good.com)|(^https?://goodie.com)"); // NOT OK, but not detected
5+
"http://evil.com/?http://good.com".match("^https?://good.com"); // NOT OK - missing post-anchor
6+
"http://evil.com/?http://good.com".match(/^https?:\/\/good.com/); // NOT OK - missing post-anchor
7+
"http://evil.com/?http://good.com".match("(^https?://good1.com)|(^https?://good2.com)"); // NOT OK - missing post-anchor
8+
"http://evil.com/?http://good.com".match("(https?://good.com)|(^https?://goodie.com)"); // NOT OK - missing post-anchor
99

1010
/https?:\/\/good.com/.exec("http://evil.com/?http://good.com"); // NOT OK
1111
new RegExp("https?://good.com").exec("http://evil.com/?http://good.com"); // NOT OK
@@ -23,7 +23,7 @@
2323
"https?://good.com", // NOT OK, referenced below
2424
/https?:\/\/good.com/, // NOT OK, referenced below
2525
new RegExp("https?://good.com"), // NOT OK, referenced below
26-
"^https?://good.com"
26+
"^https?://good.com" // NOT OK - missing post-anchor
2727
];
2828
function isTrustedUrl(url) {
2929
for (let trustedUrl of trustedUrls) {
@@ -105,6 +105,4 @@
105105

106106
/\.com|\.org/; // OK, has no domain name
107107
/example\.com|whatever/; // OK, the other disjunction doesn't match a hostname
108-
109-
/^https?:\/\/www\.example\.com\/.*\.html|^https?:\/\/www\.(?:example1|example2).com\/foo\/\d+\/\d+.html/i; // OK
110108
});

0 commit comments

Comments
 (0)