Skip to content

Commit 1312fcc

Browse files
authored
Merge pull request github#3324 from erik-krogh/BoundSocketIO
Approved by asgerf
2 parents 471f536 + 957e407 commit 1312fcc

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

javascript/ql/src/semmle/javascript/frameworks/SocketIO.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ module SocketIO {
190190
|
191191
on = base.getAMethodCall(EventEmitter::on()) and
192192
on.getArgument(0).mayHaveStringValue(connect) and
193-
this = on.getCallback(1).getParameter(0)
193+
this = on.getABoundCallbackParameter(1, 0)
194194
)
195195
}
196196

javascript/ql/test/library-tests/frameworks/SocketIO/tests.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ test_NamespaceNode
3030
| tst.js:68:1:68:35 | io.on(' ... => {}) | socket.io namespace with path '/' |
3131
| tst.js:69:1:69:32 | ns.on(' ... => {}) | socket.io namespace with path '/' |
3232
| tst.js:70:1:74:2 | ns.on(' ... {});\\n}) | socket.io namespace with path '/' |
33+
| tst.js:85:1:85:37 | io.on(' ... , "x")) | socket.io namespace with path '/' |
3334
test_ClientReceiveNode_getASender
3435
| client2.js:4:1:6:2 | sock.on ... y);\\n}) | tst.js:30:1:30:28 | ns.emit ... event') |
3536
| client2.js:4:1:6:2 | sock.on ... y);\\n}) | tst.js:31:1:31:20 | ns.send('a message') |
@@ -121,6 +122,7 @@ test_SocketNode
121122
| tst.js:71:3:71:35 | socket. ... => {}) | socket.io namespace with path '/' |
122123
| tst.js:72:3:72:46 | socket. ... => {}) | socket.io namespace with path '/' |
123124
| tst.js:73:3:73:43 | socket. ... => {}) | socket.io namespace with path '/' |
125+
| tst.js:84:16:84:21 | socket | socket.io namespace with path '/' |
124126
test_ClientSendNode_getEventName
125127
| client2.js:14:1:14:32 | sock.em ... there") | data |
126128
| client2.js:16:1:16:36 | sock.wr ... => {}) | message |
@@ -171,6 +173,7 @@ test_ServerNode
171173
| tst.js:50:1:67:2 | io.on(' ... t');\\n}) | tst.js:1:12:1:33 | require ... .io')() |
172174
| tst.js:68:1:68:35 | io.on(' ... => {}) | tst.js:1:12:1:33 | require ... .io')() |
173175
| tst.js:80:1:80:10 | obj.server | tst.js:1:12:1:33 | require ... .io')() |
176+
| tst.js:85:1:85:37 | io.on(' ... , "x")) | tst.js:1:12:1:33 | require ... .io')() |
174177
test_ClientSendNode_getAReceiver
175178
| client2.js:14:1:14:32 | sock.em ... there") | tst.js:71:3:71:35 | socket. ... => {}) |
176179
| client2.js:14:1:14:32 | sock.em ... there") | tst.js:72:3:72:46 | socket. ... => {}) |

javascript/ql/test/library-tests/frameworks/SocketIO/tst.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,6 @@ var obj = {
8080
obj.server; // SocketIO::ServerNode
8181
obj.serveClient(false); // not a SocketIO::ServerNode
8282
obj.serveClient(false).server; // not a SocketIO::ServerNode
83+
84+
function foo(x,socket) {}
85+
io.on('connect', foo.bind(null, "x"));

0 commit comments

Comments
 (0)