Skip to content

Commit bdbd00e

Browse files
author
Esben Sparre Andreasen
committed
JS: add newline removal tests for js/incomplete-sanitization
1 parent a61ca48 commit bdbd00e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

javascript/ql/test/query-tests/Security/CWE-116/IncompleteSanitization/IncompleteSanitization.expected

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,7 @@
2525
| tst.js:140:2:140:27 | s.repla ... replace | This replaces only the first occurrence of /}/. |
2626
| tst.js:141:2:141:10 | s.replace | This replaces only the first occurrence of ']'. |
2727
| tst.js:141:2:141:27 | s.repla ... replace | This replaces only the first occurrence of '['. |
28-
| tst.js:185:9:185:17 | s.replace | This replaces only the first occurrence of /'/. |
28+
| tst.js:146:2:146:68 | require ... replace | This replaces only the first occurrence of "\\n". |
29+
| tst.js:148:2:148:10 | x.replace | This replaces only the first occurrence of "\\n". |
30+
| tst.js:149:2:149:24 | x.repla ... replace | This replaces only the first occurrence of "\\n". |
31+
| tst.js:193:9:193:17 | s.replace | This replaces only the first occurrence of /'/. |

javascript/ql/test/query-tests/Security/CWE-116/IncompleteSanitization/tst.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,14 @@ function good12(s) {
141141
s.replace(']', '').replace('[', ''); // probably OK, but still flagged
142142
}
143143

144+
function newlines(s) {
145+
// motivation for whitelist
146+
require("child_process").execSync("which emacs").toString().replace("\n", ""); // OK
147+
148+
x.replace("\n", "").replace(x, y); // NOT OK
149+
x.replace(x, y).replace("\n", ""); // NOT OK
150+
}
151+
144152
app.get('/some/path', function(req, res) {
145153
let untrusted = req.param("p");
146154

0 commit comments

Comments
 (0)