JS: whitelist quote stripping for js/incomplete-sanitization

This commit is contained in:
Esben Sparre Andreasen
2019-09-05 09:47:49 +01:00
parent 641232a9d7
commit a9665f53b8
3 changed files with 10 additions and 0 deletions

View File

@@ -17,6 +17,7 @@
| **Query** | **Expected impact** | **Change** |
|--------------------------------|------------------------------|---------------------------------------------------------------------------|
| Incomplete string escaping or encoding (`js/incomplete-sanitization`) | Fewer false-positive results | This rule now recognizes additional ways delimiters can be stripped away. |
| Client-side cross-site scripting (`js/xss`) | More results | More potential vulnerabilities involving functions that manipulate DOM attributes are now recognized. |
| Prototype pollution (`js/prototype-pollution`) | Same results | The results are now shown on LGTM by default. |

View File

@@ -122,6 +122,10 @@ predicate isDelimiterUnwrapper(
left = "{" and right = "}"
or
left = "(" and right = ")"
or
left = "\"" and right = "\""
or
left = "'" and right = "'"
|
removesFirstOccurence(leftUnwrap, left) and
removesFirstOccurence(rightUnwrap, right) and

View File

@@ -192,3 +192,8 @@ app.get('/some/path', function(req, res) {
var indirect = /'/;
return s.replace(indirect, ""); // NOT OK
});
(function (s) {
s.replace('"', '').replace('"', ''); // OK
s.replace("'", "").replace("'", ""); // OK
});