mirror of
https://github.com/github/codeql.git
synced 2026-05-01 11:45:14 +02:00
JS: recognize HTTP URLs in js/incomplete-url-sanitization
This commit is contained in:
@@ -19,8 +19,12 @@ where
|
||||
call.getMethodName() = name and
|
||||
substring = call.getArgument(0) and
|
||||
substring.mayHaveStringValue(target) and
|
||||
// target contains a domain on a common TLD, and perhaps some other URL components
|
||||
target.regexpMatch("(?i)([a-z]*:?//)?\\.?([a-z0-9-]+\\.)+(com|org|edu|gov|uk|net)(:[0-9]+)?/?") and
|
||||
(
|
||||
// target contains a domain on a common TLD, and perhaps some other URL components
|
||||
target.regexpMatch("(?i)([a-z]*:?//)?\\.?([a-z0-9-]+\\.)+(com|org|edu|gov|uk|net)(:[0-9]+)?/?") or
|
||||
// target is a HTTP URL to a domain on any TLD
|
||||
target.regexpMatch("(?i)https?://([a-z0-9-]+\\.)+([a-z]+)(:[0-9]+)?/?")
|
||||
) and
|
||||
// whitelist
|
||||
not (
|
||||
name = "indexOf" and
|
||||
|
||||
@@ -10,3 +10,4 @@
|
||||
| tst-IncompleteUrlSubstringSanitization.js:32:5:32:35 | x.index ... e.com") | '$@' may be at an arbitrary position in the sanitized URL. | tst-IncompleteUrlSubstringSanitization.js:32:15:32:34 | "https://secure.com" | https://secure.com |
|
||||
| tst-IncompleteUrlSubstringSanitization.js:33:5:33:39 | x.index ... m:443") | '$@' may be at an arbitrary position in the sanitized URL. | tst-IncompleteUrlSubstringSanitization.js:33:15:33:38 | "https: ... om:443" | https://secure.com:443 |
|
||||
| tst-IncompleteUrlSubstringSanitization.js:34:5:34:36 | x.index ... .com/") | '$@' may be at an arbitrary position in the sanitized URL. | tst-IncompleteUrlSubstringSanitization.js:34:15:34:35 | "https: ... e.com/" | https://secure.com/ |
|
||||
| tst-IncompleteUrlSubstringSanitization.js:52:5:52:41 | x.index ... ernal") | '$@' may be at an arbitrary position in the sanitized URL. | tst-IncompleteUrlSubstringSanitization.js:52:15:52:40 | "https: ... ternal" | https://example.internal |
|
||||
|
||||
@@ -48,4 +48,7 @@
|
||||
|
||||
x.indexOf("tar.gz") + offset // OK
|
||||
x.indexOf("tar.gz") - offset // OK
|
||||
|
||||
x.indexOf("https://example.internal"); // NOT OK
|
||||
x.indexOf("https://"); // OK
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user