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

Skip to content

Commit d3f587c

Browse files
committed
JS: Restrict class values flowing through globals
1 parent dbfd0ae commit d3f587c

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

javascript/ql/src/semmle/javascript/dataflow/Nodes.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,12 @@ class ClassNode extends DataFlow::SourceNode {
674674
*/
675675
DataFlow::SourceNode getAClassReference(DataFlow::TypeTracker t) {
676676
t.start() and
677-
result.(AnalyzedNode).getAValue() = getAbstractClassValue()
677+
result.(AnalyzedNode).getAValue() = getAbstractClassValue() and
678+
(
679+
not CallGraph::isIndefiniteGlobal(result)
680+
or
681+
result.getAstNode().getFile() = this.getAstNode().getFile()
682+
)
678683
or
679684
exists(DataFlow::TypeTracker t2 | result = getAClassReference(t2).track(t2, t))
680685
}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
| arraydef.js:1:1:1:19 | function Array() {} | Function Array is sometimes invoked as a constructor (for example $@), and sometimes as a normal function (for example $@). | arraycalls.js:2:1:2:13 | new Array(45) | here | arraycalls.js:1:1:1:9 | Array(45) | here |
21
| m.js:1:8:1:22 | functio ... = x;\\n} | Function A is sometimes invoked as a constructor (for example $@), and sometimes as a normal function (for example $@). | c1.js:2:1:2:9 | new A(42) | here | c2.js:2:1:2:5 | A(23) | here |
32
| tst.js:1:1:1:22 | functio ... = y;\\n} | Function Point is sometimes invoked as a constructor (for example $@), and sometimes as a normal function (for example $@). | tst.js:6:1:6:17 | new Point(23, 42) | here | tst.js:7:1:7:13 | Point(56, 72) | here |

0 commit comments

Comments
 (0)