Skip to content

Commit e38b63e

Browse files
committed
JS: previously js/case-sensitive-middleware-path was not taking into consideration unknown flags
1 parent 178da21 commit e38b63e

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

javascript/ql/src/Security/CWE-178/CaseSensitiveMiddlewarePath.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ predicate isCaseSensitiveMiddleware(
6565
arg = call.getArgument(0) and
6666
regexp.getAReference().flowsTo(arg) and
6767
exists(string flags |
68-
flags = regexp.getFlags() and
68+
flags = regexp.tryGetFlags() and
6969
not RegExp::isIgnoreCase(flags)
7070
)
7171
)

javascript/ql/test/query-tests/Security/CWE-178/CaseSensitiveMiddlewarePath.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
| tst.js:76:9:76:20 | /\\/baz\\/bla/ | This route uses a case-sensitive path $@, but is guarding a $@. A path such as '/BAZ/BLA' will bypass the middleware. | tst.js:76:9:76:20 | /\\/baz\\/bla/ | pattern | tst.js:77:1:79:2 | app.get ... });\\n}) | case-insensitive path |
77
| tst.js:86:9:86:30 | /\\/[Bb] ... 3\\/[a]/ | This route uses a case-sensitive path $@, but is guarding a $@. A path such as '/BAZ3/A' will bypass the middleware. | tst.js:86:9:86:30 | /\\/[Bb] ... 3\\/[a]/ | pattern | tst.js:87:1:89:2 | app.get ... });\\n}) | case-insensitive path |
88
| tst.js:91:9:91:40 | /\\/summ ... ntGame/ | This route uses a case-sensitive path $@, but is guarding a $@. A path such as '/CURRENTGAME' will bypass the middleware. | tst.js:91:9:91:40 | /\\/summ ... ntGame/ | pattern | tst.js:93:1:95:2 | app.get ... O");\\n}) | case-insensitive path |
9+
| tst.js:98:5:98:43 | new Reg ... Flag()) | This route uses a case-sensitive path $@, but is guarding a $@. A path such as '/BAR/1' will bypass the middleware. | tst.js:98:5:98:43 | new Reg ... Flag()) | pattern | tst.js:107:1:108:2 | app.get ... ware\\n}) | case-insensitive path |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ app.get('/currentGame', function (req, res) {
9595
});
9696

9797
app.get(
98-
new RegExp('^/bar(.*)?', unknownFlag()), // NOT OK - Currently not flagged.
98+
new RegExp('^/bar(.*)?', unknownFlag()), // NOT OK - Might be OK if the unknown flag evaluates to case insensitive one
9999
unknown(),
100100
function(req, res, next) {
101101
if (req.params.blah) {

0 commit comments

Comments
 (0)