Skip to content

Commit 2f3a76c

Browse files
committed
JS: Handle global variable d3
1 parent 3b11958 commit 2f3a76c

File tree

1 file changed

+13
-0
lines changed
  • javascript/ql/src/semmle/javascript/frameworks

1 file changed

+13
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ private import semmle.javascript.security.dataflow.Xss
55

66
/** Provides classes and predicates modelling aspects of the `d3` library. */
77
module D3 {
8+
/** The global variable `d3` as an entry point for API graphs. */
9+
private class D3GlobalEntry extends API::EntryPoint {
10+
D3GlobalEntry() { this = "D3GlobalEntry" }
11+
12+
override DataFlow::SourceNode getAUse() {
13+
result = DataFlow::globalVarRef("d3")
14+
}
15+
16+
override DataFlow::Node getARhs() { none() }
17+
}
18+
819
/** Gets an API node referring to the `d3` module. */
920
API::Node d3() {
1021
result = API::moduleImport("d3")
@@ -13,6 +24,8 @@ module D3 {
1324
result = API::moduleImport(any(string s | s.regexpMatch("@.*/d3(-\\w+)?")))
1425
or
1526
result = API::moduleImport("d3-node").getInstance().getMember("d3")
27+
or
28+
result = API::root().getASuccessor(any(D3GlobalEntry i))
1629
}
1730

1831
/**

0 commit comments

Comments
 (0)