Skip to content

Commit ee7b31d

Browse files
committed
JS: Add some query IDs
1 parent 6a56063 commit ee7b31d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

javascript/ql/test/query-tests/Security/CWE-730/RegExpInjection.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var URI = require("urijs");
44
app.get('/findKey', function(req, res) {
55
var key = req.param("key"), input = req.param("input");
66

7-
var re = new RegExp("\\b" + key + "=(.*)\n"); // $ Alert - Unsanitized user input is used to construct a regular expression
7+
var re = new RegExp("\\b" + key + "=(.*)\n"); // $ Alert[js/regex-injection] - Unsanitized user input is used to construct a regular expression
88

99
function wrap(s) {
1010
return "\\b" + wrap2(s);
@@ -14,16 +14,16 @@ app.get('/findKey', function(req, res) {
1414
return s + "=(.*)\n";
1515
}
1616

17-
new RegExp(wrap(key)); // $ Alert
18-
new RegExp(wrap(key)); // $ Alert - duplicated to test precision of flow tracking
17+
new RegExp(wrap(key)); // $ Alert[js/regex-injection]
18+
new RegExp(wrap(key)); // $ Alert[js/regex-injection] - duplicated to test precision of flow tracking
1919

2020
function getKey() {
2121
return req.param("key");
2222
}
23-
new RegExp(getKey()); // $ Alert
23+
new RegExp(getKey()); // $ Alert[js/regex-injection]
2424

2525
function mkRegExp(s) {
26-
return new RegExp(s); // $ Alert
26+
return new RegExp(s); // $ Alert[js/regex-injection]
2727
}
2828
mkRegExp(key);
2929
mkRegExp(getKey());
@@ -93,7 +93,7 @@ app.get("argv", function(req, res) {
9393

9494
var sanitized = input.replace(new RegExp("[\\-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]"), "\\$&");
9595
new RegExp(sanitized); // $ Alert[js/regex-injection]
96-
96+
9797
var sanitized = input.replace(new RegExp("[\\-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]", "g"), "\\$&");
9898
new RegExp(sanitized);
9999

0 commit comments

Comments
 (0)