Skip to content

Commit 4cf7299

Browse files
author
Alvaro Muñoz
committed
restore Spife.qll to working status
1 parent 14faff4 commit 4cf7299

File tree

1 file changed

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

1 file changed

+19
-12
lines changed

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

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,32 @@ import semmle.javascript.frameworks.HTTP
99
* Provides classes for working with [Spife](https://github.com/npm/spife) applications.
1010
*/
1111
module Spife {
12+
private class TaggedTemplateEntryPoint extends API::EntryPoint {
13+
TaggedTemplateEntryPoint() { this = "TaggedTemplateEntryPoint" }
14+
15+
override DataFlow::SourceNode getASource() { result.asExpr() instanceof TaggedTemplateExpr }
16+
}
17+
1218
/**
1319
* A call to a Spife method that sets up a route.
1420
*/
15-
private class RouteSetup extends DataFlow::CallNode, Http::Servers::StandardRouteSetup {
21+
private class RouteSetup extends API::CallNode, Http::Servers::StandardRouteSetup {
1622
TaggedTemplateExpr template;
1723

1824
RouteSetup() {
19-
this.getCalleeNode().asExpr() = template and
20-
API::moduleImport(["@npm/spife/routing", "spife/routing"])
21-
.asSource()
22-
.flowsToExpr(template.getTag())
25+
exists(CallExpr templateCall |
26+
this.getCalleeNode().asExpr() = template and
27+
API::moduleImport(["@npm/spife/routing", "spife/routing"])
28+
.asSource()
29+
.flowsToExpr(template.getTag()) and
30+
templateCall.getAChild() = template
31+
)
2332
}
2433

2534
private string getRoutePattern() {
2635
// Concatenate the constant parts of the expression
2736
result =
28-
strictconcat(Expr e, int i |
37+
concat(Expr e, int i |
2938
e = template.getTemplate().getElement(i) and exists(e.getStringValue())
3039
|
3140
e.getStringValue() order by i
@@ -44,22 +53,20 @@ module Spife {
4453
)
4554
}
4655

47-
DataFlow::Node getHandlerByName(string name) {
48-
result = DataFlow::parameterNode(this.getACallee().getParameter(0)).getAPropertyRead(name)
49-
}
56+
API::Node getHandlerByName(string name) { result = this.getParameter(0).getMember(name) }
5057

51-
DataFlow::Node getHandlerByRoute(string method, string path) {
58+
API::Node getHandlerByRoute(string method, string path) {
5259
exists(string handlerName |
5360
this.hasLine(method, path, handlerName) and
5461
result = this.getHandlerByName(handlerName)
5562
)
5663
}
5764

5865
override DataFlow::SourceNode getARouteHandler() {
59-
result = this.getHandlerByRoute(_, _).getALocalSource().(DataFlow::FunctionNode)
66+
result = this.getHandlerByRoute(_, _).getAValueReachingSink().(DataFlow::FunctionNode)
6067
or
6168
exists(DataFlow::MethodCallNode validation |
62-
validation = this.getHandlerByRoute(_, _).getALocalSource() and
69+
validation = this.getHandlerByRoute(_, _).getAValueReachingSink() and
6370
result = validation.getArgument(1).getAFunctionValue()
6471
)
6572
}

0 commit comments

Comments
 (0)