Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 77e59f1

Browse files
author
Max Schaefer
committed
JavaScript: Be more lenient about namespace matching.
1 parent 41d83d5 commit 77e59f1

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ module SocketIOClient {
372372
)
373373
}
374374

375-
/** Gets the path of the namespace this socket belongs to. */
375+
/** Gets the path of the namespace this socket belongs to, if it can be determined. */
376376
string getNamespacePath() {
377377
// the path name of the specified URL
378378
exists(string url, string pathRegex |
@@ -395,14 +395,20 @@ module SocketIOClient {
395395
SocketIO::ServerObject getATargetServer() {
396396
exists(NPMPackage pkg |
397397
result.getOrigin().getFile() = pkg.getAFile() and
398-
this.getFile() = pkg.getAFile() and
398+
this.getFile() = pkg.getAFile()
399+
|
400+
not exists(getNamespacePath()) or
399401
exists(result.getNamespace(getNamespacePath()))
400402
)
401403
}
402404

403405
/** Gets a namespace this socket may be communicating with. */
404406
SocketIO::NamespaceObject getATargetNamespace() {
405407
result = getATargetServer().getNamespace(getNamespacePath())
408+
or
409+
// if the namespace of this socket cannot be determined, overapproximate
410+
not exists(getNamespacePath()) and
411+
result = getATargetServer().getNamespace(_)
406412
}
407413

408414
/** Gets a server-side socket this client-side socket may be communicating with. */
@@ -473,7 +479,7 @@ module SocketIOClient {
473479
SocketNode getSocket() { result = base }
474480

475481
/**
476-
* Gets the path of the namespace to which data is sent.
482+
* Gets the path of the namespace to which data is sent, if it can be determined.
477483
*/
478484
string getNamespacePath() { result = base.getNamespacePath() }
479485

0 commit comments

Comments
 (0)