Skip to content

Commit 4797924

Browse files
committed
JS: review comments
1 parent d2a04d3 commit 4797924

File tree

4 files changed

+3
-8
lines changed

4 files changed

+3
-8
lines changed

change-notes/1.19/analysis-javascript.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222
| Regular expression injection | Fewer false-positive results | This rule now identifies calls to `String.prototype.search` with more precision. |
2323
| Unbound event handler receiver | Fewer false-positive results | This rule now recognizes additional ways class methods can be bound. |
2424
| Remote property injection | Fewer results | The precision of this rule has been revised to "medium". Results are no longer shown on LGTM by default. |
25-
| Missing CSRF middleware | Fewer false-positive results | This rule now recognizes CSRF middleware from the [lusca](https://www.npmjs.com/package/lusca) package. |
25+
| Missing CSRF middleware | Fewer false-positive results | This rule now recognizes additional CSRF protection middlewares. |
2626

2727
## Changes to QL libraries

javascript/ql/src/Security/CWE-352/MissingCsrfMiddleware.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ DataFlow::CallNode csrfMiddlewareCreation() {
4444
callee = DataFlow::moduleImport("csurf")
4545
or
4646
callee = DataFlow::moduleImport("lusca") and
47-
result.getOptionArgument(0, "csrf").analyze().getABooleanValue() = true // any truthy value will enable CSRF
47+
exists(result.getOptionArgument(0, "csrf"))
4848
or
4949
callee = DataFlow::moduleMember("lusca", "csrf")
5050
)

javascript/ql/test/query-tests/Security/CWE-352/MissingCsrfMiddleware.expected

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
| csurf_api_example.js:39:37:39:50 | cookieParser() | This cookie middleware is serving a request handler $@ without CSRF protection. | csurf_api_example.js:39:53:41:3 | functio ... e')\\n } | here |
33
| csurf_example.js:18:9:18:22 | cookieParser() | This cookie middleware is serving a request handler $@ without CSRF protection. | csurf_example.js:29:40:31:1 | functio ... sed')\\n} | here |
44
| lusca_example.js:9:9:9:22 | cookieParser() | This cookie middleware is serving a request handler $@ without CSRF protection. | lusca_example.js:23:42:25:1 | functio ... sed')\\n} | here |
5-
| lusca_example.js:9:9:9:22 | cookieParser() | This cookie middleware is serving a request handler $@ without CSRF protection. | lusca_example.js:27:55:29:1 | functio ... sed')\\n} | here |
6-
| lusca_example.js:9:9:9:22 | cookieParser() | This cookie middleware is serving a request handler $@ without CSRF protection. | lusca_example.js:31:40:33:1 | functio ... sed')\\n} | here |
5+
| lusca_example.js:9:9:9:22 | cookieParser() | This cookie middleware is serving a request handler $@ without CSRF protection. | lusca_example.js:27:40:29:1 | functio ... sed')\\n} | here |

javascript/ql/test/query-tests/Security/CWE-352/lusca_example.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ app.post('/process', parseForm, lusca(), function (req, res) { // NOT OK - missi
2424
res.send('data is being processed')
2525
})
2626

27-
app.post('/process', parseForm, lusca({csrf: false}), function (req, res) { // NOT OK - csrf disabled
28-
res.send('data is being processed')
29-
})
30-
3127
app.post('/process_unsafe', parseForm, function (req, res) { // NOT OK
3228
res.send('data is being processed')
3329
})

0 commit comments

Comments
 (0)