Skip to content

Commit 742e4aa

Browse files
Alvaro Muñozerik-krogh
andauthored
Apply suggestions from code review
Co-authored-by: Erik Krogh Kristensen <[email protected]>
1 parent c7ac237 commit 742e4aa

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

javascript/ql/lib/semmle/javascript/frameworks/Restify.qll

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ module Restify {
384384
}
385385

386386
/**
387-
* The URL of a REstify client, viewed as a sink for request forgery.
387+
* The URL of a Restify client, viewed as a sink for request forgery.
388388
*/
389389
class RequestForgerySink extends RFC::RequestForgery::Sink {
390390
RequestForgerySink() {
@@ -435,8 +435,7 @@ module Restify {
435435
* A header produced by a route handler with no explicit declaration of a Content-Type.
436436
*/
437437
private class ContentTypeRouteHandlerHeader extends Http::ImplicitHeaderDefinition,
438-
DataFlow::FunctionNode {
439-
ContentTypeRouteHandlerHeader() { this instanceof RouteHandler }
438+
DataFlow::FunctionNode instanceof RouteHandler {
440439

441440
override predicate defines(string headerName, string headerValue) {
442441
headerName = "content-type" and headerValue = "application/json"
@@ -454,8 +453,7 @@ module Restify {
454453
override DataFlow::SourceNode getAReference() { result = def.ref() }
455454
}
456455

457-
private class RoutingTreeSetup extends Routing::RouteSetup::MethodCall {
458-
RoutingTreeSetup() { this instanceof RouteSetup }
456+
private class RoutingTreeSetup extends Routing::RouteSetup::MethodCall instanceof RouteSetup {
459457

460458
override string getRelativePath() {
461459
not this.getMethodName() = ["use", "pre", "param", "on"] and // do not treat parameter name as a path

javascript/ql/lib/semmle/javascript/frameworks/Spife.qll

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ module Spife {
186186
string kind;
187187

188188
ContextInputAccess() {
189-
request.ref().flowsTo(super.getReceiver()) and
190-
super.getMethodName() = "get" and
189+
this = request.ref().getAMethodCall("get")
191190
kind = "path"
192191
}
193192

@@ -261,7 +260,7 @@ module Spife {
261260

262261
override predicate definesHeaderValue(string headerName, DataFlow::Node headerValue) {
263262
// reply.header(RESPONSE, 'Cache-Control', 'no-cache')
264-
headerName = this.getNameNode().getStringValue() and
263+
this.getNameNode().mayHaveStringValue(headerName) and
265264
headerValue = this.getArgument(2)
266265
}
267266

@@ -279,10 +278,10 @@ module Spife {
279278
MultipleHeaderDefinitions() {
280279
// reply.header(RESPONSE, {'Cache-Control': 'no-cache'})
281280
// reply(RESPONSE, {'Cache-Control': 'no-cache'})
282-
reply.ref().(DataFlow::CallNode).getCalleeName() = ["header", "reply"] and
283-
reply.ref().(DataFlow::CallNode).getAnArgument().getALocalSource() instanceof
284-
DataFlow::ObjectLiteralNode and
285-
this = reply
281+
exists(DataFlow::CallNode call | call = [reply.ref(), reply.ref().getAMethodCall("header")] |
282+
call.getAnArgument().getALocalSource() instanceof DataFlow::ObjectLiteralNode and
283+
this = call
284+
)
286285
}
287286

288287
/**
@@ -321,10 +320,10 @@ module Spife {
321320
/**
322321
* An HTTP cookie defined in a Spife HTTP response.
323322
*/
324-
private class CookieDefinition extends Http::CookieDefinition, DataFlow::MethodCallNode instanceof ReplySource {
323+
private class CookieDefinition extends Http::CookieDefinition, DataFlow::MethodCallNode {
325324
CookieDefinition() {
326325
// reply.cookie(RESPONSE, 'TEST', 'FOO', {"maxAge": 1000, "httpOnly": true, "secure": true})
327-
this.ref().(DataFlow::MethodCallNode).getMethodName() = "cookie"
326+
this = any(ReplySource r).ref().getAMethodCall("cookie")
328327
}
329328

330329
override DataFlow::Node getNameArgument() { result = this.getArgument(1) }

0 commit comments

Comments
 (0)