Skip to content

Commit fa8edee

Browse files
committed
change StoredXss example to use TypeTracking
1 parent 906705f commit fa8edee

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

javascript/ql/examples/queries/dataflow/StoredXss/StoredXssTrackedNode.ql renamed to javascript/ql/examples/queries/dataflow/StoredXss/StoredXssTypeTracking.ql

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ import DataFlow::PathGraph
1515
/**
1616
* An instance of `mysql.createConnection()`, tracked globally.
1717
*/
18-
class MysqlConnection extends TrackedNode {
19-
MysqlConnection() { this = moduleImport("mysql").getAMemberCall("createConnection") }
20-
21-
/**
22-
* Gets a call to the `query` method on this connection object.
23-
*/
24-
MethodCallNode getAQueryCall() {
25-
this.flowsTo(result.getReceiver()) and
26-
result.getMethodName() = "query"
27-
}
18+
DataFlow::SourceNode mysqlConnection(DataFlow::TypeTracker t) {
19+
t.start() and
20+
result = moduleImport("mysql").getAMemberCall("createConnection")
21+
or
22+
exists(DataFlow::TypeTracker t2 | result = mysqlConnection(t2).track(t2, t))
2823
}
2924

25+
/**
26+
* An instance of `mysql.createConnection()`, tracked globally.
27+
*/
28+
DataFlow::SourceNode mysqlConnection() { result = mysqlConnection(DataFlow::TypeTracker::end()) }
29+
3030
/**
3131
* Data returned from a MySQL query.
3232
*
@@ -42,7 +42,7 @@ class MysqlConnection extends TrackedNode {
4242
* ```
4343
*/
4444
class MysqlSource extends StoredXss::Source {
45-
MysqlSource() { this = any(MysqlConnection con).getAQueryCall().getCallback(1).getParameter(1) }
45+
MysqlSource() { this = mysqlConnection().getAMethodCall("query").getCallback(1).getParameter(1) }
4646
}
4747

4848
from StoredXss::Configuration cfg, PathNode source, PathNode sink

0 commit comments

Comments
 (0)