Skip to content

Commit 4e1e7bc

Browse files
Max SchaeferEsben Sparre Andreasen
andcommitted
JavaScript: Apply review suggestion.
Co-Authored-By: Esben Sparre Andreasen <[email protected]>
1 parent 3970ead commit 4e1e7bc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

javascript/ql/src/semmle/javascript/security/dataflow/MissingRateLimiting.qll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*/
2424

2525
import javascript
26+
private import semmle.javascript.frameworks.ConnectExpressShared::ConnectExpressShared
2627

2728
// main concepts
2829
/**
@@ -160,8 +161,8 @@ class RouteHandlerLimitedByExpressLimiter extends RateLimitedRouteHandlerExpr {
160161
* A rate-handler function implemented using one of the rate-limiting classes provided
161162
* by the `rate-limiter-flexible` package.
162163
*
163-
* We look for functions that invoke the `consume` method of one of the `RateLimiter*`
164-
* classes from the `rate-limiter-flexible` package on a property of their first argument,
164+
* We look for route handlers that invoke the `consume` method of one of the `RateLimiter*`
165+
* classes from the `rate-limiter-flexible` package on a property of their request parameter,
165166
* like the `rateLimiterMiddleware` function in this example:
166167
*
167168
* ```
@@ -176,14 +177,13 @@ class RateLimiterFlexibleRateLimiter extends DataFlow::FunctionNode {
176177
RateLimiterFlexibleRateLimiter() {
177178
exists(
178179
string rateLimiterClassName, DataFlow::SourceNode rateLimiterClass,
179-
DataFlow::SourceNode rateLimiterInstance
180+
DataFlow::SourceNode rateLimiterInstance, DataFlow::ParameterNode request
180181
|
181182
rateLimiterClassName.matches("RateLimiter%") and
182183
rateLimiterClass = DataFlow::moduleMember("rate-limiter-flexible", rateLimiterClassName) and
183184
rateLimiterInstance = rateLimiterClass.getAnInstantiation() and
184-
getParameter(0).getAPropertyRead() = rateLimiterInstance
185-
.getAMemberCall("consume")
186-
.getAnArgument()
185+
request.getParameter() = getRouteHandlerParameter(getFunction(), "request") and
186+
request.getAPropertyRead() = rateLimiterInstance.getAMemberCall("consume").getAnArgument()
187187
)
188188
}
189189
}

0 commit comments

Comments
 (0)