Skip to content

Commit 407df37

Browse files
author
Alvaro Muñoz
committed
Add feedback from Code review
1 parent 3e92b4c commit 407df37

File tree

1 file changed

+12
-15
lines changed
  • javascript/ql/lib/semmle/javascript/frameworks

1 file changed

+12
-15
lines changed

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

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -209,26 +209,25 @@ module Spife {
209209
* route handler.
210210
*/
211211
private class ReplyCall extends API::CallNode {
212+
boolean isDirectReplyCall;
213+
212214
ReplyCall() {
213215
// reply(resp)
214-
this = API::moduleImport(["@npm/spife/reply", "spife/reply"]).getACall()
216+
this = API::moduleImport(["@npm/spife/reply", "spife/reply"]).getACall() and
217+
isDirectReplyCall = true
215218
or
216219
// reply.header(resp, 'foo', 'bar')
217-
this = API::moduleImport(["@npm/spife/reply", "spife/reply"]).getAMember().getACall()
220+
this = API::moduleImport(["@npm/spife/reply", "spife/reply"]).getAMember().getACall() and
221+
isDirectReplyCall = false
218222
}
219223

220-
predicate isDirectReplyCall() {
221-
this = API::moduleImport(["@npm/spife/reply", "spife/reply"]).getACall()
222-
}
224+
predicate isDirectReplyCall() { isDirectReplyCall = true }
223225

224226
/**
225227
* Gets the route handler that provides this response.
226228
*/
227229
RouteHandler getRouteHandler() {
228-
exists(RouteHandler handler |
229-
handler.getAReturn() = this.getReturn().getAValueReachableFromSource() and
230-
result = handler
231-
)
230+
result.getAReturn() = this.getReturn().getAValueReachableFromSource()
232231
}
233232
}
234233

@@ -248,9 +247,7 @@ module Spife {
248247
headerValue = super.getArgument(2)
249248
}
250249

251-
override DataFlow::Node getNameNode() {
252-
result = super.getArgument(1)
253-
}
250+
override DataFlow::Node getNameNode() { result = super.getArgument(1) }
254251

255252
override RouteHandler getRouteHandler() { result = ReplyCall.super.getRouteHandler() }
256253
}
@@ -380,14 +377,14 @@ module Spife {
380377
* An object passed to the `template` method of the reply object.
381378
*/
382379
private class TemplateObjectInput extends DataFlow::Node {
383-
TemplateCall call;
380+
ReplyCall call;
384381

385-
TemplateObjectInput() { this = call.(ReplyCall).getArgument(1) }
382+
TemplateObjectInput() { this = call.getArgument(1) }
386383

387384
/**
388385
* Gets the route handler that uses this object.
389386
*/
390-
RouteHandler getRouteHandler() { result = call.(ReplyCall).getRouteHandler() }
387+
RouteHandler getRouteHandler() { result = call.getRouteHandler() }
391388
}
392389

393390
/**

0 commit comments

Comments
 (0)